]> granicus.if.org Git - sudo/commitdiff
o Move the call to rebuild_env() until after MODE_RESET_HOME is set.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Jan 2002 01:53:02 +0000 (01:53 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Jan 2002 01:53:02 +0000 (01:53 +0000)
  Otherwise, the set_home option has no effect.

o Fix use of freed memory when the "fqdn" flag is set.  This was
  introduced by the fix for the "segv when gethostbynam() fails" bug.
  Also, we no longer call set_fqdn() if the "fqdn" flag is not set so
  there is no need to check the "fqdn" flag in set_fqdn() itself.

sudo.c

diff --git a/sudo.c b/sudo.c
index 6313aed9b8fec02b64467d3a5ff1c8333090ba48..bb4abbf9c4abb2394fce934b603b6bf23b858dda 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -287,9 +287,6 @@ main(argc, argv, envp)
            log_error(NO_MAIL|MSG_ONLY, "no passwd entry for %s!", *user_runas);
     }
 
-    /* Build up custom environment that avoids any nasty bits. */
-    new_environ = rebuild_env(sudo_mode, envp);
-
     /* This goes after the sudoers parse since we honor sudoers options. */
     if (sudo_mode == MODE_KILL || sudo_mode == MODE_INVALIDATE) {
        remove_timestamp((sudo_mode == MODE_KILL));
@@ -335,6 +332,9 @@ main(argc, argv, envp)
     if (!(validated & FLAG_NOPASS))
        check_user();
 
+    /* Build up custom environment that avoids any nasty bits. */
+    new_environ = rebuild_env(sudo_mode, envp);
+
     if (validated & VALIDATE_OK) {
        /* Finally tell the user if the command did not exist. */
        if (cmnd_status == NOT_FOUND_DOT) {
@@ -950,17 +950,15 @@ set_fqdn()
     struct hostent *hp;
     char *p;
 
-    if (def_flag(I_FQDN)) {
-       if (!(hp = gethostbyname(user_host))) {
-           log_error(MSG_ONLY|NO_EXIT,
-               "unable to lookup %s via gethostbyname()", user_host);
-       } else {
-           free(user_host);
-           user_host = estrdup(hp->h_name);
-       }
+    if (!(hp = gethostbyname(user_host))) {
+       log_error(MSG_ONLY|NO_EXIT,
+           "unable to lookup %s via gethostbyname()", user_host);
+    } else {
+       if (user_shost != user_host)
+           free(user_shost);
+       free(user_host);
+       user_host = estrdup(hp->h_name);
     }
-    if (user_shost != user_host)
-       free(user_shost);
     if ((p = strchr(user_host, '.'))) {
        *p = '\0';
        user_shost = estrdup(user_host);