]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
tools: restore lxc-create log behavior
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 11 Jun 2018 11:15:48 +0000 (13:15 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 08:12:29 +0000 (09:12 +0100)
Older versions of lxc-create used to set log_file to "none" when a log priority
but no log file was specified on the command line. Let's restore this behavior.

Closes #2392.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/tools/lxc_create.c

index 915f62984d4aa4dbefe5f997942d433f4031b49a..dc29f8e123a386c94fa6366e044d6ff1f8baae79 100644 (file)
@@ -213,19 +213,21 @@ int main(int argc, char *argv[])
        if (lxc_arguments_parse(&my_args, argc, argv))
                exit(EXIT_FAILURE);
 
-       if (!my_args.log_file)
-               my_args.log_file = "none";
-
-       log.name = my_args.name;
-       log.file = my_args.log_file;
-       log.level = my_args.log_priority;
-       log.prefix = my_args.progname;
-       log.quiet = my_args.quiet;
-       log.lxcpath = my_args.lxcpath[0];
-
-       if (lxc_log_init(&log))
-               exit(EXIT_FAILURE);
-       lxc_log_options_no_override();
+       /* Only create log if explicitly instructed */
+       if (my_args.log_file || my_args.log_priority) {
+               log.name = my_args.name;
+               if (!my_args.log_file)
+                       log.file = "none";
+               else
+                       log.file = my_args.log_file;
+               log.level = my_args.log_priority;
+               log.prefix = my_args.progname;
+               log.quiet = my_args.quiet;
+               log.lxcpath = my_args.lxcpath[0];
+
+               if (lxc_log_init(&log))
+                       exit(EXIT_FAILURE);
+       }
 
        if (!my_args.template) {
                fprintf(stderr, "A template must be specified.\n");