Rename log_warning flags and only send mail if SLOG_SEND_MAIL is
set instead of mailing by default like we used to.
This commit is contained in:
@@ -155,8 +155,10 @@ sudoers_policy_init(void *info, char * const envp[])
|
||||
TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) {
|
||||
if (nss->open(nss) == 0 && nss->parse(nss) == 0) {
|
||||
sources++;
|
||||
if (nss->setdefs(nss) != 0)
|
||||
log_warningx(NO_STDERR, N_("problem with defaults entries"));
|
||||
if (nss->setdefs(nss) != 0) {
|
||||
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
||||
N_("problem with defaults entries"));
|
||||
}
|
||||
} else {
|
||||
TAILQ_REMOVE(snl, nss, entries);
|
||||
}
|
||||
@@ -194,8 +196,10 @@ sudoers_policy_init(void *info, char * const envp[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!update_defaults(SETDEF_RUNAS))
|
||||
log_warningx(NO_STDERR, N_("problem with defaults entries"));
|
||||
if (!update_defaults(SETDEF_RUNAS)) {
|
||||
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
||||
N_("problem with defaults entries"));
|
||||
}
|
||||
|
||||
if (def_fqdn)
|
||||
set_fqdn(); /* deferred until after sudoers is parsed */
|
||||
@@ -335,8 +339,8 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
|
||||
timestamp_uid = pw->pw_uid;
|
||||
sudo_pw_delref(pw);
|
||||
} else {
|
||||
log_warningx(0, N_("timestamp owner (%s): No such user"),
|
||||
def_timestampowner);
|
||||
log_warningx(SLOG_SEND_MAIL,
|
||||
N_("timestamp owner (%s): No such user"), def_timestampowner);
|
||||
timestamp_uid = ROOT_UID;
|
||||
}
|
||||
}
|
||||
@@ -625,7 +629,8 @@ init_vars(char * const envp[])
|
||||
|
||||
/* It is now safe to use log_warningx() and set_perms() */
|
||||
if (unknown_user) {
|
||||
log_warningx(0, N_("unknown uid: %u"), (unsigned int) user_uid);
|
||||
log_warningx(SLOG_SEND_MAIL, N_("unknown uid: %u"),
|
||||
(unsigned int) user_uid);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
debug_return_bool(true);
|
||||
@@ -671,7 +676,7 @@ set_cmnd(void)
|
||||
if (rval == NOT_FOUND_ERROR) {
|
||||
if (errno == ENAMETOOLONG)
|
||||
audit_failure(NewArgv, N_("command too long"));
|
||||
log_warning(NO_MAIL, "%s", NewArgv[0]);
|
||||
log_warning(0, "%s", NewArgv[0]);
|
||||
debug_return_int(rval);
|
||||
}
|
||||
}
|
||||
@@ -720,8 +725,10 @@ set_cmnd(void)
|
||||
else
|
||||
user_base = user_cmnd;
|
||||
|
||||
if (!update_defaults(SETDEF_CMND))
|
||||
log_warningx(NO_STDERR, N_("problem with defaults entries"));
|
||||
if (!update_defaults(SETDEF_CMND)) {
|
||||
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
||||
N_("problem with defaults entries"));
|
||||
}
|
||||
|
||||
debug_return_int(rval);
|
||||
}
|
||||
@@ -758,10 +765,11 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
|
||||
* the user with a reasonable error message (unlike the lexer).
|
||||
*/
|
||||
if ((fp = fopen(sudoers, "r")) == NULL) {
|
||||
log_warning(0, N_("unable to open %s"), sudoers);
|
||||
log_warning(SLOG_SEND_MAIL, N_("unable to open %s"), sudoers);
|
||||
} else {
|
||||
if (sb.st_size != 0 && fgetc(fp) == EOF) {
|
||||
log_warning(0, N_("unable to read %s"), sudoers);
|
||||
log_warning(SLOG_SEND_MAIL,
|
||||
N_("unable to read %s"), sudoers);
|
||||
fclose(fp);
|
||||
fp = NULL;
|
||||
} else {
|
||||
@@ -772,21 +780,24 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
|
||||
}
|
||||
break;
|
||||
case SUDO_PATH_MISSING:
|
||||
log_warning(0, N_("unable to stat %s"), sudoers);
|
||||
log_warning(SLOG_SEND_MAIL, N_("unable to stat %s"), sudoers);
|
||||
break;
|
||||
case SUDO_PATH_BAD_TYPE:
|
||||
log_warningx(0, N_("%s is not a regular file"), sudoers);
|
||||
log_warningx(SLOG_SEND_MAIL,
|
||||
N_("%s is not a regular file"), sudoers);
|
||||
break;
|
||||
case SUDO_PATH_WRONG_OWNER:
|
||||
log_warningx(0, N_("%s is owned by uid %u, should be %u"),
|
||||
sudoers, (unsigned int) sb.st_uid, (unsigned int) sudoers_uid);
|
||||
log_warningx(SLOG_SEND_MAIL,
|
||||
N_("%s is owned by uid %u, should be %u"), sudoers,
|
||||
(unsigned int) sb.st_uid, (unsigned int) sudoers_uid);
|
||||
break;
|
||||
case SUDO_PATH_WORLD_WRITABLE:
|
||||
log_warningx(0, N_("%s is world writable"), sudoers);
|
||||
log_warningx(SLOG_SEND_MAIL, N_("%s is world writable"), sudoers);
|
||||
break;
|
||||
case SUDO_PATH_GROUP_WRITABLE:
|
||||
log_warningx(0, N_("%s is owned by gid %u, should be %u"),
|
||||
sudoers, (unsigned int) sb.st_gid, (unsigned int) sudoers_gid);
|
||||
log_warningx(SLOG_SEND_MAIL,
|
||||
N_("%s is owned by gid %u, should be %u"), sudoers,
|
||||
(unsigned int) sb.st_gid, (unsigned int) sudoers_gid);
|
||||
break;
|
||||
default:
|
||||
/* NOTREACHED */
|
||||
@@ -806,7 +817,7 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
|
||||
static bool
|
||||
set_loginclass(struct passwd *pw)
|
||||
{
|
||||
const int errflags = NO_MAIL|MSG_ONLY;
|
||||
const int errflags = SLOG_RAW_MSG;
|
||||
login_cap_t *lc;
|
||||
bool rval = true;
|
||||
debug_decl(set_loginclass, SUDO_DEBUG_PLUGIN)
|
||||
@@ -871,7 +882,8 @@ set_fqdn(void)
|
||||
hint.ai_family = PF_UNSPEC;
|
||||
hint.ai_flags = AI_FQDN;
|
||||
if (getaddrinfo(user_host, NULL, &hint, &res0) != 0) {
|
||||
log_warningx(MSG_ONLY, N_("unable to resolve host %s"), user_host);
|
||||
log_warningx(SLOG_SEND_MAIL|SLOG_RAW_MSG,
|
||||
N_("unable to resolve host %s"), user_host);
|
||||
} else {
|
||||
if (user_shost != user_host)
|
||||
efree(user_shost);
|
||||
@@ -907,7 +919,7 @@ set_runaspw(const char *user, bool quiet)
|
||||
if (pw == NULL) {
|
||||
if ((pw = sudo_getpwnam(user)) == NULL) {
|
||||
if (!quiet)
|
||||
log_warningx(NO_MAIL|MSG_ONLY, N_("unknown user: %s"), user);
|
||||
log_warningx(SLOG_RAW_MSG, N_("unknown user: %s"), user);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
@@ -938,7 +950,7 @@ set_runasgr(const char *group, bool quiet)
|
||||
if (gr == NULL) {
|
||||
if ((gr = sudo_getgrnam(group)) == NULL) {
|
||||
if (!quiet)
|
||||
log_warningx(NO_MAIL|MSG_ONLY, N_("unknown group: %s"), group);
|
||||
log_warningx(SLOG_RAW_MSG, N_("unknown group: %s"), group);
|
||||
debug_return_bool(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user