]> granicus.if.org Git - sudo/commitdiff
added tzset() to load_globals
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 14 Jul 1994 21:43:58 +0000 (21:43 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 14 Jul 1994 21:43:58 +0000 (21:43 +0000)
added epasswd (encrypted password) global
made user dynamically allocated

sudo.c

diff --git a/sudo.c b/sudo.c
index 3f7b7ba4c9de2ba4d44b1f81148b3209fab3c6b7..4e4469798ca0a1b9edc3da7e3b2ebf2873a2b9ac 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -106,8 +106,9 @@ static void clean_env               __P((char **));
 int Argc;
 char **Argv;
 char *cmnd;
+char *user;
+char *epasswd;
 char host[MAXHOSTNAMELEN + 1];
-char user[9];
 char cwd[MAXPATHLEN + 1];
 uid_t uid = -2;
 int validate_only = 0;
@@ -211,6 +212,29 @@ static void load_globals()
 
     uid = getuid();            /* we need to tuck this away for safe keeping */
 
+#ifdef HAVE_TZSET
+    (void) tzset();            /* set the timezone if applicable */
+#endif /* HAVE_TZSET */
+
+    /*
+     * loading the user & epasswd global variable from the passwd file
+     * (must be done as root to get real passwd on some systems)
+     */
+    if ((pw_ent = getpwuid(uid)) == NULL) {
+       (void) sprintf(user, "%u", uid);
+       log_error(GLOBAL_NO_PW_ENT);
+       inform_user(GLOBAL_NO_PW_ENT);
+       exit(1);
+    }
+
+    user = strdup(pw_ent -> pw_name);
+    epasswd = strdup(pw_ent -> pw_passwd);
+    if (user == NULL || epasswd == NULL) {
+       perror("malloc");
+       (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
+       exit(1);
+    }
+
     /*
      * We only want to be root when we absolutely need it.
      * This will effectively do setreuid(0, uid) but for portability...
@@ -237,18 +261,6 @@ static void load_globals()
     }
 #endif
 
-    /*
-     * loading the user global variable from the passwd file
-     */
-    if ((pw_ent = getpwuid(uid)) == NULL) {
-       (void) sprintf(user, "%u", uid);
-       log_error(GLOBAL_NO_PW_ENT);
-       inform_user(GLOBAL_NO_PW_ENT);
-       exit(1);
-    }
-    strncpy(user, pw_ent -> pw_name, 8)[8] = '\0';
-
-
     /*
      * load the host global variable from gethostname()
      * and use gethostbyname() if we want it to be fully qualified.
@@ -327,7 +339,6 @@ static void usage()
 static void clean_env(envp)
     char **envp;
 {
-
     /*
      * omit all LD_* environmental vars
      */
@@ -414,6 +425,8 @@ void be_full_user()
     }
 }
 
+
+
 /**********************************************************************
  *
  * rmenv()