fix from Peter Samuelson for use-after-free bug parsing wildcards in sudoers
[debian/sudo] / sudo.c
diff --git a/sudo.c b/sudo.c
index 0f8e2deb79e832139b5b113a535d969b71438647..6eb5930b165cd1c03c6ced4d304ba724fdb2917d 100644 (file)
--- a/sudo.c
+++ b/sudo.c
 #include "version.h"
 
 #ifndef lint
-__unused __unused static const char rcsid[] = "$Sudo: sudo.c,v 1.369.2.39 2008/04/10 17:56:05 millert Exp $";
+__unused __unused static const char rcsid[] = "$Sudo: sudo.c,v 1.369.2.41 2008/06/21 19:04:07 millert Exp $";
 #endif /* lint */
 
 /*
@@ -131,6 +131,7 @@ extern char **insert_env_vars               __P((char **, struct list_member *));
 extern struct passwd *sudo_getpwnam    __P((const char *));
 extern struct passwd *sudo_getpwuid    __P((uid_t));
 extern struct passwd *sudo_pwdup       __P((const struct passwd *));
+extern void runas_resetgroups          __P((void));
 
 /*
  * Globals
@@ -155,7 +156,7 @@ login_cap_t *lc;
 #ifdef HAVE_BSD_AUTH_H
 char *login_style;
 #endif /* HAVE_BSD_AUTH_H */
-sigaction_t saved_sa_int, saved_sa_quit, saved_sa_tstp, saved_sa_chld;
+sigaction_t saved_sa_int, saved_sa_quit, saved_sa_tstp;
 
 
 int
@@ -204,8 +205,6 @@ main(argc, argv, envp)
     (void) sigaction(SIGINT, &sa, &saved_sa_int);
     (void) sigaction(SIGQUIT, &sa, &saved_sa_quit);
     (void) sigaction(SIGTSTP, &sa, &saved_sa_tstp);
-    sa.sa_handler = reapchild;
-    (void) sigaction(SIGCHLD, &sa, &saved_sa_chld);
 
     /*
      * Turn off core dumps and close open files.
@@ -437,7 +436,6 @@ main(argc, argv, envp)
        (void) sigaction(SIGINT, &saved_sa_int, NULL);
        (void) sigaction(SIGQUIT, &saved_sa_quit, NULL);
        (void) sigaction(SIGTSTP, &saved_sa_tstp, NULL);
-       (void) sigaction(SIGCHLD, &saved_sa_chld, NULL);
 
 #ifndef PROFILING
        if (ISSET(sudo_mode, MODE_BACKGROUND) && fork() > 0)
@@ -916,7 +914,10 @@ args_done:
            warnx("you may not specify environment variables in edit mode");
        usage(1);
     }
-
+    if (ISSET(rval, MODE_PRESERVE_ENV) && ISSET(rval, MODE_LOGIN_SHELL)) {
+       warnx("you may not specify both the `-i' and `-E' options");
+       usage(1);
+    }
     if (user_runas != NULL && !ISSET(rval, (MODE_EDIT|MODE_RUN))) {
        if (excl != '\0')
            warnx("the `-u' and '-%c' options may not be used together", excl);
@@ -1240,6 +1241,7 @@ set_runaspw(user)
        if (runas_pw == NULL)
            log_error(NO_MAIL|MSG_ONLY, "no passwd entry for %s!", user);
     }
+    runas_resetgroups();
     return(TRUE);
 }