2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 13:58:05 +00:00
Commit Graph

13161 Commits

Author SHA1 Message Date
Todd C. Miller
7a10cdc286 _python_plugin_new_interpreter switches to the new interpreter
No need to do PyThreadState_Swap in the caller.
2023-07-20 06:58:53 -06:00
Todd C. Miller
cc939297a1 Call PyImport_AppendInittab after pre-initialization.
Also remove redundant PyConfig settings.
2023-07-19 09:13:23 -06:00
Todd C. Miller
da60384ad8 Use Py_InitializeFromConfig() not Py_InitializeEx() for Python >= 3.8.
Avoids deprecation warnings on Python 3.12.
2023-07-18 20:18:38 -06:00
Todd C. Miller
7facc380a3 The sudoers option is "use_pty", not "log_pty"
GitHub issue #291

--HG--
branch : 1.9
2023-07-18 07:26:53 -06:00
Todd C. Miller
aa7f77edd8 Merge sudo_module_register_loghandler and sudo_module_set_default_loghandler.
We now create the LogHandler class for each interpreter in
python_plugin_init() instead of just once in sudo_module_init().
This fixes the crash seen in Py_EndInterpreter() with Python 3.12
and significantly reduces the number of leaked objects tracked by
MemorySanitizer.

--HG--
branch : 1.9
2023-07-24 11:07:45 -06:00
Todd C. Miller
32ac7d4d63 sudo_module_register_loghandler: clear sudo_type_LogHandler on error
Also add comments about PyModule_AddObject stealing a ref on success.

--HG--
branch : 1.9
2023-07-22 08:33:04 -06:00
Todd C. Miller
2b0643f6a2 Work around a crash with Python 3.12.
In sudo_module_set_default_loghandler() if we don't leak the reference
to py_loghandler we get a crash in Py_EndInterpreter() with Python
3.12.  This probably indicates a reference counting bug elsewhere.

--HG--
branch : 1.9
2023-07-21 12:20:18 -06:00
Todd C. Miller
28b05ea8f9 Use PyObject_CallNoArgs() where possible.
--HG--
branch : 1.9
2023-07-21 10:47:28 -06:00
Todd C. Miller
1143431421 Make sudo_type_ConvMessage and sudo_type_LogHandler static.
They are not used outside their respective compilation units.

--HG--
branch : 1.9
2023-07-21 10:46:16 -06:00
Todd C. Miller
46159d2844 Adapt to changed formatting of a rejected result in Python 3.12
--HG--
branch : 1.9
2023-07-20 07:46:28 -06:00
Todd C. Miller
58cd8e2302 Remove trailing whitespace from test output.
--HG--
branch : 1.9
2023-07-20 06:57:19 -06:00
Todd C. Miller
8aeb76f7f2 Use Py_InitializeFromConfig() not Py_InitializeEx() for Python >= 3.8.
Avoids deprecation warnings on Python 3.12.

--HG--
branch : 1.9
2023-07-18 20:18:38 -06:00
Todd C. Miller
0efdd7632a The sudoers option is "use_pty", not "log_pty"
GitHub issue #291
2023-07-18 07:26:53 -06:00
Todd C. Miller
4b5480cf76 Quiet a warning false positive with older versions of gcc. 2023-07-17 11:23:04 -06:00
Todd C. Miller
fa66c16689 sudoers_check_common: MODE_PRESERVE_ENV is not valid with MODE_CHECK.
We should only check for MODE_PRESERVE_ENV when running a command.
2023-07-17 10:52:23 -06:00
Todd C. Miller
5a6f0d5b19 Added tag SUDO_1_9_14p2 for changeset 47c0bf9a7ebb
--HG--
branch : 1.9
2023-07-15 09:41:19 -06:00
Todd C. Miller
2a3b848e4f sudo 1.9.14p2
--HG--
branch : 1.9
SUDO_1_9_14p2 v1.9.14p2
2023-07-15 09:41:12 -06:00
Todd C. Miller
c29a27e840 Document bug fixes in 1.9.14p2. 2023-07-14 15:29:52 -06:00
Todd C. Miller
db704c22ec runas_userlist_matches: fix matching a Runas_Spec with an empty runas user.
We should only match a rule with an empty runas user if a group was
specified on the command line (sudo -g) without a user (no -u option)
or the user specified their own name on the command line.
GitHub issue #290
2023-07-15 08:44:57 -06:00
Todd C. Miller
181b639fbe Document bug fixes in 1.9.14p2.
--HG--
branch : 1.9
2023-07-14 15:29:52 -06:00
Todd C. Miller
23fc7abfad runas_userlist_matches: fix matching a Runas_Spec with an empty runas user.
We should only match a rule with an empty runas user if a group was
specified on the command line (sudo -g) without a user (no -u option)
or the user specified their own name on the command line.
GitHub issue #290

