]> granicus.if.org Git - sudo/commitdiff
Go back to using a callback for runas_default to keep runas_pw in
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 9 Aug 2011 18:56:05 +0000 (14:56 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 9 Aug 2011 18:56:05 +0000 (14:56 -0400)
sync.  This is needed to make per-entry runas_default settings work
with LDAP-based sudoers.  Instead of declaring it a callback in
def_data.in, sudo pokes sudo_defs_table[] which is a bit naughty,
but avoids requiring stub functions in visudo and testsudoers.

--HG--
branch : 1.7

defaults.h
sudo.c

index eb2188a149fa8720f8a1920e479b2e7722937760..837d453c9aca267b41ef07c6825e750622797622 100644 (file)
@@ -48,7 +48,7 @@ struct sudo_defs_types {
     int type;
     char *desc;
     struct def_values *values;
-    int (*callback) __P((char *));
+    int (*callback) __P((const char *));
     union {
        int flag;
        int ival;
diff --git a/sudo.c b/sudo.c
index 0dc2e78ad276cd906e2b9a6a94860df20ee6cf56..f1c62417cfdfe3fa2d7af6ca8468a9feff9cc024 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -114,8 +114,8 @@ static void init_vars                       __P((char **));
 static int set_cmnd                    __P((int));
 static void initial_setup              __P((void));
 static void set_loginclass             __P((struct passwd *));
-static void set_runasgr                        __P((char *));
-static void set_runaspw                        __P((char *));
+static int set_runaspw                 __P((const char *));
+static int set_runasgr                 __P((const char *));
 static void show_version               __P((void));
 static void create_admin_success_flag  __P((void));
 extern int sudo_edit                   __P((int, char **, char **));
@@ -753,6 +753,9 @@ init_vars(envp)
        NewArgc++;
        NewArgv[0] = user_cmnd;
     }
+
+    /* Set runas callback. */
+    sudo_defs_table[I_RUNAS_DEFAULT].callback = set_runaspw;
 }
 
 /*
@@ -820,9 +823,6 @@ set_cmnd(sudo_mode)
     if (!update_defaults(SETDEF_CMND))
        log_error(NO_STDERR|NO_EXIT, "problem with defaults entries");
 
-    if (!runas_user && !runas_group)
-       set_runaspw(def_runas_default); /* may have been updated above */
-
     return rval;
 }
 
@@ -1210,9 +1210,9 @@ set_fqdn()
  * Get passwd entry for the user we are going to run commands as
  * and store it in runas_pw.  By default, commands run as "root".
  */
-static void
+int
 set_runaspw(user)
-    char *user;
+    const char *user;
 {
     if (runas_pw != NULL)
        pw_delref(runas_pw);
@@ -1225,15 +1225,16 @@ set_runaspw(user)
            log_error(NO_MAIL|MSG_ONLY, "unknown user: %s", user);
        }
     }
+    return TRUE;
 }
 
 /*
  * Get group entry for the group we are going to run commands as
  * and store it in runas_gr.
  */
-static void
+static int
 set_runasgr(group)
-    char *group;
+    const char *group;
 {
     if (runas_gr != NULL)
        gr_delref(runas_gr);
@@ -1244,6 +1245,7 @@ set_runasgr(group)
        if ((runas_gr = sudo_getgrnam(group)) == NULL)
            log_error(NO_MAIL|MSG_ONLY, "unknown group: %s", group);
     }
+    return TRUE;
 }
 
 /*