Commit Graph

1652 Commits

Author SHA1 Message Date
Todd C. Miller
c2d0888bf9 No need to use pseudo-cbreak mode now that we use pipes when stdout is
not a tty.  Instead, check whether stdin is a tty and if not, delay
setting the tty to raw mode until the command tries to access it itself
(and receives SIGTTIN or SIGTTOU).
2010-05-10 17:23:35 -04:00
Todd C. Miller
cbb3010d73 Use an array for signals received instead of a single variable so
we don't lose any when there are multiple different signals.
2010-05-10 15:13:48 -04:00
Todd C. Miller
5adda153ae Do signal setup after turning off echo, not before. If we are using
a tty but are not the foreground pgrp this will generate SIGTTOU
so we want the default action to be taken (suspend process).
2010-05-10 15:02:50 -04:00
Todd C. Miller
23a9bf2c07 Flush the iobufs on suspend or child exit using the same logic
as the main event loop.
2010-05-07 10:15:25 -04:00
Todd C. Miller
b08a96eea7 Free memory after we are done with it. 2010-05-07 10:14:12 -04:00
Todd C. Miller
3cbbf27e9d Go back to reseting io_buffer offset and length (and now also the
EOF handling) in the loop we do the FD_SET, not after we drain the
buffer after write() since we don't know what order reads and writes
will occur in.
2010-05-05 16:11:13 -04:00
Todd C. Miller
b4d16ae1af Add support for logging stdin when it is not a tty.
There is still a bug where "cat | sudo cat" has problems because
both cat and sudo are trying to read from the tty.
2010-05-05 09:47:12 -04:00
Todd C. Miller
782f494003 Add separate I/O logging functions for tty in/out and stdin/stdout/stderr.
NOTE: stdin logging does not currently work and is disabled for now.
2010-05-05 07:29:28 -04:00
Todd C. Miller
9fbec34fed Add pointer to a printf like function to plugin open functon.
This can be used instead of the conversation function to display
info and error messages.
2010-05-04 19:17:31 -04:00
Todd C. Miller
e3f561668f Only set user's tty to blocking mode when doing the final flush.
Flush pipes as well as pty master when the process is done.
2010-05-04 09:09:12 -04:00
Todd C. Miller
0eda64b235 Do not need the opost flag to term_copy() now that we use pipes for
stdout/stderr when they are not a tty.
2010-05-03 10:41:26 -04:00
Todd C. Miller
dd256f25ca Use pipes to the sudo process if stdout or stderr is not a tty.
Still needs some polishing and a decision as to whether it is
desirable to add additonal entry points for logging stdout/stderr/stdin
when they are not ttys.  That would allow a replay program to keep
things separate and to know whether the terminal needs to be in raw
mode at replay time.
2010-05-03 10:12:54 -04:00
Todd C. Miller
5475020561 Move audit sources into the sudoers plugin dir; the driver does not use them. 2010-04-30 15:38:33 -04:00
Todd C. Miller
d346e50903 Use angle brackets when including headers that can only be found when
an -I flag is specified.  The files in the compat dir could get away
with double quotes here but I've converted all the source files
to use angle brackets for consistency.
2010-04-30 15:13:47 -04:00
Todd C. Miller
23f9bb59ec fmt_string is used by the sudoers plugin too so do not include sudo.h
(which is not really needed here anyway)
2010-04-30 13:40:57 -04:00
Todd C. Miller
5e9ec6a365 Fix building with non-BSD versions of make such as GNU make.
Requires VPATH support, which should be in any non-neolithic make.
2010-04-30 12:18:06 -04:00
Todd C. Miller
f42cf76d8a Re-enable bsm audit. Currently auditing is done within the sudoers
plugin itself.  If possible, this should really be done in the main
driver but we don't presently have the needed data to do that.  This
will be re-evaluated when Linux audit support is added.
2010-04-30 12:01:15 -04:00
Todd C. Miller
0c7e3235f6 Remove extraneous $srcdir and use more .c.lo and .c.o rules instead
of explicit rules in the dependency.
2010-04-30 11:14:31 -04:00
Todd C. Miller
8fc1ebd4f4 Print signal info after restoring the tty mode, not before. 2010-04-29 16:52:50 -04:00
Todd C. Miller
f45b1e82ed Defer call to alarm() until after we fork the child.
Pass correct pid to terminate_child()
If the command exits due to signal, set alive to false like we do when it
    exits normally.
