Commit Graph

79 Commits

Author SHA1 Message Date
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
Todd C. Miller
c299cdd665 Remove extraneous casts of node->data (which is void *). 2015-02-05 15:01:25 -07:00
Todd C. Miller
cebd92a88e Fix a potential crash when getpwnam() of the running user fails
and we don't replace the negative cached entry with a faked up one.
From Stephane Chazelas
2015-02-05 11:17:26 -07:00
Todd C. Miller
59ab26dbcc Go back to a 2 args debug_decl and just use the "default" instance,
now renamed "active".
2015-02-01 08:24:49 -07:00
Todd C. Miller
e9914a91b1 The sudoers plugin now defines its own list of debugging subsystem names
and defines.
2014-10-22 13:30:52 -06:00
Todd C. Miller
866cfc4fc3 Add support for multiple Debug lines per program. Callers may
register arbitrary debug facilities or use built-in defaults.  We
now use separate Debug statements for plugins and programs.
2014-10-22 13:23:05 -06:00
Todd C. Miller
36a5767e3e efree -> sudo_efree for consistency 2014-07-10 15:35:04 -06:00
Todd C. Miller
a8fa112a53 atobool -> sudo_strtobool
atoid-> sudo_strtoid
atomode -> sudo_strtomode
2014-06-27 14:53:54 -06:00
Todd C. Miller
2d61d38c23 Add sudo_ prefix to alloc.c functions and rename alloc.h -> sudo_alloc.h 2014-06-27 10:48:31 -06:00
Todd C. Miller
aecef4aa1d Rename warning/fatal -> sudo_warn/sudo_fatal to avoid namespace
pollution in libsudo_util.so.
2014-06-27 09:30:52 -06:00
Todd C. Miller
2d1484fe84 Make a password/group cache collision a warning rather than fatal.
This should not be possible in practice and we can safely return
the new (potentially duplicate) item as it will be freed by the
caller.  Make sudo_set_grlist() return an error on failure instead
of calling fatalx().
2014-03-26 16:44:29 -06:00
Todd C. Miller
e1ac1a2ff3 Use atoid() not atoi() when parsing uids/gids. 2013-12-05 15:51:56 -07:00
Todd C. Miller
2508da6f68 Better match debugging.
Sprinkle const in match functions.
2013-12-05 14:34:56 -07:00
Todd C. Miller
96eb2c4f8f Add warning_gettext() wrapper function that changes to the user locale,
then calls gettext().
Add U_ macro that calls warning_gettext() instead of gettext().
Rename warning2()/error2() back to warning_nodebug()/error_nodebug().
2013-11-18 08:59:57 -07:00
Todd C. Miller
5337da144b Replace sudo_fakepwnamid() with sudo_mkpwent() and don't return an
error if the entry already exists in the cache.
2013-04-19 14:48:23 -04:00
Todd C. Miller
39acd2fcba Rename error/errorx -> fatal/fatalx and remove the exit value as
it was always 1.
2013-04-18 14:07:59 -04:00
Todd C. Miller
c66cf7c87e cosmetic fixes 2013-03-27 11:29:58 -04:00
Todd C. Miller
b729284df9 Update copyright year. 2013-03-26 13:29:05 -04:00
Todd C. Miller
6e50087010 Add sudo_set_grlist(), currently unused by the back end. 2013-03-26 13:27:51 -04:00
Todd C. Miller
cee83cbf2d Remove unused macros, fix a debug_decl 2013-03-26 13:26:59 -04:00
Todd C. Miller
1d7072fe09 Don't include <sys/param.h>. We only needed it for MAXPATHLEN,
MAXHOSTNAMELEN and the MIN/MAX macros.  We now use PATH_MAX and
HOST_NAME_MAX throughout without falling back on MAXPATHLEN or
MAXHOSTNAMELEN and define our own MIN/MAX macros as needed.
2012-12-04 10:40:47 -05:00
Todd C. Miller
883e0ec3cc Split out implementation-specific back end code out of pwutil.c
into pwutil_impl.c.  This will allow the main pwutil code to be
used for lookup methods other than getpw* and getgr*.
2012-09-21 16:25:01 -04:00
Todd C. Miller
1cd50d0bce Defer group ID to name resolution until we actually need it. 2012-06-27 16:50:56 -04:00