Commit Graph

12444 Commits

Author SHA1 Message Date
Todd C. Miller
b965d222d8 sudo_ldap_netgroup_match_str: "-" in a netgroup can never match.
We already check for a NULL value above so "str == NULL" is always
false.  Found by PVS-Studio.
2023-03-15 10:06:04 -06:00
Todd C. Miller
027b42d5a6 Fix static compilation. 2023-03-14 13:27:45 -06:00
Todd C. Miller
33cb885cf6 Replace eventlog_json.h with parse_json.h. 2023-03-14 13:09:43 -06:00
Todd C. Miller
1b3991b717 Add tests for JSON and sudo-style log output. 2023-03-13 19:42:54 -06:00
Todd C. Miller
0f46ffa9f1 Add support for parsing all fields of struct eventlog. 2023-03-14 11:24:02 -06:00
Todd C. Miller
d8e6396c55 Declare domain even if the system lacks innetgr().
Fixes a build error on musl-based systems like Alpine.
2023-03-13 15:21:38 -06:00
Todd C. Miller
918af413f3 Add missing definition of $(SED). 2023-03-13 15:03:58 -06:00
Todd C. Miller
86ab362fd4 Move JSON log parsing from libsudo_iolog.la to libsudo_eventlog.la
It will be used in the upcoming log output tests.
2023-03-13 15:02:03 -06:00
Todd C. Miller
12648b4e0a Add missing " ; " separator between environment variables and command.
This is a regression introduced in sudo 1.9.13.
GitHub issue #254.
2023-03-13 08:04:32 -06:00
Todd C. Miller
24f04c8cb3 Add example to verify support for searching by nisNetgroupTriple. 2023-03-12 12:04:47 -06:00
Todd C. Miller
34933ef9d0 Remove unused sudoers_gc_init() function. 2023-03-11 08:06:54 -07:00
Todd C. Miller
916d8b47c1 Sudo now does its own netgroup lookups if NETGROUP_BASE is set.
Previously, it only performed netgroup queries to determine the
list of netgroups a user was a member of.
2023-03-10 19:19:23 -07:00
Todd C. Miller
c76ac1cab3 sudoers_cleanup: free cached environment before running g/c.
Avoids a double free in fuzz_policy.
2023-03-10 15:23:48 -07:00
Todd C. Miller
cd5cd45336 sudoers_cleanup: run the garbage collector at the end 2023-03-10 15:03:44 -07:00
Todd C. Miller
c09aabecdc Plugin a memory leak in intercept mode. 2023-03-10 15:00:20 -07:00
Todd C. Miller
d5a7844423 Sync non-intercept version of intercept_cleanup() declaration. 2023-03-10 14:01:07 -07:00
Todd C. Miller
33c385a78e Plug memory leak if ldap_get_option() fails with LDAP_NO_MEMORY. 2023-03-10 13:45:53 -07:00
Todd C. Miller
c61306e583 Plug a memory leak with ptrace-based intercept. 2023-03-10 13:32:56 -07:00
Todd C. Miller
31dad6b179 Plug memory leak when log_subcmds is enabled. 2023-03-10 13:18:02 -07:00
Todd C. Miller
cb7b1dd89c Pass closure to callback, not the callback pointer itself. 2023-03-10 11:19:37 -07:00
Todd C. Miller
fc253048f5 Add LDAP-specific innetgr() implementation.
Wheh netgroup_base is set we now do out own netgroup lookups using
LDAP.  Previously, LDAP was queried directly to get a list of the
netgroups the user belongs to but other netgroups queries went
through innetgr(3).  This makes it possible to use netgroups
in LDAP sudoers on systems that don't have an innetgr() function.
GitHub issue #251.
2023-03-10 10:05:33 -07:00
Todd C. Miller
554df8d934 Move some functions from ldap.c to ldap_util.c.
These will be used by the LDAP innetgr() implementation.
2023-03-10 10:02:36 -07:00
Todd C. Miller
0aad96bba1 Add per-source innetgr function pointer and use it in netgr_matches().
This will be used to implement LDAP-specific netgroup lookups when
netgroup_base is set in ldap.conf.
2023-03-08 13:44:22 -07:00
Todd C. Miller
d2582c2cdb fix typo in uninstall target 2023-03-08 19:32:11 -07:00
Todd C. Miller
954980b566 Merge pull request #252 from bin-ly/main
fix typo in uninstall target
2023-03-08 19:29:01 -07:00
bin-ly
ec255dca1e fix command error for lib/util/Makefile.in 2023-03-09 10:10:45 +08:00
Todd C. Miller
dea110a848 Add tests for SHA2 digest support.
This uses the NIST byte-oriented short message test vectors.
2023-03-07 12:45:13 -07:00
Todd C. Miller
0df56634c3 Sudo 1.9.13p3 2023-03-04 09:59:19 -07:00
Todd C. Miller
689022978c A user with "list" privs for root may not list all users.
A user with "sudo ALL" for root _is_ allowed to list any user.
2023-03-03 13:57:27 -07:00
Todd C. Miller
452d63d6c1 sudoers_policy_list: do not set runas_pw to list_pw when listing
This change introduced in sudo 1.9.13 is not actually needed.  The
"list" pseudo-command checks are performed via runas_matches_pw()
which does not use runas_pw.  GitHub issue #248
2023-03-03 11:16:44 -07:00
Todd C. Miller
d9e9307d98 Fix "sudo -l command args", broken in sudo 1.9.13.
The value of user_args should not contain the command to be run in
"sudo -l command args", only the arguments of the command being checked.
This restores the pre-1.9.13 behavior.  GitHub issue #249
2023-03-03 11:12:18 -07:00
Todd C. Miller
b013711e48 Check for sudo_pow2_roundup() overflow.
Calling sudo_pow2_roundup(INT_MAX+2) will return since there is no
power of 2 larger than INT_MAX+1 that fits in an unsigned int.
This is not an issue in practice since we restrict messages to 2Mib.
2023-03-01 13:58:32 -07:00
Todd C. Miller
19a660612f write_callback: only enable /dev/tty reader if the command is running
This fixes a hang when there is /dev/tty data in a buffer to be
flushed by the final call to del_io_events().  We do not want to
re-enable the reader when flushing the buffers as part of pty_finish().
See PR #247 for analysis of the problem and how to reproduce it.
2023-03-01 13:25:17 -07:00
Todd C. Miller
43378de75e Test non-fully qualified path name. 2023-02-28 09:11:26 -07:00
Todd C. Miller
7356a77969 Fix removal of y.tab.[ch] when generating gram.[ch]. 2023-02-28 09:06:48 -07:00
Todd C. Miller
172515c94d Add test for using "list" as user, runas and host. 2023-02-28 08:56:44 -07:00
Todd C. Miller
0197491e9c Move handling of the "list" pseudo-command from lexer to parser.
The special handling of "list" in the lexer meant it could not
be used as a user, group or host, which was unintentional.
GitHub issue #246.
2023-02-28 08:47:45 -07:00
Todd C. Miller
6c97b84c0c Make the check for HAVE_DECL_NSIG consistent with other decl checks. 2023-02-27 18:44:54 -07:00
Todd C. Miller
a4f31cff2b Plug memory leak with multiple matching CHROOT= entries.
Found by oss-fuzz.
2023-02-27 08:57:17 -07:00
Todd C. Miller
f4d2412628 Sudo 1.9.13p2. 2023-02-25 11:20:55 -07:00
Todd C. Miller
87ce692468 Fix potential double free for rules that include a CHROOT= option.
If a rule with a CHROOT= option matches the user, host and runas,
the user_cmnd variable could be freed twice.
2023-02-21 20:01:13 -07:00
Todd C. Miller
6c52056d36 Include error string when formatting a SLOG_PARSE_ERROR message if present. 2023-02-23 11:37:04 -07:00
Todd C. Miller
0be5a51918 Add missing include of errno.h. 2023-02-23 09:14:28 -07:00
Todd C. Miller
3281d0eec4 sudo_lbuf_expand: check for overflow when rounding to the nearest power of 2.
Problem deteced by oss-fuzz using the fuzz_sudoers fuzzer.
2023-02-23 08:19:18 -07:00
Todd C. Miller
91814990aa Fix --enable-static-sudoers, broken in sudo 1.9.13.
sudo_qualify_plugin() should not try to fully-qualify the path to
a statically-compiled plugin.  GitHub issue #245
2023-02-23 06:57:37 -07:00
Todd C. Miller
fb6740fa2e Add sudoers open errors to the list of parse errors sent via mail.
Previously there would be one email for the open failure and a
separate one describing the parse error.  Now a single email message
contains everything.
2023-02-22 18:49:09 -07:00
Todd C. Miller
1641c30ed6 visudo: quiet a compiler warning on Solaris 10.
Also explicitly close /dev/tty fd instead of relying on closefrom()
in case the fd ends up being a value 0-2.
2023-02-22 10:55:27 -07:00
Todd C. Miller
8bb1160624 Replace LIBMD with LIBCRYPTO display crypto/tls libs in summary.
We can only have one of either -lmd, -lgcrypt or -lcrypto so there
is no need to have more than one variable.
2023-02-22 08:49:33 -07:00
Todd C. Miller
05c866b6e1 Merge pull request #244 from ffontaine/main
configure.ac: fix openssl static build
2023-02-22 09:47:42 -07:00
Fabrice Fontaine
1fed5adc16 configure.ac: fix openssl static build
Do not use AX_APPEND_FLAG as it will break static builds by removing
duplicates such as -lz or -latomic which are needed by -lssl and
-lcrypto. This will fix the following build failure with sparc which
needs -latomic:

Checking for X509_STORE_CTX_get0_cert
configure:21215: /home/thomas/autobuild/instance-3/output-1/host/bin/sparc-buildroot-linux-uclibc-gcc -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os -g0  -static -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DZLIB_CONST  -static conftest.c   -L/home/thomas/autobuild/instance-3/output-1/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib -lssl -lz -pthread -latomic -lcrypto >&5
/home/thomas/autobuild/instance-3/output-1/host/lib/gcc/sparc-buildroot-linux-uclibc/10.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/thomas/autobuild/instance-3/output-1/host/bin/../sparc-buildroot-linux-uclibc/sysroot/usr/lib/libcrypto.a(x509cset.o): in function `X509_CRL_up_ref':
x509cset.c:(.text+0x108): undefined reference to `__atomic_fetch_add_4'

[...]

In file included from ./hostcheck.c:38:
../../include/sudo_compat.h:342:41: error: conflicting types for 'ASN1_STRING_data'
  342 | #  define ASN1_STRING_get0_data(x)      ASN1_STRING_data(x)
      |                                         ^~~~~~~~~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/8be59dd94e4916f9457cb435104e36e62a28373b

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2023-02-22 10:45:36 +01:00