mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-03 15:55:40 +00:00
Don't send email about an unresolvable host name if fqdn is
enabled and the user specified the run host via the -h flag.
This commit is contained in:
@@ -1100,8 +1100,9 @@ cb_fqdn(const union sudo_defs_val *sd_un)
|
|||||||
/* Next resolve user_runhost, setting user_runhost and user_srunhost. */
|
/* Next resolve user_runhost, setting user_runhost and user_srunhost. */
|
||||||
lhost = shost = NULL;
|
lhost = shost = NULL;
|
||||||
if (remote) {
|
if (remote) {
|
||||||
/* Failure checked below. */
|
if (!resolve_host(user_runhost, &lhost, &shost)) {
|
||||||
(void)resolve_host(user_runhost, &lhost, &shost);
|
sudo_warnx(U_("unable to resolve host %s"), user_runhost);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Not remote, just use user_host. */
|
/* Not remote, just use user_host. */
|
||||||
if ((lhost = strdup(user_host)) != NULL) {
|
if ((lhost = strdup(user_host)) != NULL) {
|
||||||
@@ -1110,19 +1111,21 @@ cb_fqdn(const union sudo_defs_val *sd_un)
|
|||||||
else
|
else
|
||||||
shost = lhost;
|
shost = lhost;
|
||||||
}
|
}
|
||||||
|
if (lhost == NULL || shost == NULL) {
|
||||||
|
free(lhost);
|
||||||
|
if (lhost != shost)
|
||||||
|
free(shost);
|
||||||
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
|
debug_return_bool(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lhost == NULL || shost == NULL) {
|
if (lhost != NULL && shost != NULL) {
|
||||||
free(lhost);
|
if (user_srunhost != user_runhost)
|
||||||
free(shost);
|
free(user_srunhost);
|
||||||
log_warning(SLOG_SEND_MAIL|SLOG_RAW_MSG,
|
free(user_runhost);
|
||||||
N_("unable to resolve host %s"), user_runhost);
|
user_runhost = lhost;
|
||||||
debug_return_bool(false);
|
user_srunhost = shost;
|
||||||
}
|
}
|
||||||
if (user_srunhost != user_runhost)
|
|
||||||
free(user_srunhost);
|
|
||||||
free(user_runhost);
|
|
||||||
user_runhost = lhost;
|
|
||||||
user_srunhost = shost;
|
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
"host %s, shost %s, runhost %s, srunhost %s",
|
"host %s, shost %s, runhost %s, srunhost %s",
|
||||||
|
Reference in New Issue
Block a user