Todd C. Miller
7e20e4b80f
Apply multiarch rules when loading plugins too.
2022-10-06 12:46:38 -06:00
Todd C. Miller
88ac5e09b6
Use sudo_secure_open_file() instead of sudo_secure_file() where possible.
...
Both sudo_secure_open_file() and sudo_secure_open_dir() are now passed
a struct stat pointer like sudo_secure_file() and sudo_secure_dir().
2022-09-21 19:08:10 -06:00
Todd C. Miller
cbd52e705c
Fix potential TOCTOU when creating time stamp directory and file.
2022-09-21 19:08:09 -06:00
Todd C. Miller
304726a215
Move gcc-style __attribute__ macros to config.h.in
...
Renamed __malloc -> sudo_malloclike, __printflike -> sudo_printflike,
__printf0like -> sudo_printf0like.
Add sudo_noreturn instead of __attribute__((__noreturn__)).
We do not use stdnoreturn.h since it has been deprecated in C23
in favor of the [[noreturn]] attribute.
2022-09-07 07:48:31 -06:00
Todd C. Miller
882990b1b3
Use gcc's malloc attribute for malloc-like allocation functions.
2022-07-26 15:14:03 -06:00
Todd C. Miller
5516cdcd5b
For preload DSO make copies of cmnd, argv, envp and map them read-only.
2022-07-25 19:56:54 -06:00
Todd C. Miller
fccf3c9c56
Add sudo_mmap_{alloc,allocarrary,strdup,free} functions.
...
These allocate memory via mmap anonymous regions and store the mapped
size immediately before the returned pointer as an unsigned long.
They are intended to be used in cases where malloc(3) and free(3)
are unsuitable due to concerns about corrupting global state in
multi-threaded programs or signal handlers.
2022-07-25 15:08:11 -06:00
Todd C. Miller
f5ac1317c4
Make sudo pass -Wmissing-prototypes
2022-06-27 12:48:03 -06:00
Todd C. Miller
7537713904
Adjust starttime test when run under Debian faketime.
...
Bug #1026
2022-03-15 08:38:27 -06:00
Todd C. Miller
7c17f84a35
Add helper function to compile a regex that supports (?i).
2022-02-11 12:01:31 -07:00
Todd C. Miller
c13b21c199
Avoid TOCTOU in sudo_mkdir_parents() using openat(2) and mkdirat(2).
...
This also allows us to make path const as it should be.
2021-12-11 08:35:18 -07:00
Todd C. Miller
2db9e64214
Move reference-counted string code from sudoers to libsudo_util.
...
It will be used by sudo_logsrvd too.
2021-04-06 14:44:19 -06:00
Todd C. Miller
41fa461fe1
Add a GNU-compatible version of basename(3).
...
Unlike POSIX basename(3), the GNU variant does not modify its argument.
Note that basename of a path ending in "/" returns an empty string.
2021-02-10 14:26:26 -07:00
Todd C. Miller
b132def0b1
For sudo, only allow "sudo" or "sudoedit" as the program name.
...
The program name is also used when matching Debug lines in sudo.conf.
We don't want the user to be able to influence sudo.conf Debug matching.
The string "sudoedit" is treated the same as "sudo" in sudo.conf.
Problem reported by Matthias Gerstner of SUSE.
2021-01-06 10:16:00 -07:00
Todd C. Miller
985af422d2
Rename __dso_public -> sudo_dso_public and move to config.h.
2020-08-12 09:57:42 -06:00
Todd C. Miller
d85d370c63
Add dependent system includes to make sudo_*.h more standalone.
...
In the past we've relied on the various .c files to include the
system headers that define types that the sudo_*.h headers require.
This is fragile and can cause issues when includes get re-ordered.
2020-05-18 04:47:21 -06:00
Todd C. Miller
83d1bee918
Rename sudo_parse_host_port -> iolog_parse_host_port and mv to lib/iolog
...
It is not used outside of the I/O log client and server and the
host:port syntax may change in the future.
2020-05-11 08:47:54 -06:00
Todd C. Miller
0cf2e09e0c
Apply spelling fixes.
...
Fixes from PR #30 (ka7) and Bug #925 (fossies.org codespell)
2020-05-06 09:27:43 -06:00
Todd C. Miller
b5a317aeb9
Add support for a tls flag in sudo_parse_host_port().
...
If the string "(tls)" appears at the end, the tls flag is set to true
and the default tls port is used if necessary.
2020-05-05 13:23:26 -06:00
Todd C. Miller
ed294b8283
Add code to generate universally unique identifiers.
...
We create type 4, variant 1 uuids (random).
2020-01-30 13:12:25 -07:00
Todd C. Miller
b270b0c887
Split out code to parse host:port into a utility function.
2019-11-02 12:04:26 -06:00
Todd C. Miller
f1d0c99e03
Move bufsize_roundup() -> sudo_pow2_roundup() in libsudo_util.
2019-11-02 12:03:44 -06:00
Todd C. Miller
76eec78a33
Add basic support for event logging using a sudo-style log format.
2019-10-24 20:04:32 -06:00
Todd C. Miller
059b55ce72
Refactor code in sudoers that creates I/O log files to share with logsrvd.
2019-10-24 20:04:31 -06:00
Todd C. Miller
e0c9a9dfa3
Move mkdir_parents to libsudo_util.
2019-10-24 20:04:31 -06:00
Todd C. Miller
40bf4081be
Rename sudo_strtoid() to sudo_strtoidx() and add simplified sudo_strtoid()
2019-10-20 10:21:29 -06:00
Todd C. Miller
2512f6efbf
Use sudo_strtonum() explicitly instead of via a macro.
2019-10-14 10:09:30 -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
716aa6e4ab
Support st_nmtime in struct stat as found in HP-UX.
2018-11-14 13:37:46 -07:00
Todd C. Miller
2121693879
Move definition of TIME_T_MAX to sudo_util.h
2018-09-24 14:21:58 -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
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
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
48fba3c2cc
update my email to Todd.Miller@sudo.ws
2017-12-03 17:53:40 -07:00
Todd C. Miller
5b86d2d298
Make sudo_parseln() flags hex to make it more obvious that they are
...
bit flags.
2016-09-01 14:36:24 -06:00
Todd C. Miller
2a4ba64c84
Add flag to sudo_parseln() to disable line continuation support.
2016-09-01 10:50:39 -06:00
Todd C. Miller
17ad75d50b
Add a flags option to sudo_parseln() and a flag to only mach comments
...
at the beginning of the line. Use the flag when parsing ldap.conf.
2016-09-01 09:19:20 -06:00
Todd C. Miller
6cbba7d665
Add an administrative domain to the passwd/group cache key for
...
AIX which can have different name <-> ID mappings depending
on whether the database is local, LDAP, etc.
2016-02-01 11:08:58 -07: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
a76b93e23a
Use our own bitmap macros instead of borrowing the ones from select.
2015-06-23 16:37:00 -06:00
Todd C. Miller
8d1708434f
Add sudo_strsplit(), similar to strtok_r() but non-destructive and
...
operates on non-C strings (requires a length parameter).
2015-05-26 15:46:41 -06:00
Todd C. Miller
05a01d4c5d
Avoid using a leading underbar in defines as they are reserved in
...
ISO C.
2015-05-21 11:13:20 -06:00
Todd C. Miller
9240018ce4
Avoid struct assignment when stashing mtime since AIX at least uses
...
a struct st_timespec that differs from struct timespec.
From Andrey Klyachkin.
2015-04-10 07:43:54 -06:00
Todd C. Miller
ee72cba937
Use futimens() and utimensat() instead of futimes() and utimes().
2015-03-02 13:58:50 -07:00
Todd C. Miller
be8dbeb22e
Avoid using HOST_NAME_MAX directly and use sysconf(_SC_HOST_NAME_MAX)
...
instead.
2015-02-19 20:28:02 -07:00
Todd C. Miller
8bc688188f
Move sudo_printf extern to sudo_util.h
2014-08-31 18:46:26 -06:00
Todd C. Miller
ecaecdc1f4
Merge secure_path.h -> sudo_util.h
2014-07-22 11:37:39 -06:00
Todd C. Miller
844a285391
Version the functions in libsudo_util
2014-07-22 11:26:17 -06:00
Todd C. Miller
a8fa112a53
atobool -> sudo_strtobool
...
atoid-> sudo_strtoid
atomode -> sudo_strtomode
2014-06-27 14:53:54 -06:00