Todd C. Miller
28d6771d24
Add log_format sudoers setting to select sudo or json format logs.
...
Defaults to sudo-format logs.
2020-10-27 15:26:02 -06:00
Todd C. Miller
4fc39cfb0a
Don't warn about log failure more than once.
2020-10-27 06:36:58 -06:00
Todd C. Miller
fdae4bdbbb
Add support for file log line wrapping in libeventlog.
2020-10-26 16:16:46 -06:00
Todd C. Miller
d899fe5936
Use real setters for the eventlog config.
...
This makes it possible to have a base config that the callers can
modify instead of replacing the config wholesale.
2020-10-26 16:10:42 -06:00
Todd C. Miller
39b540ff33
Log the short version of the tty in sudoers-format logs.
...
This is consistent with historical practice.
2020-10-26 16:10:40 -06:00
Todd C. Miller
4416bd5977
Use libeventlog in sudoers instead of doing our own logging.
2020-10-26 16:10:40 -06:00
Todd C. Miller
f1d19f1d6e
Add SLOG_AUDIT flag for log_warningx() to also audit the message.
...
This lets us combine audit_failure() and log_warningx() calls with
the same message.
2020-09-23 08:18:55 -06:00
Todd C. Miller
fd06e588ee
If the command was run in a chroot, add it to the log.
2020-09-02 16:57:55 -06:00
Todd C. Miller
226307591c
Log the runcwd not submitcwd in the sudo-style log file.
...
The log entry should reflect the working directory the command
actually ran in.
2020-09-02 11:23:26 -06:00
Todd C. Miller
961a4afe67
Fix some warnings from pvs-studio
2020-08-12 13:45:09 -06:00
Todd C. Miller
cbad17a994
Move inclusion of compat headers up with the system headers.
...
Now that sudo_dso_public is defined in config.h we don't need sudo_compat.h
before including the compat headers.
2020-08-12 10:07:07 -06:00
Todd C. Miller
fa5d44b8b5
Quiet some clang 10 analyzer warnings.
2020-08-07 14:22:56 -06:00
Todd C. Miller
f047377a07
Add basic support for reject and error audit events to sudoers.
...
This is only used when logging events from plugins other than sudoers,
such as an approval plugin. With this change, if an approval
plugin rejects the command the denial will be logged in the
sudoers log file using the message from the approval plugin.
2020-06-04 14:41:35 -06:00
Todd C. Miller
b519481912
Defer logging of the successful command until approval plugins have run.
...
This adds audit plugin support to the sudoers module, currently
only used for accept events. As a result, the sudoers file is now
initially parsed as an audit plugin.
2020-06-02 09:07:46 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06:00
Todd C. Miller
ac61b5655d
Use EXIT_SUCCESS and EXIT_FAILURE more consistently.
2020-02-08 12:43:00 -07:00
Todd C. Miller
45e589d443
Pass back a failure or error string to the front end.
...
The audit_failure() function now stores the failure string.
This will allow an audit plugin to log the reason if the user's
request is a rejected.
2020-01-30 13:25:36 -07:00
Todd C. Miller
3fddfedb53
Remove MAXSYSLOGTRIES, it is no longer used.
2020-01-09 13:59:51 -07:00
Todd C. Miller
58d50f44cd
Support systems that have nl_langinfo(3) but not the CODESET define.
...
Fixes compilation on old NetBSD versions.
2019-12-25 11:14:18 -07:00
Todd C. Miller
486ee2b71f
debug_decl and debug_decl_vars now require a semicolon at the end.
2019-12-22 08:48:16 -07:00
Todd C. Miller
356287557f
Use dup3() instead of dup2().
...
This is less error prone since dup3() returns an error if old == new.
Sudo guarantees that fds 0-2 are already open.
2019-11-02 10:55:50 -06:00
Todd C. Miller
352212c7bf
Open all pipes using pipe2() with O_CLOEXEC.
...
We no longer depend on calling closefrom() before exec.
2019-11-02 10:52:34 -06:00
Todd C. Miller
cf6c60c102
Add log_allowed and log_denied sudoers flags, defaulting to true.
2019-10-17 13:43:04 -06:00
Todd C. Miller
9d8f374397
Add ssizeof macro that returns ssize_t.
...
We can use this instead of casting the result of size_t to int.
Also change checks for snprintf() returning <=0 to <0.
2019-06-25 09:45:10 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
aa0146d68d
Keep debug fds open in send_mail() to aid in debugging.
...
Adds closefrom_nodebug() which acts like closefrom(3) but doesn't
close debug fds for use by send_mail().
Also moves the code to exec the mailer to its own function.
2019-04-20 17:28:45 -06:00
Todd C. Miller
985600e7f0
Minor snprintf() usage tweaks:
...
1) don't assume snprintf() returns -1 on error, check for <0
2) when comparing return value of sizeof(foo), cast the sizeof, not the len
3) cast return value to void in cases where snprintf cannot fail
2019-01-20 07:49:48 -07:00
Todd C. Miller
cdd5bb32eb
Add sudo_gai_fatal, sudo_gai_vfatal, sudo_gai_vwarn, sudo_gai_warn
...
and gai_log_warning that use gai_strerror() instead of strerror().
2018-11-05 09:08:05 -07:00
Todd C. Miller
6c3d20cb41
Convert PVS-Studio comment to ANSI C.
2018-10-26 08:39:09 -06:00
Todd C. Miller
64e5d34c57
Add comments in .c files so PVS-Studio will check them.
2018-10-21 08:46:05 -06:00
Todd C. Miller
5f61f2c0f4
Remove special handling of the USERNAME environment variable. It
...
used to be set on old versions of Fedora but that hasn't been the
case for some time. It's worth noting that ssh doesn't set USERNAME
either.
2018-09-24 05:30:03 -06:00
Todd C. Miller
f2fdda1aa7
Silence a clang analyzer false positive.
2017-12-22 13:27:08 -07:00
Todd C. Miller
1350a30737
Add authfail_message sudoers option to allow the user to override
...
the default message of %d incorrect password attempt(s).
2017-12-11 12:43:58 -07:00
Todd C. Miller
b16912da1d
Don't include syslog.h from logging.h, just include it in the two
...
.c files it is actually needed.
2017-12-08 15:00:41 -07:00
Todd C. Miller
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
d129f306ea
Add syslog_pid sudoers option to log sudo's process ID when logging
...
via syslog. This is disabled by default to match historic behavior.
2017-07-20 16:33:12 -06:00
Todd C. Miller
414b28dc45
move va_start() in mysyslog()
2017-01-13 16:30:08 -07:00
Todd C. Miller
00b6be9dfa
Allow syslog priority to be negated or set to "none" to disable
...
logging successes or failures.
2016-11-30 16:26:10 -07:00
Todd C. Miller
8133cdfdf6
Use sys/stat.h defines instead of bare octal values.
2016-11-07 13:36:05 -07:00
Todd C. Miller
7c56179c7d
Use "double quotes" in messages instead of a combination of the
...
accent (grave) mark and apostrophe.
2016-11-02 17:10:17 -06:00
Todd C. Miller
fc1b4155d7
Replace bare ";" in the body of for() loops with "continue;" for
...
improved readability.
2016-10-26 10:42:28 -06:00
Todd C. Miller
19c96da44d
add vsyslog() for systems without it.
2016-10-19 11:32:36 -06:00
Todd C. Miller
c18ff022e0
Use vsyslog() if available.
2016-10-18 17:00:53 -06:00
Todd C. Miller
44c2679f83
Add syslog_maxlen to control the max size of syslog messages.
2016-10-18 15:51:47 -06:00
Todd C. Miller
3f022419ae
Be consistent with the naming of the variable used to store the
...
function return value. Previously, some code used "rval", some
used "ret". This standardizes on "ret" and uses "rc" for temporary
return codes.
2016-09-08 16:38:08 -06:00
Todd C. Miller
d8a65715d6
Avoid duplicate warnings when we cannot write to the log file.
...
Also send the warning in mail if possible.
2016-08-17 14:51:20 -06:00
Todd C. Miller
9ccd260842
Make sure we print an error message to stderr (and not just send
...
mail) if do_logfile() fails. Bug #751
2016-08-15 07:25:18 -06:00
Todd C. Miller
23d288563e
Eliminate use of setpwent()/endpwent() and setgrent()/endgrent().
...
Sudo never iterates over the passwd or group file.
Rename sudo_set{pw,gr}ent() -> sudo_mk{pw,gr}cache() and
use sudo_free{pw,gr}cache() instead of sudo_end{pw,gr}ent().
2016-05-11 07:06:45 -06:00
Todd C. Miller
7b302e09ae
Check return value of restore_perms() in vlog_warning().
...
Coverity CID 104079.
2016-05-06 09:26:45 -06:00