]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/adminutil.c
Import changes from CUPS 1.4svn-r8704.
[thirdparty/cups.git] / cups / adminutil.c
index e2c5ea827dbe49154805a3e5ea9003c194157386..826ec86bd72f5ca8e011c2cffd1e9739bead8eb8 100644 (file)
@@ -2173,18 +2173,23 @@ do_samba_command(const char *command,   /* I - Command to run */
     * Child goes here, redirect stdin/out/err and execute the command...
     */
 
-    close(0);
-    open("/dev/null", O_RDONLY);
+    int fd = open("/dev/null", O_RDONLY);
 
-    close(1);
+    if (fd > 0)
+    {
+      dup2(fd, 0);
+      close(fd);
+    }
 
     if (logfile)
-      dup(fileno(logfile));
-    else
-      open("/dev/null", O_WRONLY);
+      dup2(fileno(logfile), 1);
+    else if ((fd = open("/dev/null", O_WRONLY)) > 1)
+    {
+      dup2(fd, 1);
+      close(fd);
+    }
 
-    close(2);
-    dup(1);
+    dup2(1, 2);
 
     execlp(command, command, address, "-N", "-A", authfile, "-c", subcmd,
            (char *)0);