* "host" is the (possibly fully-qualified) hostname and
* "shost" is the unqualified form of the hostname.
*/
+ sudo_user.host_fqdn_queried = FALSE;
nohostname = gethostname(thost, sizeof(thost));
if (nohostname)
user_host = user_shost = "localhost";
else {
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;
}
}
/* It is now safe to use log_error() and set_perms() */
- if (def_fqdn)
- set_fqdn(); /* may call log_error() */
-
if (nohostname)
log_error(USE_ERRNO|MSG_ONLY, "can't get hostname");
+ /* We don't query FQDN yet, it might get disabled later. Querying is done
+ * when host matching is executed and def_fqdn still true */
+
set_runaspw(*user_runas); /* may call log_error() */
if (*user_runas[0] == '#' && runas_pw->pw_name && runas_pw->pw_name[0])
*user_runas = estrdup(runas_pw->pw_name);
return(rval);
}
+ /* New default: reset the environment */
+ def_env_reset = TRUE;
while (NewArgc > 0 && NewArgv[0][0] == '-') {
if (NewArgv[0][1] != '\0' && NewArgv[0][2] != '\0')
warnx("please use single character options");
struct hostent *hp;
char *p;
+ if (!def_fqdn || sudo_user.host_fqdn_queried) {
+ /* Only querying just once is good enough */
+ return;
+ }
+
if (!(hp = gethostbyname(user_host))) {
log_error(MSG_ONLY|NO_EXIT,
"unable to lookup %s via gethostbyname()", user_host);
} else {
user_shost = user_host;
}
+ sudo_user.host_fqdn_queried = TRUE;
}
/*