Imported Upstream version 1.8.2
[debian/sudo] / src / exec.c
index 510ce11345059c5223a63a7b22c0901f57a01ed6..52dbdbb1dce70acd0a7db15e245271c33c18b4d5 100644 (file)
@@ -122,7 +122,7 @@ static int fork_cmnd(struct command_details *details, int sv[2])
     child = fork();
     switch (child) {
     case -1:
-       error(1, "fork");
+       error(1, _("unable to fork"));
        break;
     case 0:
        /* child */
@@ -216,27 +216,26 @@ sudo_execve(struct command_details *details, struct command_status *cstat)
                cstat->val = errno;
                return -1;
            case 0:
-               /* child continues */   
+               /* child continues without controlling terminal */
+               (void)setpgid(0, 0);
                break;
            default:
-               /* parent exits */
-               exit(0);
+               /* parent exits (but does not flush buffers) */
+               _exit(0);
        }
     }
 
     /*
      * If we have an I/O plugin or the policy plugin has requested one, we
      * need to allocate a pty.  It is OK to set log_io in the pty-only case
-     * as the tailqueue plugin will be empty and no I/O logging will occur.
+     * as the io plugin tailqueue will be empty and no I/O logging will occur.
      */
     if (!tq_empty(&io_plugins) || ISSET(details->flags, CD_USE_PTY)) {
        log_io = TRUE;
-       if (!ISSET(details->flags, CD_BACKGROUND)) {
-           if (ISSET(details->flags, CD_SET_UTMP))
-               utmp_user = details->utmp_user ? details->utmp_user : user_details.username;
-           sudo_debug(8, "allocate pty for I/O logging");
-           pty_setup(details->euid, user_details.tty, utmp_user);
-       }
+       if (ISSET(details->flags, CD_SET_UTMP))
+           utmp_user = details->utmp_user ? details->utmp_user : user_details.username;
+       sudo_debug(8, "allocate pty for I/O logging");
+       pty_setup(details->euid, user_details.tty, utmp_user);
     }
 
     /*
@@ -244,14 +243,14 @@ sudo_execve(struct command_details *details, struct command_status *cstat)
      * Parent sends signal info to child and child sends back wait status.
      */
     if (socketpair(PF_UNIX, SOCK_DGRAM, 0, sv) == -1)
-       error(1, "cannot create sockets");
+       error(1, _("unable to create sockets"));
 
     /*
      * We use a pipe to atomically handle signal notification within
      * the select() loop.
      */
     if (pipe_nonblock(signal_pipe) != 0)
-       error(1, "cannot create pipe");
+       error(1, _("unable to create pipe"));
 
     zero_bytes(&sa, sizeof(sa));
     sigemptyset(&sa.sa_mask);
@@ -317,7 +316,7 @@ sudo_execve(struct command_details *details, struct command_status *cstat)
        if (nready == -1) {
            if (errno == EINTR)
                continue;
-           error(1, "select failed");
+           error(1, _("select failed"));
        }
        if (FD_ISSET(sv[0], fdsw)) {
            forward_signals(sv[0]);
@@ -385,7 +384,7 @@ sudo_execve(struct command_details *details, struct command_status *cstat)
     if (ISSET(details->flags, CD_RBAC_ENABLED)) {
        /* This is probably not needed in log_io mode. */
        if (selinux_restore_tty() != 0)
-           warningx("unable to restore tty label");
+           warningx(_("unable to restore tty label"));
     }
 #endif