2 * Copyright (c) 1999-2005, 2009-2013
3 * Todd C. Miller <Todd.Miller@courtesan.com>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #ifndef _SUDOERS_LOGGING_H
19 #define _SUDOERS_LOGGING_H
29 #define SLOG_SYSLOG 0x01
30 #define SLOG_FILE 0x02
31 #define SLOG_BOTH 0x03
34 * Values for sudoers_setlocale()
36 #define SUDOERS_LOCALE_USER 0
37 #define SUDOERS_LOCALE_SUDOERS 1
39 /* Flags for log_warning()/log_fatal() */
41 #define USE_ERRNO 0x02
43 #define NO_STDERR 0x08
47 * Maximum number of characters to log per entry. The syslogger
48 * will log this much, after that, it truncates the log line.
49 * We need this here to make sure that we continue with another
50 * syslog(3) call if the internal buffer is more than 1023 characters.
53 # define MAXSYSLOGLEN 960
57 * Indentation level for file-based logs when word wrap is enabled.
59 #define LOG_INDENT " "
61 bool sudoers_setlocale(int newlocale, int *prevlocale);
62 int sudoers_getlocale(void);
63 void audit_success(char *exec_args[]);
64 void audit_failure(char *exec_args[], char const *const fmt, ...);
65 void log_allowed(int status);
66 void log_auth_failure(int status, int tries);
67 void log_denial(int status, bool inform_user);
68 void log_failure(int status, int flags);
69 void log_warning(int flags, const char *fmt, ...) __printflike(2, 3);
70 void log_fatal(int flags, const char *fmt, ...) __printflike(2, 3) __attribute__((__noreturn__));
71 void sudoers_initlocale(const char *ulocale, const char *slocale);
72 void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
74 #endif /* _SUDOERS_LOGGING_H */