summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <Todd.Miller@courtesan.com>2010-06-29 10:55:00 -0400
committerTodd C. Miller <Todd.Miller@courtesan.com>2010-06-29 10:55:00 -0400
commit92b87e85aa801d5e6688dc82f804476728911c62 (patch)
tree6b3321cb1da7f55f64ef909b23828b76bf40af16
parent66896178335277747f63619802754492cedf3ad2 (diff)
downloadsudo-92b87e85aa801d5e6688dc82f804476728911c62.tar.gz
Back out unrelated bits from 6704e80258e0
-rw-r--r--sudo.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/sudo.c b/sudo.c
index 1e2ab922f..a62f1cd96 100644
--- a/sudo.c
+++ b/sudo.c
@@ -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");