Commit Graph

12536 Commits

Author SHA1 Message Date
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
Todd C. Miller
ac46157e94 Merge pull request #272 from millert/main
Avoid use of variable length arrays and add ctype(3) casts.
2023-06-10 11:15:35 -06:00
Todd C. Miller
8fbdd414ce Avoid use of variable length arrays and add ctype(3) casts. 2023-06-10 10:48:53 -06:00
Todd C. Miller
ee4f210f32 Merge pull request #270 from moehanabi/main
Add %n$s support for sudo_lbuf_append_v1
2023-06-10 10:28:45 -06:00
Brilliant Hanabi
932339ed9f Add %n$s support for sudo_lbuf_append_v1 2023-06-09 23:20:39 +08: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
2077b51574 Mention Bug #1050 fix. 2023-06-07 11:31:20 -06:00
Todd C. Miller
c7070b0475 sudo 1.9.14 2023-06-05 13:13:37 -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
Todd C. Miller
245c56bac1 Only call ptrace_verify_post_exec() for intercept, not log_subcmds. 2023-06-05 16:03:03 -06:00
Todd C. Miller
2392ee9d7d run_command: back out changes to run editor in its own process group.
It unnecessarily complicates things to work around bugs in an OS
almost no one runs.
2023-06-04 19:11:48 -06:00
Todd C. Miller
95cd409079 Make suspend_parent.c out of lib/util and into src.
Nothing else uses it now.
2023-06-04 19:08:52 -06:00
Todd C. Miller
1278e36ff3 Initialize digest_type to SUDO_DIGEST_INVALID, not -1 and make it unsigned.
This makes the digest type consistently unsigned instead of a mix
of signed (for the -1 value in the tokenizer) and unsigned.
2023-06-03 08:59:14 -06:00
Todd C. Miller
d633d82f22 Fix typos and update excluded/ignored codespell lists. 2023-05-25 12:53:27 -06:00
Todd C. Miller
0986a8846e run_command: check that ttyfd is not -1 before using it 2023-05-19 13:38:48 -06:00
Todd C. Miller
4d417b46d9 Work around a macOS a kernel bug where tcsetpgrp() does not restart.
I reported this bug to Apple over 12 years ago.
2023-05-11 18:22:06 -06:00
Todd C. Miller
be20e1592f run_command: run editor in foreground if visudo is the foreground process
The command is now always run in its own process group.  If visudo
is run in the foreground, the command is run in the foreground too.
Otherwise, run the command in the background.  There is a race
between the tcsetpgrp() call in the parent and the execve() in the
child.  If we lose the race and the command needs the controlling
terminal, it will be stopped with SIGTTOU or SIGTTIN, which the
waitpid() loop will handle.
2023-05-11 18:20:50 -06:00
Todd C. Miller
7e28e60b56 Accept carriage return for EOL in addition to newline.
Since visudo doesn't alter the terminal settings it is possible for
the terminal to have the ONLCR bit set in the output control flags.
In that case, we will get a CR, not a NL when the user presses
enter/return.  One way this can happen is if visudo is run in the
background from a shell that supports line editing and the editor
restores the (cbreak-style) terminal mode when it finishes.
2023-05-11 18:12:54 -06:00
Todd C. Miller
91f100f5bc check_fill: sudoers_strict() is now a function, not a global variable 2023-05-09 14:16:17 -06:00
Todd C. Miller
f352ef5d67 Move parser prototypes / externs from sudoers.h to parse.h or toke.h. 2023-05-09 14:01:41 -06:00
Todd C. Miller
01ff7c476d parse.h is already included by sudoers.h. 2023-05-09 13:44:16 -06:00
Todd C. Miller
bde363e060 Rename parser_conf -> sudoers_conf in all but the parser itself. 2023-05-09 07:29:06 -06:00
Todd C. Miller
8cbd5462a6 Move sudoers search path to struct sudoers_parser_config.
That way we can avoid passing it to init_parser() directly.
We still need sudoers_search_path to be shared between the lexer
and the parser.
2023-05-08 17:04:38 -06:00
Todd C. Miller
9d7c30c5a8 Add struct sudoers_parser_config and pass it to init_parser().
This struct contains parser configuration such as the sudoers file
uid/gid/mode and parse flags such as verbose, strict and recovery.
2023-05-08 17:03:31 -06:00
Todd C. Miller
fb9d0d79a7 push_include_int: Avoid passing close(2) a negative value on error.
Coverity CID 314108
2023-05-08 14:18:56 -06:00
Todd C. Miller
f722272b7c Eliminate dead store. Coverity CID 315032. 2023-05-08 14:15:48 -06:00
Todd C. Miller
2f4b406809 iolog_gets: change size parameter to int to match fgets/gzgets
Return an error, setting errno to EINVAL, for negative sizes.
2023-05-05 10:20:21 -06:00
Todd C. Miller
c0fa3a4d24 Rename force_umask to override_umask and make it private to sudoers.c.
Add getter for policy.c.
2023-05-04 13:46:20 -06:00
Todd C. Miller
72489d7a83 Make timestamp_uid and timestamp_gid private to timestamp.c.
Add getter (for set_perms.c) and setter (for sudoers.c).
2023-05-04 13:08:23 -06:00
Todd C. Miller
d5de5890f5 Make login_style private to bsdauth.c
Add a setter for policy.c to handle auth_type from the front-end.
2023-05-04 13:06:09 -06:00
Todd C. Miller
cda03ed13f Back out last change, len must be int, not size_t, for %.*s. 2023-05-03 13:36:07 -06:00