stop touching the wrong stamp filename after configuring
[debian/sudo] / check.c
diff --git a/check.c b/check.c
index d6efa6d0befe153b9d8dcb251fda09371bbf538e..badf3e4007735df5ec8ad5e454bd3cefc811cf9b 100644 (file)
--- a/check.c
+++ b/check.c
@@ -119,7 +119,13 @@ check_user(validated, mode)
     if (ISSET(mode, MODE_INVALIDATE)) {
        SET(validated, FLAG_CHECK_USER);
     } else {
-       if (user_uid == 0 || user_uid == runas_pw->pw_uid || user_is_exempt())
+       /*
+        * Don't prompt for the root passwd or if the user is exempt.
+        * If the user is not changing uid/gid, no need for a password.
+        */
+       if (user_uid == 0 || (user_uid == runas_pw->pw_uid &&
+           (!runas_gr || user_in_group(sudo_user.pw, runas_gr->gr_name))) ||
+           user_is_exempt())
            return;
     }
 
@@ -205,7 +211,7 @@ update_timestamp(timestampdir, timestampfile)
     char *timestampfile;
 {
     /* If using tty timestamps but we have no tty there is nothing to do. */
-    if (timestampfile && !user_ttypath)
+    if (def_tty_tickets && !user_ttypath)
        return;
 
     if (timestamp_uid != 0)
@@ -528,7 +534,7 @@ timestamp_status(timestampdir, timestampfile, user, flags)
     if (timestampfile && status != TS_ERROR) {
        if (status != TS_MISSING)
            status = TS_NOFILE;                 /* dir there, file missing */
-       if (!user_ttypath)
+       if (def_tty_tickets && !user_ttypath)
            goto done;                          /* no tty, always prompt */
        if (lstat(timestampfile, &sb) == 0) {
            if (!S_ISREG(sb.st_mode)) {