Commit Graph

3630 Commits

Author SHA1 Message Date
Todd C. Miller
a38b714667 sudoers plugin: silence most -Wconversion warnings. 2023-07-07 15:07:04 -06:00
Todd C. Miller
0205f6fc75 sudoers_check_common: remove extraneous return statement. 2023-07-07 14:54:10 -06:00
Todd C. Miller
43e914a5d3 Copy, don't append group ID in fill_group() and fill_runas_group()
This only affects the case where a group ID cannot be resolved.
2023-07-05 11:49:07 -06:00
Todd C. Miller
2848dddd87 Rename print_usage() to display_usage() 2023-07-04 19:48:41 -06:00
Todd C. Miller
fd061e4d69 Include testsudoers_pwutil.h for testsudoers_pwutil.c prototypes. 2023-07-04 16:24:48 -06:00
Todd C. Miller
f1d9063477 Fix wrapping of libc getpwnam/getpwuid/getgrnam/getgrgid on NetBSD. 2023-07-04 14:14:07 -06:00
Rose
cbed9daa46 Fixed even more signedness and conversion issues
This should be the last of them.
2023-07-03 22:07:35 -04:00
Todd C. Miller
e95bd883d7 Promote length/size/offset in struct connection_buffer to size_t. 2023-07-03 17:02:24 -06:00
Todd C. Miller
56a431f7ea Make sudo_pow2_roundup() operate on size_t. 2023-07-03 16:51:05 -06:00
Todd C. Miller
b926df1df2 Make the debug subsystem unsigned.
It was already unsigned in sudoers but not in the front-end or the
python plugin.  Making this consistent resolves a lot of -Wconversion
warnings.  Also clean up some other -Wconversion warnings in sudo_debug.c.
2023-07-01 16:14:50 -06:00
Todd C. Miller
04c7e910ef Fix up indentation. 2023-07-01 16:03:33 -06:00
Rose
45fdfa18f1 Mark functions not returning as sudo_noreturn
We also put NOTREACHED where it applies.
2023-07-01 17:40:16 -04:00
Todd C. Miller
97e574091a Avoid passing debug_return_size_t() a negative number. 2023-07-01 10:39:25 -06:00
Rose
6ea68d208e Regenerate toke.c using updated flex
Use the current version of flex to generate toke.c
2023-07-01 11:47:04 -04:00
Todd C. Miller
5fbf431c42 Fix a few memory leaks in the tests. 2023-06-30 19:08:04 -06:00
Todd C. Miller
ac9b6c94d9 Add test for runas_check_shell and check_user_shell() 2023-06-30 10:43:39 -06:00
Todd C. Miller
bdc8a7f35e testsudoers: add -D and -R options to set cwd and chroot like sudo 2023-06-30 10:43:37 -06:00
Todd C. Miller
01ad570e24 Move check_user_* functions to check_util.c so testsudoers can use them. 2023-06-30 10:43:18 -06:00
Todd C. Miller
689efe3cdd testsudoers: make lbuf private to dump_sudoers()
It is no longer used directly in main.
2023-06-29 20:17:22 -06:00
Todd C. Miller
260c2fb835 testsudoers: display "Parse error" if there was a parse error.
Previously, we just printed "Command unmatched" which makes it
harder to see that an error occurred.
2023-06-29 20:10:15 -06:00
Todd C. Miller
6a21aec0a6 testsudoers: use allowed/denied/unmatched instead of just matched/unmatched
This makes it possible to tell whether an entry was rejected due
to a negative match (explicitly denied) as opposed to a non-match.
Also fixes a bug where the runas status was only printed for positive
matches.
2023-06-29 20:02:32 -06:00
Todd C. Miller
fd25bfc892 testsudoers: use sudoers_lookup() instead of a custom loop. 2023-06-29 17:31:55 -06:00
Todd C. Miller
e025cca440 Add callbacks to sudoers_lookup() so we can use it in testsudoers.
Also pass in the time to be used for NOTBEFORE/NOTAFTER checks.
2023-06-29 17:30:39 -06:00
Todd C. Miller
41b82006de Merge pull request #278 from AtariDreams/types
Avoid compiler casting warnings Part 2
2023-06-29 12:26:07 -06:00
Todd C. Miller
1c7a20d744 check_user_runcwd: only allow sudo's -D option if sudoers specifies a runcwd.
Previously, the user could specify the runas user's home dir for
"sudo -i" or the user's existing cwd when -i is not specified.
This behavior was never documented and is inconsistent with how
the -R option is handled.
2023-06-29 11:24:04 -06:00
Todd C. Miller
2c1a473ddc testsudoers: add support for NOTBEFORE and NOTAFTER
Also adds -T option to set the value of "now".
2023-06-29 11:13:01 -06:00
Rose
22079c3072 Avoid compiler casting warnings Part 2
This saves instructions that are related to casting as well as compiler warnings.
2023-06-29 13:10:27 -04:00
Todd C. Miller
f2a274b061 Rename parse.c -> lookup.c now that it only contains sudoers_lookup. 2023-06-29 10:52:44 -06:00
Todd C. Miller
8b640329d3 Split display_privs() and display_cmnd() out of parse.c into display.c 2023-06-29 10:31:09 -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
e7d4c05ace check_user_runcwd: allow -D option if it matches the cwd in sudoers
Previously, check_user_runcwd() would return true if the runcwd
matched the user's cwd, even if sudoers specified a different one.
The user-specified runcwd was ignored but it is better to error out
in this case.  It is now also possible to use "sudo -D" with the
directory specified in sudoers.
2023-06-28 09:59:33 -06:00
Rose
0bb41ed82a Set command_info to NULL once it is freed
The lack of setting to NULL is a holdover from when command_info was a local variable and not a global one. However, we given how other global variables are set to NULL, it is best that we do the same here to avoid potential issues should sudoers_policy_store_result be called again after the first time failed, otherwise we could get a double-free.
2023-06-26 15:08:51 -04:00
binlingyu
f8a45e8a54 Modify the is_script function for match_command.c 2023-06-25 11:15:17 +08:00
Todd C. Miller
3bdd2214ad Merge pull request #266 from AtariDreams/c99
Do variable length arrays the C99 way
2023-06-20 13:29:30 -06:00
Todd C. Miller
69b486d462 Merge pull request #269 from trackers-lover/main
correct the return value type of function alias_find_used
2023-06-19 10:39:59 -06:00
Todd C. Miller
4da1f373de Add commented out example for disabling use_pty. 2023-06-18 08:03:46 -06:00
Rose
7fd680c983 Do variable length arrays the C99 way
Variable length arrays are supported by C99, but having it denoted as "1" confused the compiler and is not defined.