--HG--
branch : 1.9
2023-07-15 08:44:57 -06:00
Todd C. Miller
78b712101e Pass SUDO_TERM_OFLAG to sudo_term_raw() when sudo output is piped.
This fixes a problem with "stair-stepped" output when the sudo-run
command's output is piped to another program and the command reads
input from the terminal.
2023-07-14 14:12:18 -06:00
Todd C. Miller
d821e8da3b Pass SUDO_TERM_OFLAG to sudo_term_raw() when sudo output is piped.
This fixes a problem with "stair-stepped" output when the sudo-run
command's output is piped to another program and the command reads
input from the terminal.

--HG--
branch : 1.9
2023-07-14 14:12:18 -06:00
Todd C. Miller
db4bdb7327 Simplify the exec_monitor() foreground flag.
Add cmnd_foreground flag that is only true if sudo is the foreground
process and the CD_EXEC_BG flag is not set and pass it to exec_monitor().
This means exec_monitor() no longer needs to check for CD_EXEC_BG.
2023-07-14 14:08:59 -06:00
Todd C. Miller
9cdebcf907 Simplify the exec_monitor() foreground flag.
Add cmnd_foreground flag that is only true if sudo is the foreground
process and the CD_EXEC_BG flag is not set and pass it to exec_monitor().
This means exec_monitor() no longer needs to check for CD_EXEC_BG.

--HG--
branch : 1.9
2023-07-14 14:08:59 -06:00
Todd C. Miller
625653de08 sudo_term_raw: change the isig argument into a flags field
There are current two flags: SUDO_TERM_ISIG (enable terminal signals)
and SUDO_TERM_OFLAG (preserve output flags).
2023-07-14 13:12:51 -06:00
Todd C. Miller
77f209e145 sudo_term_raw: change the isig argument into a flags field
There are current two flags: SUDO_TERM_ISIG (enable terminal signals)
and SUDO_TERM_OFLAG (preserve output flags).

--HG--
branch : 1.9
2023-07-14 13:12:51 -06:00
Todd C. Miller
ff6ddff39b Fix a crash in intercept mode running a command with NULL argv[0].
Newer Linux kernels replace a NULL argv[0] with the empty string,
we should as well.
2023-07-12 09:29:00 -06:00
Todd C. Miller
24cc3f4c91 Fix a crash in intercept mode running a command with NULL argv[0].
Newer Linux kernels replace a NULL argv[0] with the empty string,
we should as well.

