Commit Graph

386 Commits

Author SHA1 Message Date
Todd C. Miller
939585e906 tv_nsec can never be negative after timespecsub.
Found by PVS Studio
2018-10-17 06:21:48 -06:00
Todd C. Miller
2b56252210 Handle EOF on password input when pwfedback is enabled. 2018-10-08 06:47:53 -06:00
Todd C. Miller
d8870177c2 Pass getgrouplist() NGROUPS_MAX+1, not NGROUPS_MAX so we have room
for the primary gid.
2018-09-22 12:55:44 -06:00
Todd C. Miller
c639c965cf Fix a crash in the event system's poll() backend introduced with
support for nanosecond timers.  Only affects systems without ppoll().
Bug #851
2018-09-12 07:02:13 -06:00
Todd C. Miller
a924b4610b Fix warnings on OpenIndiana (Illumos) 2018-08-30 14:06:18 -06:00
Todd C. Miller
5fea22e514 sync 2018-08-26 19:31:20 -06:00
Todd C. Miller
63f7aa8fcf Backward ABI compatibility for even functions that use a timeval. 2018-08-25 21:02:07 -06:00
Todd C. Miller
6b76f9dbd3 Use a monotonic timer for the event subsystem. 2018-08-25 21:02:06 -06:00
Todd C. Miller
04d1f56d90 Use struct timespec, not struct timeval in the event subsystem.
Use ppoll() or pselect() if avaialble which use timespec.
2018-08-25 21:02:05 -06:00
Todd C. Miller
fe965c3a31 Fix typo in last commit. 2018-08-22 19:15:26 -06:00
Todd C. Miller
d876602dbf Do not assume all Linux has linux/random.h.
Add missing sys/syscall.h include
2018-08-22 15:12:11 -06:00
Todd C. Miller
ad104a3e47 Fix setting of errno when gotdata() fails. 2018-08-22 10:36:00 -06:00
Todd C. Miller
df1c062526 HP-UX doesn't suport CLOCK_MONOTONIC but we can use gethrtime() instead. 2018-08-20 10:56:34 -06:00
Todd C. Miller
6953e7fc79 Move updating of the window size to the monitor process.
This will allow us to close the slave in the main sudo process in
the future so only the command and monitor have it open.
2018-08-20 10:04:14 -06:00
Todd C. Miller
b3227d3ed5 Add sudo_gettime_uptime() to measure time while not sleeping. 2018-08-19 09:55:08 -06:00
Todd C. Miller
86413f95ec Don't need to preallocate 4 x NGROUP_MAX on AIX or BSD/Linux.
For BSD/Linux, getgrouplist(3) will tell us the number of groups if
we don't have enough.  For AIX, we can count the entries in the
group set before allocating the group vector.
2018-07-26 15:12:26 -06:00
Todd C. Miller
e7daff062f Linux getgrouplist(3) returns the number of groups on success instead
of 0 like BSD.
2018-07-23 07:23:17 -06:00
Todd C. Miller
33f96a0347 Use madvise(2) with MADV_WIPEONFORK if available. 2018-07-03 13:58:49 -06:00
Todd C. Miller
0ae9662833 Add sudo_getgrouplist2() to dynamically allocate the group vector.
This allows us to avoid repeatedly calling getgrouplist() with
a statically sized vector on macOS, Solaris, HP-UX, and AIX.
2018-06-15 14:05:13 -06:00
Todd C. Miller
43003d29d8 Use arc4random for mkstemp() and insults. 2018-05-24 21:04:23 -06:00
Todd C. Miller
ddd663a5f2 Import arc4random() from libressl. This takes an all-in-one approach
instead of the one-file-per-OS approach that libressl takes.
The fallback code does not have as many OS-specific bits as libressl.
2018-05-24 21:04:23 -06:00
Todd C. Miller
154a5f59a9 Move digest code into libutil 2018-05-24 21:04:07 -06:00
Todd C. Miller
670d8e6d77 Special case comment lines in lbufs. 2018-03-04 07:03:41 -07:00
Todd C. Miller
42fe0409f6 Add sudo_ev_dispatch(), a wrapper for ev_loop() with no flags.
Similar the dispatch function in libevent.
2018-02-19 11:00:10 -07:00
Todd C. Miller
a885b952fb Remove use of AC_HEADER_TIME, only obsolete platforms actually
need this.  Also stop removing sys/time.h unless the source file
uses struct timeval.
2018-01-17 09:52:15 -07:00
Todd C. Miller
ff5ac3ef0e Add tsdump, a simple utility to dump a timestamp file. To build,
run "make tsdump" in the plugins/sudoers directory (it is not built
by default).  In order to map the tty device number to a name,
sudo_ttyname_dev() has been moved into libsudo_util.
2018-01-11 10:49:20 -07:00
Todd C. Miller
d93559e9c0 regen 2017-12-18 09:39:06 -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
dd47a0a416 Add missing initprogname() calls. 2017-11-28 09:06:44 -07:00
Todd C. Miller
2c45774a35 Treat an empty hostname as a failure and return NULL. 2017-10-20 07:37:40 -06:00
Todd C. Miller
fdff345e0f The read and write sides of signal_pipe[] were swapped, resulting
in EBADF reading from and writing to the signal pipe on Linux and
probably others.  On systems with bidirectional pipes this was not
an issue.
2017-09-06 12:29:36 -06:00
Todd C. Miller
c3b3e501b9 regen 2017-08-01 15:45:20 -06:00
Todd C. Miller
5a6b8a78f1 Include pathnames.h for /dev/fd on FreeBSD and Mac OS X. 2017-07-27 20:51:21 -06:00
Todd C. Miller
7f8765d327 If we free the default base in sudo_ev_base_free(), reset the default
base to NULL.
2017-07-14 10:09:58 -06:00
Todd C. Miller
d2a0bfbb12 Add the ability to set a default event base, to be used by plugins
which don't have access to the event base.
2017-07-13 13:59:31 -06:00
Todd C. Miller
6505d05803 Clear input, output, control and local flags before copying them
from the source terminal.  Otherwise, flags that are disabled
in the source terminal may still be enabled in the destination.
2017-07-12 05:47:28 -06:00
Todd C. Miller
e70a953fb4 Remove pointless subshells in targets that simply change the directory
and execute a command.  The command is already run in a shell so
there is no need to execute a subshell in this case.
2017-07-12 05:45:46 -06:00
Todd C. Miller
88bf0337e9 Move the bits to fill in the new event base to sudo_ev_base_init(),
which is not currently exported.
2017-06-01 09:45:23 -06:00
Todd C. Miller
c000189684 Use getentropy() in mkstemp/mkdtemp replacement. 2017-06-29 18:11:30 -06:00
Todd C. Miller
6d4d4594b7 Use _PATH_DEV consistently 2017-06-29 18:10:53 -06:00
Todd C. Miller
c77c5d026a When copying terminal settings from one tty to another only copy a
subset of the flags.  Sudo now copies the same set of flags that
OpenSSH uses, which should be safe.
2017-06-15 12:59:46 -06:00
Todd C. Miller
cc71b99849 Add a new "devsearch" Path setting to sudo.conf for configuring the
/dev paths to traverse instead of hard-coding a list in ttyname.c
The default value can be set at configure time.
2017-05-30 10:44:11 -06:00
Todd C. Miller
20a0fa1284 Fix potential memory leak on reallocarray() error. Coverity CID 169639 2017-05-23 13:26:54 -06:00
Todd C. Miller
c91b6777d3 On HP-UX 11.0, sys/ioctl.h is not sufficient to make struct winsize
visisble, we need termios.h too.
2017-05-15 09:37:58 -06:00
Todd C. Miller
ea9120ee24 Always used TIOCGWINSZ. 2017-05-15 09:21:00 -06:00
Todd C. Miller
d979898e71 Remove use of non-standard sigaction_t 2017-05-12 10:02:18 -06:00
Todd C. Miller
95e92bfe4e Activate the sigevents inside the signal pipe callback itself
and call signal_pipe_cb() directly if the backend returns EINTR
and the signal_caught flag is set.  This has the side effect of
processing signal events in the current pass of the event loop
instead of the next one.
2017-05-12 10:02:17 -06:00
Todd C. Miller
9d4a92b9b4 Handle the possibility of the siginfo parameter in sa_sigaction
handler being NULL.
2017-05-12 10:02:17 -06:00
Todd C. Miller
2a55808775 Add support for signal events in sudo's event subsystem 2017-05-12 10:02:17 -06:00
Todd C. Miller
6af6f84670 Fix exponential behavior in glob() with respect to multiple '*'.
See https://research.swtch.com/glob
Adapted from https://perl5.git.perl.org/perl.git/commit/33252c318625f3c6c89b816ee88481940e3e6f95
2017-04-28 12:12:00 -06:00