Note that because we don't get the inferred NULL terminator, we have to increase the malloc size by one.
2023-06-15 15:25:17 -04:00
Todd C. Miller
c5c589da04 Updated translations from translationproject.org 2023-06-14 11:08:57 -06:00
Todd C. Miller
baf482763c Add tests to exercise recent runas user and group bug fixes. 2023-06-14 10:29:07 -06:00
Todd C. Miller
0d17325039 Add test to exercise the bug that prevented the group specified via
"sudo -g" from matching when a Runas_Alias was used in the user or
group portion of a Runas_Spec.
2023-06-14 10:15:38 -06:00
Todd C. Miller
78e65e14ea runaslist_matches: split out user_list and group_list matching.
This makes it possible to call the appropriate runas user or group
list match function when resolving aliases instead of calling
runaslist_matches() itself.  Fixes a bug that prevented the group
specified via "sudo -g" from matching when a Runas_Alias was used
in the user or group portion of a Runas_Spec.
2023-06-13 20:13:24 -06:00
Todd C. Miller
4710283516 runaslist_matches: fix bug when no runas list is specified in sudoers.
If a sudoers rule has no runas list, a user-specified runas group
should only be allowed if it matches a group that the default runas
user belongs to.  Instead, a missing group check allowed the user
run commands as the default runas user with an arbitrary group.

This means that a rule like "somebody host = ALL", which should be
equivalent to "somebody host = (root) ALL", had the same effect as
"somebody host = (root:ALL) ALL".
2023-06-13 10:29:00 -06:00
Todd C. Miller
8c1559e0e3 runaslist_matches: remove special case to handle "sudo -g group"
Now that we are guaranteed to have a runas user list for all sudoers
rules that contain a runas list, we can remove support for the
special case where user_matched is set in the runas group matching
conditional.  This fixes a bug where "sudo -u myuser -g mygroup"
was permitted by a rule like "myuser ALL = (root) ALL".
2023-06-13 16:03:25 -06:00
Todd C. Miller
64ab8cd236 Populate runasusers even when only a grouplist is specified.
When a sudoers rule permits the user to run commands as a group,
not a user, we should set the runasusers to single member with the
special MYSELF token.  This guarantees that the only time runasusers
will be NULL is when no runaslist is present.
2023-06-13 15:46:46 -06:00
Todd C. Miller
a28d2d4128 Python may be built with 32-bit time_t support on 32-bit platforms.
We need to undef the SIZEOF_TIME_T from pyconfig.h so it does not
conflict with our own.
2023-06-11 14:05:02 -06:00
bianguangze
b4dcac650f correct the return value type of function alias_find_used 2023-06-09 09:46:05 +08:00
Todd C. Miller
5baf817dbc Updated translations from translationproject.org 2023-06-07 13:29:23 -06:00
Todd C. Miller
2c58d80751 Update .pot files for 1.9.14 2023-06-07 13:27:47 -06:00
Todd C. Miller
3786654dbd Add NETGROUP_QUERY option for servers that can't match nisNetgroupTriple.
This can be used to support netgroup queries on systems that lack
the innetgr() function and where the LDAP server cannot query the
nisNetgroup by nisNetgroupTriple.
2023-06-07 10:10:52 -06:00
Todd C. Miller
6fddb2875c sudo_ldap_check_non_unix_group: pass nss pointer to netgr_matches()
This allows us to use the LDAP-specific version of innetgr() when
possible.  Also enable "use_netgroups" by default even on systems
without innetgr() since we can now query netgroups directly via
LDAP.
2023-06-06 19:55:06 -06:00