]> granicus.if.org Git - sudo/commitdiff
setauthdb() only sets the "old" registry if it was set by a previous
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 20 Jul 2010 16:40:47 +0000 (12:40 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 20 Jul 2010 16:40:47 +0000 (12:40 -0400)
call to setauthdb().  To restore the original value, passing NULL
(or an empty string) to setauthdb() is sufficient.

--HG--
branch : 1.7

aix.c

diff --git a/aix.c b/aix.c
index 4b8810f6154b814cbe36f4f0def831d2073a7db5..5735ec97a0eb2f35b7b4e9c522b869cd6282d457 100644 (file)
--- a/aix.c
+++ b/aix.c
@@ -55,10 +55,6 @@ struct aix_limit {
     int factor;
 };
 
-#ifdef HAVE_SETAUTHDB
-static char saved_registry[16]; /* 15 chars plus NUL as per setauthdb(3) */
-#endif
-
 static struct aix_limit aix_limits[] = {
     { RLIMIT_FSIZE, S_UFSIZE, S_UFSIZE_HARD, 512 },
     { RLIMIT_CPU, S_UCPU, S_UCPU_HARD, 1 },
@@ -151,7 +147,7 @@ aix_setauthdb(user)
        if (setuserdb(S_READ) != 0)
            error(1, "unable to open userdb");
        if (getuserattr(user, S_REGISTRY, &registry, SEC_CHAR) == 0) {
-           if (setauthdb(registry, saved_registry) != 0)
+           if (setauthdb(registry, NULL) != 0)
                error(1, "unable to switch to registry \"%s\" for %s",
                    registry, user);
        }
@@ -165,11 +161,8 @@ aix_setauthdb(user)
 void
 aix_restoreauthdb()
 {
-    if (saved_registry[0]) {
-       if (setauthdb(saved_registry, NULL) != 0)
-           error(1, "unable to restore registry \"%s\"", saved_registry);
-       saved_registry[0] = '\0';
-    }
+    if (setauthdb(NULL, NULL) != 0)
+       error(1, "unable to restore registry");
 }
 #endif