diff options
author | Todd C. Miller <Todd.Miller@courtesan.com> | 2010-06-29 10:55:00 -0400 |
---|---|---|
committer | Todd C. Miller <Todd.Miller@courtesan.com> | 2010-06-29 10:55:00 -0400 |
commit | 92b87e85aa801d5e6688dc82f804476728911c62 (patch) | |
tree | 6b3321cb1da7f55f64ef909b23828b76bf40af16 | |
parent | 66896178335277747f63619802754492cedf3ad2 (diff) | |
download | sudo-92b87e85aa801d5e6688dc82f804476728911c62.tar.gz |
Back out unrelated bits from 6704e80258e0
-rw-r--r-- | sudo.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -304,9 +304,6 @@ main(argc, argv, envp) if (!update_defaults(SETDEF_RUNAS)) log_error(NO_STDERR|NO_EXIT, "problem with defaults entries"); - if (def_fqdn) - set_fqdn(); /* deferred until after sudoers is parsed */ - /* Set login class if applicable. */ set_loginclass(sudo_user.pw); @@ -628,17 +625,22 @@ 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 ((p = strchr(user_host, '.'))) { - *p = '\0'; - user_shost = estrdup(user_host); - *p = '.'; - } else { + if (def_fqdn) { + /* Defer call to set_fqdn() until log_error() is safe. */ user_shost = user_host; + } else { + if ((p = strchr(user_host, '.'))) { + *p = '\0'; + user_shost = estrdup(user_host); + *p = '.'; + } else { + user_shost = user_host; + } } } @@ -717,6 +719,9 @@ init_vars(sudo_mode, envp) user_ngroups = 0; #endif + if (def_fqdn) + set_fqdn(); /* may call log_error() */ + if (nohostname) log_error(USE_ERRNO|MSG_ONLY, "can't get hostname"); |