Commit Graph

1652 Commits

Author SHA1 Message Date
Todd C. Miller
a556b373c9 Allocate a socketpair to communicate with sudo_intercept.so over.
This is used for the intercept and log_children options.
2021-08-09 15:50:25 -06:00
Todd C. Miller
6287e8ca7d Add support for loading the sudo_intercept.so DSO. 2021-08-09 15:50:25 -06:00
Todd C. Miller
2ea773ed1f Plug a memory leak in check_net_ifs found by address sanitizer. 2021-07-29 09:29:09 -06:00
MertsA
0a506b3801 Rewind utmp file pointer after searching for entry (#108)
getutline() advances the file pointer until it matches or reaches EOF. pututline() starts from the current position in utmp. This rewinds the file pointer to the beginning to avoid allocating additional spurious utmp entries.
2021-07-26 09:07:10 -06:00
Todd C. Miller
b0ae7a566b Avoid using RLIM_INFINITY for the nofile soft limit to prevent
closefrom_fallback() from closing too many file descriptors.
2021-07-23 15:10:46 -06:00
Todd C. Miller
7a309d70bb Don't assume that the number of groups returned by getgroups() is static.
On systems where getgroups() returns results based on more than
just the per-process group vector in the kernel it is possible for
the number of groups to change in between invocations.
Based on GitHub PR #106 from Pierre-Olivier Martel.
2021-06-26 18:45:28 -06:00
Todd C. Miller
0b809cdafe regen 2021-06-22 15:23:00 -06:00
Todd C. Miller
ae0e25cf2e Move definition of INADDR_NONE from interfaces.c to net_ifs.c.
Fixes compilation on Solaris 9.
2021-06-21 10:09:32 -06:00
Radovan Sroka
f44adcdf3c Fixed bad condition for sesh args
In selinux_edit_copy_tfiles() when there is only one file and the open()
fails then number of arguments is lower than expected.
Sudo should return error with or without "Defaults !sudoedit_checkdir" set.

This was found with regression testing of CVE-2021-23240.

Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2021-06-02 11:38:26 -06:00
Todd C. Miller
97f6fc259c Fix some debug_decl typos and remove an unneeded cast. 2021-06-02 07:22:11 -06:00
Todd C. Miller
b1d4a02eab sudo_stat_plugin(): set errno but do not warn if plugin path too long.
The caller will display the warning (using errno) so there is no
need to do it twice.
2021-05-28 14:15:46 -06:00
Todd C. Miller
2e492267e7 Build sudo_noexec.so as a module on systems other then Darwin.
On Darwin, shared modules and shared libraries are not interchangable
and since we preload sudo_noexec.so via DYLD_INSERT_LIBRARIES it
must be a library, not a module.  We must relax the requirement
that libraries begin with a "lib" prefix to work around this
difference.  This does mean you must use sudo's libtool on Darwin
(macOS) but that is already a requirement on other systems (notably
HP-UX and SCO) due to a number of libtool patches we require that
haven't be accepted upstream.  This is a different fix for PR #102.
2021-05-13 12:45:56 -06:00
Todd C. Miller
d9b8311122 Fix compiler warning on FreeBSD. 2021-05-12 07:53:19 -06:00
Todd C. Miller
3147bbeb24 Don't set the command status in the closure when the command is suspended.
This should only be set for signals that terminate the process.
Fixes a bug where the sudo front-end could call the plugin close
function with a non-terminal signal argument.
2021-05-10 13:42:06 -06:00
Todd C. Miller
51cbc626f8 Fix debug message when prctl(PR_SET_DUMPABLE, 0, 0, 0, 0) fails.
GitHub issue #101
2021-05-03 12:40:23 -06:00
Todd C. Miller
727056e0c9 Make sure SIGCHLD is not ignored when sudo is executed.
If SIGCHLD is ignored there is a race condition between when the
process is executed and when the SIGCHLD handler is installed.
This fixes the bug described by GitHub PR #98
2021-04-23 07:41:27 -06:00
Todd C. Miller
6717415e73 Add minimum value to consider when overriding resource limits.
Currently only used for RLIMIT_DATA and RLIMIT_AS.

This works around a problem on HP-UX where setting RLIMIT_DATA
changes the resource limits for both 32-bit and 64-bit processes.
HP-UX processes start out with RLIMIT_DATA set based on the values
of the maxdsiz and maxdsiz_64bit kernel tunables, depending on
whether they are 32-bit or 64-bit.  By default this limit is 1GB
for 32-bit processes and 4GB for 64-bit.  However, once RLIMIT_DATA
is changed, it does not appear to be possible to restore the old
values.  This can result in a 64-bit process that is executed by a
32-bit shell getting the 32-bit RLIMIT_DATA instead of the 64-bit
one.  Bug #973
2021-04-20 14:31:40 -06:00
Todd C. Miller
42865567d7 Check for NULL ifa->ifa_addr and ifa->ifa_netmask in both loops. 2021-04-07 08:15:10 -06:00
Todd C. Miller
52c29aa7a0 Plug memory leak on overflow; Coverity CID 220556 2021-04-06 21:38:43 -06:00
Todd C. Miller
e3ff4e663c Set user group list when executing the askpass helper.
Under normal circumstances the existing group list will match the
list fetched by sudo.  However, if sudo is executed by a process
that has changed the group list via setgroups(2) and "group_source"
in sudo.conf is set to "dynamic" it is possible for them to be
different.

If group_source in sudo.conf is set to "dynamic" it is possible
for the group list
2021-04-06 14:30:16 -06:00
Todd C. Miller
d4517e0a1c Move autoconf auxiliary files to the scripts directory. 2021-04-06 14:23:38 -06:00
Radovan Sroka
c2a63690c8 Removed depricated security_context_t
Signed-off-by: Radovan Sroka <rsroka@redhat.com>
2021-04-06 06:06:46 -06:00
Todd C. Miller
a40e4b3867 Use separate getopt config for sudoedit.
Avoids a problem where the user gets an exclusive usage error message
when using a sudo-specific option.
GitHub issue #95
2021-03-30 16:07:28 -06:00
Todd C. Miller
a4c710ccfd Add -h and -V to sudoedit usage and customize help output for sudoedit.
Also add missing -B option to usage strings.
2021-03-30 15:53:38 -06:00
Todd C. Miller
b9a0c72fd1 Don't report a usage error for "sudo -V".
GitHub issue #95
2021-03-30 15:17:31 -06:00
Todd C. Miller
ce1f0da845 SCO OpenServer uses SIOCGIFANUM, not SIOCGIFNUM.
On OpenServer, SIOCGIFNUM is the number of network interfaces,
not the number of ifreq structs.
2021-03-29 09:59:09 -06:00
Todd C. Miller
b269da75b8 Add support for HP-UX SIOCGLIFNUM and SIOCGLIFCONF ioctls.
We need to use both SIOCGIFCONF and SIOCGLIFCONF since SIOCGLIFCONF
only returns IPv6 addresses.
2021-03-27 13:55:07 -06:00
Todd C. Miller
00cdc83cb6 Move get_net_ifs stub to the top and remove unused INET_ADDRSTRLEN def. 2021-03-24 20:36:49 -06:00
Todd C. Miller
0e49dd2381 No longer need ifr_tmp variable, just reuse ifr.
Now that we store the string version of the address before fetching
the netmask we can just re-use ifr.  This simplifies things and is
safer since if there is space for the address there must also be
space for the mask.
2021-03-24 14:18:40 -06:00
Todd C. Miller
423e231229 SCO OpenServer 5 returns a bogus value for SIOCGIFNUM.
Gleaned from sendmail.
2021-03-24 08:57:43 -06:00
Todd C. Miller
45ca46d735 Use SIOCGSIZIFCONF or SIOCGIFNUM where available.
Still falls back to a loop if not but now maxes out at 2048
interfaces instead of potentially looping forever.
2021-03-24 08:57:40 -06:00
Todd C. Miller
cf8feb2876 Remove support for obsolete ISC UNIX and MIPS RISC/OS systems.
They were getting in the way of net_its.c simplification.
2021-03-24 08:54:17 -06:00
Todd C. Miller
9d6a37a49b Use SIOCGLIFCONF to get interface list where supported (Solaris).
HP-UX has a SIOCGLIFCONF but it is incompatible (and appears to only
return IPv6 addresses).
Also add IPv6 support using SIOCGIFCONF (probably AIX only) and make
sure ifr_tmpbuf[] is properly aligned.
2021-03-22 19:51:40 -06:00
Todd C. Miller
06df3a1b47 Add simple regress check to display the network interfaces found. 2021-03-22 12:26:36 -06:00
Todd C. Miller
dfff132122 Add a new "fuzz" target that executes the fuzzers for 8192 runs each.
To run indefinately, set FUZZ_RUNS=-1, e.g. "make FUZZ_RUNS=-1 fuzz"
2021-03-18 16:48:19 -06:00
Todd C. Miller
4c182c90f1 Rename "fuzz" makefile target to "check-fuzzer".
It's purpose is to run the fuzzers are part of a normal "make check"
to avoid bit rot, not to perform a fuzzer run.
The fuzz_logsrvd_conf fuzzer was not wired up to "make check" previously.
2021-03-18 09:08:16 -06:00
Todd C. Miller
3f11e8d9a6 Quiet a few Solaris Studio compiler warnings. 2021-03-10 08:57:28 -07:00
Todd C. Miller
0cf7c3a951 Set locale for all "make check" targets. 2021-03-08 12:51:48 -07:00
Todd C. Miller
14c71eaa86 Add clean rules to .PHONY target. 2021-02-19 08:54:04 -07:00
Todd C. Miller
9f1e016cde Add install-fuzz Makefile target to install the fuzzers and seed corpus.
The FUZZ_DESTDIR make variable needs to be set in the environment
or on the command line.
2021-02-18 19:38:54 -07:00
Todd C. Miller
41eae91206 If sudo_getgrouplist2() returns -1, clamp ngroups based on max_groups.
The ngroups parameter is an out parameter that is filled in with
the actual number of groups, which may be less than the static
number allocated when max_groups is set in sudo.conf.
Fixes a potential out of bounds read found by LLVM libFuzzer.
2021-02-13 11:54:21 -07:00
Todd C. Miller
0663ffbc3f Use sudo_basename() instead of doing the equivalent manually. 2021-02-10 15:14:08 -07:00
Todd C. Miller
63d043fae2 Silence a clang analyzer false positive. 2021-02-08 16:16:23 -07:00
Todd C. Miller
63a3f62547 Add fuzz Makefile target and run fuzzer corpus in make check. 2021-02-08 04:56:17 -07:00
Anton Bershanskiy
fecb68617d Fix comment typo in src/copy_file.c 2021-02-06 12:23:31 -07:00
Todd C. Miller
19d5845f8b The program name may now only be "sudo" or "sudoedit".
We no longer need to check for any string that ends in "edit".
2021-01-26 11:33:05 -07:00
Todd C. Miller
c0eecf85c8 Don't assume that argv is allocated as a single flat buffer.
While this is how the kernel behaves it is not a portable assumption.
The assumption may also be violated if getopt_long(3) permutes arguments.
Found by Qualys.
2021-01-23 08:44:00 -07:00
Todd C. Miller
b301b46b79 Reset valid_flags to MODE_NONINTERACTIVE for sudoedit.
This is consistent with how the -e option is handled.
Also reject -H and -P flags for sudoedit as was done in sudo 1.7.
Found by Qualys, this is part of the fix for CVE-2021-3156.
2021-01-23 08:43:59 -07:00
Todd C. Miller
3a13f1bf0c Run the editor with the user's real and effective uid and gid.
Fixes a bug introduced in sudo 1.9.5 where the editor was run setuid
root unless SELinux RBAC was in use.
2021-01-11 18:41:19 -07:00
Todd C. Miller
01d0bbfb85 Add casts to quiet two warnings on Solaris. 2021-01-11 07:35:33 -07:00