2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 22:35:10 +00:00

Add log_warningx

This commit is contained in:
Todd C. Miller
2014-05-02 16:40:30 -06:00
parent 7f0b9eca03
commit 954a3e77b1
13 changed files with 91 additions and 75 deletions

View File

@@ -182,8 +182,10 @@ found_it:
if ((size_t)nwritten == sizeof(struct timestamp_entry))
debug_return_bool(true);
log_warning(nwritten == -1 ? USE_ERRNO : 0,
N_("unable to write to %s"), timestamp_file);
if (nwritten == -1)
log_warning(0, N_("unable to write to %s"), timestamp_file);
else
log_warningx(0, N_("unable to write to %s"), timestamp_file);
/* Truncate on partial write to be safe. */
if (nwritten > 0 && old_eof != (off_t)-1) {
@@ -310,7 +312,7 @@ build_timestamp(struct passwd *pw)
len = snprintf(timestamp_file, sizeof(timestamp_file), "%s/%s",
def_timestampdir, user_name);
if (len <= 0 || (size_t)len >= sizeof(timestamp_file)) {
log_warning(0, N_("timestamp path too long: %s/%s"),
log_warningx(0, N_("timestamp path too long: %s/%s"),
def_timestampdir, user_name);
len = -1;
}
@@ -350,7 +352,7 @@ update_timestamp(struct passwd *pw)
if (uid_changed)
(void) restore_perms();
if (fd == -1) {
log_warning(USE_ERRNO, N_("unable to open %s"), timestamp_file);
log_warning(0, N_("unable to open %s"), timestamp_file);
goto done;
}
@@ -490,7 +492,7 @@ timestamp_status(struct passwd *pw)
#ifdef CLOCK_MONOTONIC
/* A monotonic clock should never run backwards. */
if (diff.tv_sec < 0) {
log_warning(0, N_("ignoring time stamp from the future"));
log_warningx(0, N_("ignoring time stamp from the future"));
status = TS_OLD;
SET(entry.flags, TS_DISABLED);
ts_update_record(fd, &entry, timestamp_hint);
@@ -501,7 +503,7 @@ timestamp_status(struct passwd *pw)
timeout.tv_sec *= 2;
if (sudo_timespeccmp(&diff, &timeout, >)) {
time_t tv_sec = (time_t)entry.ts.tv_sec;
log_warning(0,
log_warningx(0,
N_("time stamp too far in the future: %20.20s"),
4 + ctime(&tv_sec));
status = TS_OLD;
@@ -605,7 +607,7 @@ already_lectured(int unused)
if (len > 0 && (size_t)len < sizeof(status_file)) {
debug_return_bool(stat(status_file, &sb) == 0);
}
log_warning(0, N_("lecture status path too long: %s/%s"),
log_warningx(0, N_("lecture status path too long: %s/%s"),
def_lecture_status_dir, user_name);
}
debug_return_bool(false);
@@ -626,7 +628,7 @@ set_lectured(void)
len = snprintf(lecture_status, sizeof(lecture_status), "%s/%s",
def_lecture_status_dir, user_name);
if (len <= 0 || (size_t)len >= sizeof(lecture_status)) {
log_warning(0, N_("lecture status path too long: %s/%s"),
log_warningx(0, N_("lecture status path too long: %s/%s"),
def_lecture_status_dir, user_name);
goto done;
}