From: Todd C. Miller Date: Thu, 14 Jul 1994 21:43:58 +0000 (+0000) Subject: added tzset() to load_globals X-Git-Tag: SUDO_1_3_1~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7bf4f9fe0458f1b20beaf5f0d2678d03d031487;p=sudo added tzset() to load_globals added epasswd (encrypted password) global made user dynamically allocated --- diff --git a/sudo.c b/sudo.c index 3f7b7ba4c..4e4469798 100644 --- 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()