]> granicus.if.org Git - sudo/commitdiff
log_{fatal,warning} now logs to the debug file itself.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 16 Nov 2013 16:21:43 +0000 (09:21 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 16 Nov 2013 16:21:43 +0000 (09:21 -0700)
log_{fatal,warning} now calls warningx2() after setting the
locale itself instead of using the wrapper macros.
This removes the only use of warningx(ngettext(...)).

plugins/sudoers/logging.c

index 4cd4398f5ccf09a98f0bd91f8802b4edda1e1b38..dd4011a5c7db419b958dbf4a97ea0a2abc27a741 100644 (file)
@@ -446,6 +446,15 @@ vlog_warning(int flags, const char *fmt, va_list ap)
        evasprintf(&message, _(fmt), ap);
     }
 
+    /* Log to debug file. */
+    if (USE_ERRNO) {
+       sudo_debug_printf2(NULL, NULL, 0,
+           SUDO_DEBUG_WARN|SUDO_DEBUG_ERRNO|sudo_debug_subsys, "%s", message);
+    } else {
+       sudo_debug_printf2(NULL, NULL, 0,
+           SUDO_DEBUG_WARN|sudo_debug_subsys, "%s", message);
+    }
+
     if (ISSET(flags, MSG_ONLY)) {
        logline = message;
     } else {
@@ -482,16 +491,18 @@ vlog_warning(int flags, const char *fmt, va_list ap)
      * Tell the user (in their locale).
      */
     if (!ISSET(flags, NO_STDERR)) {
+       warning_set_locale();
        if (fmt == INCORRECT_PASSWORD_ATTEMPT) {
            int tries = va_arg(ap2, int);
-           warningx(ngettext("%d incorrect password attempt",
+           warningx2(ngettext("%d incorrect password attempt",
                "%d incorrect password attempts", tries), tries);
        } else {
            if (ISSET(flags, USE_ERRNO))
-               vwarning(fmt, ap2);
+               vwarning2(_(fmt), ap2);
            else
-               vwarningx(fmt, ap2);
+               vwarningx2(_(fmt), ap2);
        }
+       warning_restore_locale();
        va_end(ap2);
     }