Todd C. Miller [Sat, 26 Sep 2015 16:53:16 +0000 (10:53 -0600)]
When the command sudo is running is killed by a signal, sudo will
now send itself the same signal with the default signal handler
instead of exiting. The bash shell appears to ignore some signals,
e.g. SIGINT, unless the command is killed by that signal. This
makes the behavior of commands run under sudo the same as without
sudo when bash is the shell. Bug #722
Todd C. Miller [Fri, 25 Sep 2015 17:15:22 +0000 (11:15 -0600)]
If some, but not all, of the LOGNAME, USER or USERNAME environment
variables have been preserved from the invoking user's environment,
sudo will now use the preserved value to set the remaining variables
instead of using the runas user. This ensures that if, for example,
only LOGNAME is present in the env_keep list, that sudo will not
set USER and USERNAME to the runas user.
Todd C. Miller [Thu, 24 Sep 2015 19:43:17 +0000 (13:43 -0600)]
Fix passing of the callback pointer to the conversation function.
This was preventing the on_suspend and on_resume functions from
being called on PAM systems.
Todd C. Miller [Tue, 15 Sep 2015 16:30:36 +0000 (10:30 -0600)]
When a terminal device is closed, SIGHUP is sent to the controlling
process associated with that terminal. It is not sent to the entire
process group so sudo needs to relay SIGHUP to the command when it
is not being run in a new pty. Bug #719
Todd C. Miller [Tue, 15 Sep 2015 15:29:40 +0000 (09:29 -0600)]
We reserved two slots at the end of the editor argv for the line
number and the file name. However, resolve_editor() adds "--"
before the file names so the +line_number is interpreted as a file
name, not a line number so we need to overwrite the "--" as well.
Todd C. Miller [Thu, 10 Sep 2015 22:44:57 +0000 (16:44 -0600)]
Remove checks for __sys_siglist and __sys_signame. They are internal
to libc and there are no known systems that export those symbols
that do not already export the single underbar or no-underbar versions.
Todd C. Miller [Wed, 9 Sep 2015 20:56:52 +0000 (14:56 -0600)]
No need to have version macros for hooks, callbacks and the sudoers
group plugin. We can just use the main sudo API macros. The sudoers
group plugin macros are preserved for source compatibility but are
not documented.
Todd C. Miller [Wed, 9 Sep 2015 16:50:21 +0000 (10:50 -0600)]
Fill in cstat if exec_setup() fails. Previously it was only filled
in for an execve() failure. Fixes an unkillable sudo process when
exec_setup() fails and I/O logging is enabled.
Todd C. Miller [Wed, 9 Sep 2015 16:45:56 +0000 (10:45 -0600)]
Fix running commands as non-root when neither setresuid() not
setreuid() are available. At this point we are already root so
setuid() must succeed. Bug #713
Todd C. Miller [Mon, 7 Sep 2015 12:06:08 +0000 (06:06 -0600)]
Bring back the check for time stamp files that predate the boot
time. Instead of truncating we now unlink the file since another
process may be sleeping on the lock.
Todd C. Miller [Mon, 7 Sep 2015 12:06:08 +0000 (06:06 -0600)]
Adjust new locking to work when tty_tickets is disabled. We need
to use per-tty/ppid locking to gain exclusive access to the tty
for the password prompt but use a separate (short term) lock
that is shared among all sudo processes for the user.
Todd C. Miller [Mon, 7 Sep 2015 12:06:08 +0000 (06:06 -0600)]
Implement suspend/resume callbacks for the conversation function.
If suspended, close the timestamp file (dropping all locks). On
resume, lock the record before reading the password.
For this to work properly we need to be able to run th callback
when tsetattr() suspends us, not just when the user does. To
accomplish this the term_* functions now return EINTR if SIGTTOU
would be generated. The caller now has to restart the term_*
function (and send itself SIGTTOU) instead of it being done
automatically.
Todd C. Miller [Mon, 7 Sep 2015 12:06:08 +0000 (06:06 -0600)]
Lock individual records in the timestamp file instead of the entire
file. This will make it possible for multiple sudo processes using
the same tty to serialize their timestamp lookups.
Todd C. Miller [Mon, 7 Sep 2015 12:06:08 +0000 (06:06 -0600)]
Add a struct sudo_conv_callback that contains on_suspend and on_resume
function pointer args plus a closure pointer and at it to the
conversation function.
Todd C. Miller [Tue, 1 Sep 2015 16:24:59 +0000 (10:24 -0600)]
When decoding base64, avoid using '=' in the decoded temporary array
as a sentinel as it can legitimately be present. Instead, just use
the count of bytes stored in the temp array to determine which bytes
to fold into the destination.
Todd C. Miller [Tue, 18 Aug 2015 14:57:53 +0000 (08:57 -0600)]
The condition for adding a missing newline at the end of sudoers
was never reached. Keep track of the last character and write a
newline character if when copying to the temp file. Found by Radovan
Sroka.
Todd C. Miller [Tue, 11 Aug 2015 02:17:02 +0000 (20:17 -0600)]
In sudo_pam_begin_session() and sudo_pam_end_session() return
AUTH_FATAL on error, not AUTH_FAILURE. In sudo_auth_begin_session()
treat anything other than AUTH_SUCCESS as a fatal error.
Todd C. Miller [Mon, 10 Aug 2015 21:13:37 +0000 (15:13 -0600)]
Linux sets si_pid in struct siginfo to 0 when the process that sent
the signal is in a different container since the PID namespaces in
different conatiners are separate. Avoid looking up the process
group by id when si_pid is 0 since getpgid(0) returns the process
group of the current process. Since sudo ignores signals sent
by processes in its own process group, this had the effect of
ignoring signals sent from other containers. From Maarten de Vries
Todd C. Miller [Fri, 7 Aug 2015 23:01:15 +0000 (17:01 -0600)]
Explicitly tell people not to grant sudoedit to directories the
user can write to. While sudoedit will no longer open symbolic
links, hard links are still an issue.
Todd C. Miller [Thu, 6 Aug 2015 19:20:01 +0000 (13:20 -0600)]
Do not follow symbolic links in sudoedit by default. This behavior
can be controlled by the sudoedit_follow Defaults flag as well as
the FOLLOW/NOFOLLOW tags.
Todd C. Miller [Fri, 10 Jul 2015 16:31:21 +0000 (10:31 -0600)]
Avoid calling dlerror() multiple times since it clear the error
status after printing the error.
Problem caused by sudo_warn/sudo_fatal being macros...