Commit Graph

98 Commits

Author SHA1 Message Date
Todd C. Miller
586b418ad8 Sanity check size when converting the first record to TS_LOCKEXCL
Coverity CID 206591
2020-01-05 09:37:09 -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
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
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
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
6786d53d45 In timestamp_open() no need to free cookie on error, it is NULL.
Found by PVS-Studio.
2018-10-19 13:32:24 -06:00
Todd C. Miller
fe58062547 Cast uid/gid to unsigned int before printing. 2018-08-22 12:58:24 -06:00
Todd C. Miller
aaefdd7575 Include stddef.h for offsetof() definition. 2018-08-22 10:27:33 -06:00
Todd C. Miller
dcf168e702 fix compiler warnings on Solaris 11 2018-08-22 10:40:11 -06:00
Todd C. Miller
7a929ce135 Add debugging info so we can tell why a timestamp record doesn't match. 2018-08-15 09:19:50 -06:00
Todd C. Miller
07d9cec271 Remove extraneous break statement and fix some whitespace. 2018-01-30 11:12:38 -07:00
Todd C. Miller
b3601253e6 Fall back to ppid time stamps if timestamp_type == kernel and no
tty is present.  This is consistent with timestamp_type == tty.
2018-01-23 11:18:18 -07:00
Todd C. Miller
52409b9c72 Do not call the TIOCSETVERAUTH ioctl with a negative number of seconds.
Also cap the max number of seconds at 3600 to avoid getting EINVAL
from TIOCSETVERAUTH.
2018-01-23 11:05:41 -07:00
Todd C. Miller
4c0c225062 Store passwd_timeout and timestamp_timeout as a struct timespec
instead of as a float.  Remove timeout argument to auth_getpass()
as it was never used.
2018-01-22 12:18:48 -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
7f99af859a Use a tty lock even for kernel time stamps so we can avoid simultaneous
password prompts.
2017-12-22 11:10:22 -07:00
Todd C. Miller
feb48b8ebf Add "kernel" as a possible value of timestamp_type.
Currently only supported on OpenBSD.
2017-12-20 16:19:54 -07:00
Todd C. Miller
1709dc7f77 In the timestamp record, include the start time of the terminal
session leader for tty-based timestamps or the start time of the
parent process for ppid-based timestamps.  Idea from Duncan Overbruck.
2017-12-16 05:53:05 -07:00
Todd C. Miller
5cec5734cc If the lock record doesn't match the expected record size we need
to seek to the end of the record as we otherwise may have gone too
far (or not far enough).  Fixes interop problems when the time stamp
record changes size.
2017-12-15 21:08:38 -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
63d954d1fc Replace tty_tickets option with timestamp_type which can be
global, ppid or tty.  Defaults to tty (no change in behavior).
Some users want the ppid behavior.
2017-08-01 16:14:54 -06:00
Todd C. Miller
a842913aa7 Use debug logging instead of ignore_result() where possible. 2017-05-12 10:02:18 -06:00
Todd C. Miller
b5c88e52b1 Remove use of the non-standard SA_INTERRUPT 2017-05-12 10:02:17 -06:00
Todd C. Miller
8d1e994d84 cast mode_t to unsigned int when printing with %o 2017-03-22 08:37:12 -06:00
Todd C. Miller
7668b4b42b Set umask temporarily when creating files instead of changing the
mode after the fact.  This is slightly less error prone.
2017-03-21 16:21:17 -06:00
Todd C. Miller
8d57491dc1 Add PERM_IOLOG so we can create I/O log files on an NFS-mounted
filesystem where root is remapped to an unprivileged user.
2017-03-21 13:41:14 -06:00
Todd C. Miller
2dbd091443 When creating the timestamp directory, use the group of the timestamp
owner instead of inheriting the group of the parent directory.
2017-03-20 12:59:28 -06:00
Todd C. Miller
00b4732c9d Add some casts to quiet gcc warnings on Solaris and remove a
now-useless debug printf.
2017-03-03 11:20:56 -07:00
Todd C. Miller
852ffa5938 Ignore a boot time that is in the future, which can happen when the
clock is corrected down after boot.  Otherwise, the timestamp file
will be unlinked each time sudo is run and a password is always
required.
2016-12-01 10:52:05 -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
bf62530acf Move io_mkdir_parents() to its own file and use it in ts_mkdirs(). 2016-10-29 12:45:57 -06:00
Todd C. Miller
cf5a12c09a def_timestamp_timeout is a double so compare against 0.0 not 0 to
avoid making it appear to be an integer type.
2016-10-26 10:56:32 -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
602ed0c747 In ts_mkdirs(), change the order from stat then mkdir, to mkdir then stat.
This more closely matches what "mkdir -p" does.
Coverity CID 104119.
2016-05-06 16:37:20 -06:00
Todd C. Miller
7a86430d41 Cast off_t printed via printf(3) instead of assuming it is long long. 2016-05-06 14:17:32 -06:00
Todd C. Miller
562b5cb59b Check lseek() return value.
Coverity CID 104061.
2016-05-05 16:46:25 -06:00
Todd C. Miller
60e740dd60 Ignore ts_write() return value when disabling an entry with a bogus
timestamp.  We ignore the timestamp entry even it doesn't succeed.
Coverity CID 104062.
2016-05-05 16:30:11 -06:00
Todd C. Miller
8b12390abf Add debug_return_ssize_t 2015-11-01 15:13:28 -07:00
Todd C. Miller
c6dad0001d Avoid compilation error on Solaris 10 with Stun Studio 12.
Bug #727
2015-11-01 15:08:50 -07:00
Todd C. Miller
118680eabf Cast sizeof(entry) to off_t before making it a negative offset for
lseek().  Fixes "sudo -k" on Solaris and probably others.
2015-09-24 10:52:44 -06:00
Todd C. Miller
67183d74f4 Remove include/compat/timespec.h. Systems old enough to lack struct
timespec are too old to build a modern sudo.
2015-09-09 11:13:22 -06:00
Todd C. Miller
69050f9345 Bring back the check for time stamp files that predate the boot
time.  Instead of truncating we now unlink the file since another
process may be sleeping on the lock.
2015-09-07 06:06:08 -06:00
Todd C. Miller
7d0a623fdd Use pread(2) and pwrite(2) where possible. 2015-09-07 06:06:08 -06:00
Todd C. Miller
0487b6da9d Adjust new locking to work when tty_tickets is disabled. We need
to use per-tty/ppid locking to gain exclusive access to the tty
for the password prompt but use a separate (short term) lock
that is shared among all sudo processes for the user.
2015-09-07 06:06:08 -06:00
Todd C. Miller
f9b8a43816 Allow the time stamp lock to be interrupted by signals. 2015-09-07 06:06:08 -06:00
Todd C. Miller
00142c91fa Lock individual records in the timestamp file instead of the entire
file.  This will make it possible for multiple sudo processes using
the same tty to serialize their timestamp lookups.
2015-09-07 06:06:08 -06:00
Todd C. Miller
8f84857977 Fix creation of the timestamp file; bug #704 2015-07-20 20:16:14 -06:00
Todd C. Miller
0b241088b3 There's no need to conditionalize the #include <unistd.h>, we require
a POSIX system.
2015-07-02 09:08:28 -06:00