Add missing check for errpipe[0] != -1 before using it in FD_ISSET
2010-04-29 16:47:27 -04:00
Todd C. Miller
935aef4983 Simplify dependencies by using .c.o and .c.lo rules. 2010-04-27 12:06:41 -04:00
Todd C. Miller
1c67169b9d Substitute in @PROGS@ into src/Makefile to add sesh 2010-04-27 11:56:51 -04:00
Todd C. Miller
c8733dbc6e Add sudo_noexec.la to "all" target, otherwise it only gets built
at install time.
2010-04-26 21:30:41 -04:00
Todd C. Miller
03536ca93e Update clean and cleandir targets 2010-04-23 22:55:34 -04:00
Todd C. Miller
4b04e875ed Move fileops.c defines and prototypes to filesops.h 2010-04-23 06:02:39 -04:00
Todd C. Miller
b4a26b7691 Use timeval directly instead of converting to timespec when dealing
with file times and time of day.
2010-04-20 16:44:02 -04:00
Todd C. Miller
bc813db528 Add a "noninteractive" boolean to the settings passed in to the plugin's
open function that is set when the user specifies the -n flag.
2010-04-14 08:41:53 -04:00
Todd C. Miller
ea523b17a4 Use a pipe to pass back errno to the parent if execve() fails.
If we get an error in script_child(), kill the command and exit.
2010-04-13 19:40:32 -04:00
Todd C. Miller
f19be6da31 Handle plugin's open function returning -2 (usage error). 2010-04-13 09:36:43 -04:00
Todd C. Miller
40533f381e If execve() fails, leave it to the plugin to print an error string. 2010-04-13 07:39:06 -04:00
Todd C. Miller
e472e4ae01 If execve fails in logging mode, pass the errno directly to the grandparent
on the backchannel and exit.  The immediate parent will get SIGCHLD and
try to report that status but its parent will no longer be listening.
It would probably be cleaner to pass this over a pipe in script_child().
2010-04-13 06:31:55 -04:00
Todd C. Miller
7ce802792e NULL-terminate env_add 2010-04-12 07:56:32 -04:00
Todd C. Miller
0494774f30 Call the I/O log open function before the I/O version function. 2010-04-11 17:13:11 -04:00
Todd C. Miller
711b8d1c04 Only need to take action on SIGCHLD in parent if no I/O logger.
If there is an I/O logger we will receive ECONNRESET or EPIPE when
we try to read from the socketpair.
2010-04-10 10:31:47 -04:00
Todd C. Miller
93126eb5ab Don't set SA_RESTART when registering SIGALRM handler.
Do set SA_RESTART when registering SIGWINCH handler.
2010-04-08 20:17:26 -04:00
Todd C. Miller
b457f13718 If log_input or log_output returns false, terminate the command. 2010-04-08 09:40:27 -04:00
Todd C. Miller
5b3d150932 Better signal handling.
Instead of using a single variable to store the received signal, use
an array so we can't lose a signal when multiple are sent.
Fix process termination by SIGALRM in non-I/O logger mode.
Fix relaying terminal signals to the child in non-I/O logger mode.
2010-04-08 07:40:04 -04:00
Todd C. Miller
a3f4278388 Fix a race between when we get the child pid in the parent and when
the child process exits.  The problem exhibited as a hang after a
short-lived process, e.g. "sudo id" when no IO logger was enabled.
2010-04-08 06:12:47 -04:00
Todd C. Miller
2634cf08cc Avoid installing signal handlers that are io-logger specific. Fixes
job control when no io logger is enabled.
2010-04-05 16:27:30 -04:00
Todd C. Miller
43b6359df3 Fix out-of-tree builds 2010-04-04 14:01:21 -04:00
Todd C. Miller
8c91f0a30c Create our own sys_siglist for systems without it for use by strsignal() 2010-04-02 07:47:19 -04:00
Todd C. Miller
44341c9c15 Main sudo should not block signals; the plugin should do this in
check_policy.
2010-04-01 06:35:19 -04:00
Todd C. Miller
ca2eee07b5 Fix a sizeof(ptr) vs. sizeof(*ptr) 2010-03-31 20:30:34 -04:00
Todd C. Miller
c3e87c2db3 Unlike most operating systems, HP-UX select() is not interrupted
by SIGCHLD when the signal is registered with SA_RESTART.  If
we clear SA_RESTART when calling sigaction() for SIGCHLD we get
the expected behavior and the code in the select() loops already
handles EINTR correctly.
2010-03-31 12:43:26 -04:00
Todd C. Miller
6c71d6afa4 Load the sudoers I/O plugin by default too now that it is hooked up. 2010-03-31 05:42:58 -04:00
Todd C. Miller
5d6f19671c It looks like AIX doesn't need to push STREAMS modules for ptys. 2010-03-30 12:06:27 -04:00
Todd C. Miller
e17f1e5cbd Delay calling the I/O plugin open function until the policy plugin
returns success.
2010-03-28 08:41:06 -04:00
Todd C. Miller
43ea59f64f Fix iteration over runas_groups list. 2010-03-22 18:08:17 -04:00
Todd C. Miller
7af5cdfaf4 Fix setting of groups list 2010-03-22 08:26:05 -04:00
Todd C. Miller
4b36657781 Pass in preserve_groups when the -P flag is specified as per the design 2010-03-22 08:11:06 -04:00