--HG--
branch : 1.9
2023-07-12 09:29:00 -06:00
Todd C. Miller
b47f1799c5 sudo_conversation_printf: simplify \n -> \r\n handling 2023-07-12 08:39:18 -06:00
Todd C. Miller
a014b0f2aa sudo_conversation: zero out reply even if no password is requested.
This avoids a potential invalid free in the err label and provides
more predictable behavior when mixing message types in a conversation.
2023-07-12 08:16:35 -06:00
Todd C. Miller
8f3b92ee89 Added tag SUDO_1_9_14p1 for changeset fc033946b1a9
--HG--
branch : 1.9
2023-07-11 14:27:13 -06:00
Todd C. Miller
e1b4d21a23 sudo 1.9.14p1
--HG--
branch : 1.9
SUDO_1_9_14p1 v1.9.14p1
2023-07-11 14:26:52 -06:00
Todd C. Miller
9afb1851b2 Docume bug fixes in 1.9.14p1. 2023-07-11 14:24:42 -06:00
Todd C. Miller
696094c0e1 Docume bug fixes in 1.9.14p1.
--HG--
branch : 1.9
2023-07-11 14:24:42 -06:00
Todd C. Miller
56828f6412 fmt_info_messages: don't include ttyname if it is NULL
The NULL check was commented out for testing but should have been
restored.  Fixes a potential protocol error message from sudo_logsrvd.
2023-07-11 14:15:46 -06:00
Todd C. Miller
ff5f68f2e2 fmt_info_messages: don't include ttyname if it is NULL
The NULL check was commented out for testing but should have been
restored.  Fixes a potential protocol error message from sudo_logsrvd.

--HG--
branch : 1.9
2023-07-11 14:15:46 -06:00
Todd C. Miller
2eee45ef96 evlog_new: store a new copy of peeraddr, not a pointer to a buffer.
Starting in sudo 1.9.14, eventlog_free() will free the peeraddr
member too so it needs to be dynamically allocated.
2023-07-11 13:51:16 -06:00
Todd C. Miller
ac830c558d evlog_new: store a new copy of peeraddr, not a pointer to a buffer.
Starting in sudo 1.9.14, eventlog_free() will free the peeraddr
member too so it needs to be dynamically allocated.

--HG--
branch : 1.9
2023-07-11 13:51:16 -06:00
Todd C. Miller
a432aed4f0 realpath.c: include limits.h and use sysconf(_SC_SYMLOOP_MAX)
This is more portable and eliminates the need to check for SYMLOOP_MAX
(and provide it if missing) in configure.  Also quiet some -Wconversion
warnings.
2023-07-10 15:52:16 -06:00
Todd C. Miller
dc1a5d7b40 sudo_krb5_ccname_path: avoid gcc false positive for ccname being NULL
The callers all verify that they don't pass a NULL ccname so I'm
not sure how the compiler is getting confused (and why now?).
2023-07-10 15:21:31 -06:00
Todd C. Miller
c6a11b4fed Work around unused variable warning when fuzzing in enabled. 2023-07-10 14:50:21 -06:00
Todd C. Miller
d1625f9c83 Only allow the user to specify -D or -R for the special "*" value.
The sudoers file must now explicitly allow the user to specify a
directory (sudo -D) or chroot (sudo -R) by setting cwd or chroot
to "*".  If a specific cwd or chroot value is set in sudoers, the
user may not use the -D or -R options, even if they match the value
in sudoers.
2023-07-10 14:30:40 -06:00
Todd C. Miller
44cfa9e132 Add restrict keyword to sudo_printf_t in plugin docs. 2023-07-10 14:30:39 -06:00
Todd C. Miller
db6baf2caf Convert sudo_debug_enter and sudo_debug_exit into macros.
In most cases, these simply expand to a call to sudo_debug_printf2().
We need to keep the function versions around in libsudo_util for
backwards compatibility.
2023-07-10 14:30:38 -06:00
Todd C. Miller
2d12a41940 Fix sudo_debug_exit_uint_v1 declaration for fuzzers. 2023-07-10 11:27:28 -06:00
Todd C. Miller
eff4e1c0c5 Add missing sudo_debug_exit_uint_v1 stub for fuzzers. 2023-07-10 11:23:06 -06:00
Todd C. Miller
dbb95ad214 sudo frontend: make more bit flags unsigned. 2023-07-10 11:06:34 -06:00
Todd C. Miller
cbcb1d2506 sudoers plugin: make more bit flags unsigned. 2023-07-10 11:06:23 -06:00
Todd C. Miller
4f097eebd3 libsudo_util: make more bit flags unsigned. 2023-07-10 11:06:04 -06:00