Commit Graph

12419 Commits

Author SHA1 Message Date
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
Todd C. Miller
2a4939a1c5 Merge pull request #279 from AtariDreams/bison
Regenerate toke.c using updated flex
2023-07-01 10:23:40 -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
Todd C. Miller
1ba61cd13a No need to round up to page size with sudo_mmap_alloc(). 2023-06-29 10:17:39 -06:00
Todd C. Miller
f437c66a2a Merge pull request #265 from AtariDreams/types
Avoid compiler casting warnings by assigning to variables of the same type where possible
2023-06-29 10:06:30 -06:00
Todd C. Miller
e0238ab210 Merge pull request #277 from AtariDreams/debug_return_int(1);
We should be returning 0, not 1, when logservd finishes without errors
2023-06-29 09:50:20 -06:00
Rose
2c13d7130c We should be returning 0, not 1, when logservd finishes without errors
1 is for failure, 0 is for no failure, and this does not look like a failure.
2023-06-28 17:27:13 -04: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
a0b074cc9c Fix undefined symbol on macOS for intercept mode and log_subcmds.
macOS does not support direct access to the environ pointer from a
shared object.  We need to redirect through _NSGetEnviron() instead.
Fixes GitHub issue #276.
2023-06-28 10:59:26 -06: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
Todd C. Miller
a2a87323eb Merge pull request #275 from AtariDreams/emergency
Set command_info to NULL once it is freed
2023-06-26 13:52:48 -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
Todd C. Miller
676066e2aa Merge pull request #274 from bin-ly/main
Modify the is_script function for match_command.c
2023-06-25 07:55:54 -06:00
binlingyu
f8a45e8a54 Modify the is_script function for match_command.c 2023-06-25 11:15:17 +08:00
Todd C. Miller
7fb98a9a33 Mention C99 requirement. 2023-06-21 07:56:17 -06:00
Todd C. Miller
e0ee845dfc Reference SETENV-related settings in the command environment section.
Based on GitHub PR #273 from Ilya Kulakov.
2023-06-20 15:12:43 -06:00
Todd C. Miller
733d5291b4 Sudo requires a C99 compiler due to the use of flexible array members. 2023-06-20 13:39:10 -06: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
5d2b1761f6 Clarify that use_pty is on by default starting with 1.9.14. 2023-06-18 12:44:57 -06:00
Todd C. Miller
afb09e0044 Sudo runs the command in a pty by default in 1.9.14 and above. 2023-06-18 08:08:32 -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
64b666471a Update Xcode version from 13.2.1 to 13.4.1. 2023-06-15 11:24:44 -06:00
Todd C. Miller
dc49e11fa5 Add plugins/sudoers/regress/testsudoers/passwd to MANIFEST. 2023-06-14 12:48:05 -06:00
Todd C. Miller
c5c589da04 Updated translations from translationproject.org 2023-06-14 11:08:57 -06:00
Todd C. Miller
4f9185f4c5 Document recent bug fixes. 2023-06-14 11:08:24 -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