From: Todd C. Miller Date: Fri, 18 Jun 2010 21:21:10 +0000 (-0400) Subject: Do not call set_fqdn() until sudoers parses (where is gets run as a callback). X-Git-Tag: SUDO_1_7_3~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8fe84ffa637a8f0c0b871aa0e872ccc1b8bb5e1;p=sudo Do not call set_fqdn() until sudoers parses (where is gets run as a callback). Otherwise, if sudo is built --with-fqdn the fqdn will be set even if !fqdn is set in sudoers. --HG-- branch : 1.7 --- diff --git a/sudo.c b/sudo.c index b384d567c..e1bc6c3bd 100644 --- a/sudo.c +++ b/sudo.c @@ -576,22 +576,17 @@ init_vars(sudo_mode, envp) * "shost" is the unqualified form of the hostname. */ nohostname = gethostname(thost, sizeof(thost)); - if (nohostname) + if (nohostname) { user_host = user_shost = "localhost"; - else { + } else { thost[sizeof(thost) - 1] = '\0'; user_host = estrdup(thost); - if (def_fqdn) { - /* Defer call to set_fqdn() until log_error() is safe. */ - user_shost = user_host; + if ((p = strchr(user_host, '.'))) { + *p = '\0'; + user_shost = estrdup(user_host); + *p = '.'; } else { - if ((p = strchr(user_host, '.'))) { - *p = '\0'; - user_shost = estrdup(user_host); - *p = '.'; - } else { - user_shost = user_host; - } + user_shost = user_host; } } @@ -672,9 +667,6 @@ init_vars(sudo_mode, envp) } #endif - if (def_fqdn) - set_fqdn(); /* may call log_error() */ - if (nohostname) log_error(USE_ERRNO|MSG_ONLY, "can't get hostname");