Todd C. Miller
24351bdadc
sudo_set_grlist and sudo_set_gidlist: set auth registry based on username
...
Previously we used the global registry but since we have the user's
passwd info we should use that when storing the group and gid lists.
2023-11-03 10:30:56 -06:00
Todd C. Miller
e343e07543
Use #include <foo.h> instead of #include "foo.h" in most cases.
...
We rely on the include path to find many of these headers. It
especially doesn't make sense to use #include "foo.h" for headers
in the top-level include directory.
2023-09-25 10:13:28 -06:00
Todd C. Miller
2fdb4db339
Wrap valid_shell and add to sudo_pwutil_set_backend().
...
This will make it possible to support a different getusershell()
implementation for testsudoers in the future.
2023-09-09 14:48:25 -06:00
Todd C. Miller
d18ee8e0e7
Move check_user_shell() to pwutil.c as user_shell_valid()
...
This will make it possible to support a different backend which may
be used by testsudoers in the future.
2023-09-09 14:07:28 -06:00
Todd C. Miller
f5b3f99098
user_in_group: the user's group vector already includes the primary group.
...
There's no need to look up the name of user's primary group (pw_gid),
we always include the primary group ID in the group vector.
2023-08-30 13:36:41 -06:00
Todd C. Miller
2440174954
Make struct sudoers_context private to sudoers.c.
...
We now pass a pointer to the context where necessary. There are a
few cases where we need to request the context from sudoers via
sudoers_get_context() for the plugin API functions. If the plugin
API was able to pass around a closure pointer this would not be
necessary.
2023-08-21 09:21:49 -06:00
Todd C. Miller
20baa39007
Move max_groups out of sudoers_user_context and into pwutil.c.
...
It is only used by the local password pwutil implementation.
2023-08-14 16:29:15 -06:00
Todd C. Miller
a38b714667
sudoers plugin: silence most -Wconversion warnings.
2023-07-07 15:07:04 -06:00
Rose
e54ba33ea0
Avoid compiler casting warnings by assigning to the same type where possible
...
This saves instructions that are related to casting as well as compiler warnings.
2023-06-28 17:25:26 -04:00
Todd C. Miller
3ecfa025b8
sudo_debug_group_list: short-circuit if groups is NULL
2022-11-11 11:05:12 -07:00
Todd C. Miller
6a3fb3fd73
Add debugging to sudo_set_grlist() and sudo_set_gidlist().
2022-10-28 16:58:16 -06:00
Todd C. Miller
13672f28df
Make sudo pass -Wwrite-strings
2022-06-28 16:33:15 -06:00
Todd C. Miller
41f116050f
Add --group-file and --passwd-file options to cvtsudoers.
...
These are based on the code in testsudoers.
2021-09-23 19:18:25 -06:00
Todd C. Miller
a2e4f53642
Cast NULL terminator argument to char * when calling sudo_mkgrent().
...
Avoids a portability issue on systems where NULL is not a pointer.
2021-04-06 18:57:33 -06:00
Todd C. Miller
f0761a9810
No need to update cp after storing gr->gr_name, it is not used,
...
Coverity CID 219314
2021-03-03 07:13:25 -07:00
Todd C. Miller
7463a1989f
Add sudo_mkgrent(), to be used to prime the group cache in tests/fuzzers.
2021-02-22 08:00:46 -07:00
Todd C. Miller
520db741b5
Fix sudo_getgrgid reference count bug when gid doesn't exist.
...
This one was missed when the other user/group lookup functions
were fixed.
2021-02-12 19:27:47 -07:00
Todd C. Miller
f6a14c9414
Include strings.h for strcasecmp(3).
...
From Tim Rice
2020-09-04 15:59:27 -06:00
Todd C. Miller
fa5d44b8b5
Quiet some clang 10 analyzer warnings.
2020-08-07 14:22:56 -06:00
Todd C. Miller
446ae3f507
Include string.h unconditionally and only use strings.h for strn?casecmp()
...
In the pre-POSIX days BSD had strings.h, not string.h.
Now strings.h is only used for non-ANSI string functions.
2020-05-18 07:59:24 -06:00
Todd C. Miller
dd88460800
We no longer need to include headers we don't use for sudo*.h files.
...
Previously we needed to include headers required by the various
sudo*h files. Now those files are more self-sufficient and we
should only include headers needed by code in the various .c files.
2020-05-18 06:47:04 -06: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
c3ce3a84fb
Refer to user-ID and group-ID instead of "user ID" and "group ID"
2019-10-19 14:26:41 -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
9d5867eaed
Use errno in warning when sudo_make_*_item() fails.
...
Previously we always said "out of memory" if not ENOENT.
2019-10-14 10:09:28 -06:00
Todd C. Miller
1e1ef61902
Add SPDX-License-Identifier to files.
2019-04-29 07:21:51 -06:00
Todd C. Miller
194968eaf0
Plug a memory leak on user/group lookup failure found by ASAN.
2019-03-14 11:31:05 -06: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
aaefdd7575
Include stddef.h for offsetof() definition.
2018-08-22 10:27:33 -06:00
Todd C. Miller
b31656b7f1
Add cppcheck annotation to suppress memory leak false positive.
2018-05-16 10:14:39 -06:00
Todd C. Miller
14ee65c525
Add -M option to cvtsudoers to force the use of the local passwd
...
and group databases when matching.
2018-03-22 13:24:41 -06:00
Todd C. Miller
e26ef96a65
Add case_insensitive_group and case_insensitive_user sudoers options,
...
which are enabled by default.
2018-03-05 10:42:02 -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
250209d7a8
When running a command as the invoking user we cannot use the gid
...
list from the front-end since it may not correspond to the user's
aux group vector as defined by the group database.
2017-11-28 09:48:43 -07: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
9cfd556853
Add match_group_by_gid Defaults option to allow sites with slow
...
group lookups and a small number of groups in sudoers to match
groups by group ID instead of by group name.
2016-08-30 13:42:42 -06:00
Todd C. Miller
043b3d223b
Separate out the supplemental group ID checks from the supplemental
...
group name checks in user_in_group(). We now call sudo_get_gidlist()
only when the group name in sudoers begins with a '#' (which is
seldom used).
2016-08-13 21:12:22 -06:00
Todd C. Miller
985ab1dd3e
Cache the user's group IDs and group names separately and only
...
resolve group IDs -> names when needed. If the sudoers file doesn't
contain groups we will no longer try to resolve all the user's group
IDs to names, which can be expensive on some systems.
2016-08-13 16:27:44 -06:00
Todd C. Miller
05db5aa3b8
Remove sudo_mkpwcache() and sudo_mkgrcache(). We now create the
...
caches as needed on demand. Also remove calls to sudo_freepwcache()
and sudo_freegrcache() that are immediately followed by execve(),
they are not needed.
2016-05-11 09:40:31 -06:00
Todd C. Miller
23d288563e
Eliminate use of setpwent()/endpwent() and setgrent()/endgrent().
...
Sudo never iterates over the passwd or group file.
Rename sudo_set{pw,gr}ent() -> sudo_mk{pw,gr}cache() and
use sudo_free{pw,gr}cache() instead of sudo_end{pw,gr}ent().
2016-05-11 07:06:45 -06:00
Todd C. Miller
2152f053b1
Use a single debug message for cache hit or store to avoid another
...
situation where they get out of sync. Bug #743
2016-05-04 09:15:12 -06:00
Todd C. Miller
a152afaeb5
Sync the "cache hit" debug messages with the "cached" debug messages.
...
This fixes a bug where we could dereference a NULL pointer when we
look up a negative cached entry which is stored as a NULL passwd
or group struct pointer. Bug #743 .
2016-05-04 08:55:21 -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
c28f59271a
Additional debugging for pwutil functions.
2016-01-22 17:04:59 -07: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
Todd C. Miller
dc883f2454
We require ANSI C so stop using the obsolete STDC_HEADERS.
2015-06-19 14:29:27 -06:00
Todd C. Miller
4f9cabd005
Remove obsolete memory.h include.
2015-06-18 21:02:57 -06:00
Todd C. Miller
6b7be032af
Use non-existing allocators in the passwd/group cache functions.
2015-05-27 10:26:49 -06:00
Todd C. Miller
2bf454b74d
Use non-exiting allocators in the redblack tree and fix the fallout.
...
Also switch to non-exiting allocators in affected code blocks.
2015-05-27 09:51:54 -06:00