create_admin_success_flag() should use restore_perms() rather than
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 23 Nov 2010 12:34:22 +0000 (07:34 -0500)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 23 Nov 2010 12:34:22 +0000 (07:34 -0500)
set_perms() to restore the uid.

plugins/sudoers/sudoers.c

index af86e776b16fb4acec090fa1cbd91898a09fe717..9e285e33e3b156f1c897974cff0dbf630467d5a1 100644 (file)
@@ -1349,14 +1349,11 @@ create_admin_success_flag(void)
 
     /* Create admin flag file if it doesn't already exist. */
     set_perms(PERM_USER);
-    if (stat(flagfile, &statbuf) == 0) {
-       set_perms(PERM_ROOT);
-       return;
+    if (stat(flagfile, &statbuf) != 0) {
+       fd = open(flagfile, O_CREAT|O_WRONLY|O_EXCL, 0644);
+       close(fd);
     }
-
-    fd = open(flagfile, O_CREAT|O_WRONLY|O_EXCL, 0644);
-    close(fd);
-    set_perms(PERM_ROOT);
+    restore_perms();
 }
 #else /* !USE_ADMIN_FLAG */
 static void