Todd C. Miller
cb63ca701c
Avoid using exiting allocators in the front end.
2015-06-17 17:00:54 -06: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
29039859b7
Defer registration of the SIGCHLD handler until just before we exec
...
the command. Fixes a problem where pam_gnome_keyring installs its
own SIGCHLD handler and may not restore the original one. As a
result, we now have to explicitly wait for the askpass helper to
finish. Bug #657
2014-11-18 14:05:51 -07:00
Todd C. Miller
21166d4da9
Make sure that SIGCHLD is not treated as a user-generated signal
...
in which case it could be ignored. Bug #676
2014-11-04 09:24:41 -07:00
Todd C. Miller
17a2a27e46
Use generic bitmap macros instead of select-style fd_set.
2014-10-23 14:37:27 -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
328c563791
Check return value of sigaction(), even though it should never fail.
2014-09-04 10:13:26 -06:00
Todd C. Miller
0546f0b6a2
Convert a debug printf to a user-visible warning.
2014-08-31 20:32:18 -06:00
Todd C. Miller
cfa4cebf13
Remove signal_event from evbase before calling sudo_ev_loopexit()
...
when the command has exited or been killed. It is possible that
we could receive another signal on the pipe if they are delivered
out of order.
2014-08-30 16:24:53 -06:00
Todd C. Miller
ae0014d6f4
Attempt to handle systems with SA_SIGINFO but that lack SI_USER.
2014-07-28 20:25:46 -06:00
Todd C. Miller
36a5767e3e
efree -> sudo_efree for consistency
2014-07-10 15:35:04 -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
826e190f31
Ignore signals sent by the command's process group, not just the
...
command itself. If we cannot determine the process group ID of the
sender (as it may no longer exist), just check the process ID.
2014-05-28 09:50:14 -06:00
Todd C. Miller
b121da2e21
In handler_user_only() only forward the signal if it was not generated
...
by the command. This should fix a problem with programs that catch
SIGTSTP, perform cleanup, and then re-send the signal to their
process group (of which sudo is the leader).
2014-05-27 10:51:31 -06:00
Todd C. Miller
d628e17ead
Handle EINTR from write(2) when writing to pipes and socket pairs.
2014-05-27 10:16:49 -06:00
Todd C. Miller
36b991348c
Forward SIGINFO to running command if supported. If the command
...
is being run in the background (or exec_background is set in sudoers),
it is the sudo process, not the actual command, that receives the ^T.
2014-04-04 15:30:15 -06:00
Todd C. Miller
640a5ddb48
If the event loop exits due to an error and we are not logging I/O,
...
kill the command if still running. Fixes a bug where sudo could
exit while the command was still running.
2014-01-14 20:34:20 -07:00
Todd C. Miller
d7277fc96e
If not logging I/O we may get EOF when the command is executed and
...
the other end of the backchannel is closed. Just remove the
backchannel event in this case or we will continue to receive
the event. Bug #631
2014-01-14 10:54:56 -07:00
Todd C. Miller
27598bc0ab
Update copyright year.
2014-01-07 10:43:31 -07:00
Todd C. Miller
d013b23ce3
If invoked as sudoedit we can't just exec the command directly since
...
the temporary files need to be updated before sudo exits.
2014-01-03 16:41:25 -07:00
Todd C. Miller
1adeda54ef
Add support for preventing fds from getting clobbered by closefrom().
2013-12-20 11:14:32 -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
99b7351de0
Fix some #if vs. #ifdef and remove an extraneous semicolon.
...
Bug #624 ; from Daniel Richard G.
2013-11-17 16:15:36 -07:00
Todd C. Miller
fd88ed42c8
Use MSG_WAITALL when receiving struct command_status over the Unix
...
domain socket since we no longer use datagrams. This should avoid
the need to handle incomplete reads, though in theory it is still
possible.
2013-10-29 15:26:32 -06:00
Todd C. Miller
8861e01d16
Add support for libevent-style timed events. Adding a timed event
...
is currently O(n). The only consumer of timed events is sudoreplay
which only used a singled one so O(n) == O(1) for now. This also
allows us to remove the nanosleep compat function as we now use a
timeout event instead.
2013-10-28 10:00:09 -06:00
Todd C. Miller
d8b368b503
Now that sudo_ev_base_free() removes all events before freeing we
...
don't need to do this by hand.
2013-10-26 07:52:59 -06:00
Todd C. Miller
e8ce021e7d
Quiet some llvm check false positives. The common idiom of using
...
TAILQ_FIRST, TAILQ_REMOVE and free in a loop to free each entry in
a TAILQ confuses llvm. Use TAILQ_FOREACH_SAFE instead (which is
probably faster anyway).
2013-10-22 14:58:00 -06:00
Todd C. Miller
923edabe6c
Convert sudo to use BSD TAILQ macros instead of home ground tail
...
queue functions. This includes a private queue.h header derived
from FreeBSD. It is simpler to just use our own header rather than
try to deal with macros that may or may not be present in various
queue.h incarnations.
2013-10-22 09:00:37 -06:00
Todd C. Miller
83d2d25c4c
Convert the main sudo event loop to use the event subsystem.
...
Read events for I/O buffers are added before the loop starts.
Write events are added on demand as the buffers are filled.
2013-10-12 05:53:52 -06:00
Todd C. Miller
ff18c65862
Use SOCK_STREAM for socketpair, not SOCK_DGRAM so we get consistent
...
semantics when the other end closes. This should make the conversion
to poll() less problematic.
2013-10-12 05:39:02 -06:00
Todd C. Miller
299a881fe2
If not using a pty and the child process gets SIGTTOU or SIGTTIN
...
and sudo is the foreground process, make the child the foreground
process and continue it.
2013-08-14 16:36:41 -06:00
Todd C. Miller
d6282d154a
Update copyright years.
2013-04-24 09:35:02 -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
eb2259bc12
Move exec_cmnd to exec.c to fix a compilation issue with sesh.c
2013-03-14 19:59:07 -04:00
Todd C. Miller
5cb928c512
If the policy plugin does not provide a close function, there is
...
no command timeout and no pty is required, skip the event loop and
just exec the command directly.
2013-02-23 14:19:07 -05:00
Todd C. Miller
e764604485
Remove extra flag to sudo_sigaction(). We want to trap the signal
...
regardless of whether or not it is ignored by the underlying command
since there's no way to know what signal handlers the command will
install. Now we just use sudo_sigaction() to set a flag in
saved_signals[] to indicate whether a signal needs to be restored
before exec.
2013-01-19 15:10:01 -05:00
Todd C. Miller
855a11af2b
Move signal code into its own source file and add sudo_sigaction()
...
wrapper that has an extra flag to check the saved_signals list to
only install the handler if the signal is not already ignored.
Bump plugin API version for the new front-end signal behavior.
2013-01-17 13:29:46 -05:00
Todd C. Miller
99704cc101
Catch SIGINT, SIGQUIT and SIGTSTP in the front end before we execute
...
the command. If we get SIGINT or SIGQUIT, call the plugin close()
functions as if the command was interrupted. If we get SIGTSTP,
uninstall the handler and deliver SIGTSTP to ourselves.
2013-01-17 09:20:45 -05:00
Todd C. Miller
541315212e
Rename handle_signals() to dispatch_signals().
...
Block other signals in handler() so we don't have to worry about
the write() being interrupted.
2013-01-17 09:17:54 -05:00
Todd C. Miller
d129290ec3
Print SIGCONT_FG and SIGCONT_BG properly in debug output.
2012-12-28 11:01:36 -05: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
7b3d268687
Call gettext() on parameters for warning()/warningx() instead of
...
having warning() do it for us.
2012-11-25 09:34:04 -05:00
Todd C. Miller
acf8af9aac
#unifdef HAVE_SETLOCALE, it is C89 so no need to check for it.
2012-11-12 08:51:58 -05:00
Todd C. Miller
c1db4b1546
Always include locale.h from gettext.h so we no longer need to
...
include locale.h from the .c files.
2012-11-11 20:23:53 -05:00
Todd C. Miller
595d3b2651
Display warning/error messages in the user's locale.
2012-11-08 15:37:44 -05:00
Todd C. Miller
885b6e7cda
When setting the signal handler for SIGTSTP to the default value
...
in non-I/O log mode, store the old handler value for when we restore
it after resume.
2012-09-16 18:40:39 -04:00
Todd C. Miller
ae21fb299d
Silence compiler warnings.
2012-08-29 14:40:25 -04:00
Todd C. Miller
ab7dda035a
Replace strsigname() with sig2str(), emulating it as needed.
2012-08-29 14:25:09 -04:00
Todd C. Miller
37269d662a
Pass on SIGTSTP to the command if it was sent by a user process
...
(not the kernel or the terminal) when we are not I/O logging and
set the default SIGTSTP handler when we re-send the signal to
ourself, restoring our handler after we resume.
2012-08-27 11:22:33 -04:00