Commit Graph

286 Commits

Author SHA1 Message Date
Todd C. Miller
9b2c889812 We need to init the auth system regardless of whether we need a
password since we will be closing the PAM session in the monitor
process.  Fixes a crash in the monitor on Solaris; bugzilla #518
2011-10-25 10:08:26 -04:00
Todd C. Miller
839919566e Add debug_decl/debug_return (almost) everywhere.
Remove old sudo_debug() and convert users to sudo_debug_printf().
2011-10-22 14:40:21 -04:00
Todd C. Miller
930122d346 It appears that LDAP or NSS may modify the euid so we need to be
root for the open().  We restore the old perms at the end of
sudoers_policy_open().
2011-10-04 11:15:06 -04:00
Todd C. Miller
bceb5df158 Modify the authentication API such that the init and cleanup functions
are always called, regardless of whether or not we are going to
verify a password.  This is needed for proper PAM session support.
2011-09-27 13:18:46 -04:00
Todd C. Miller
c5f8dc95c6 Fix a PAM_USER mismatch in session open/close. We update PAM_USER
to the target user immediately before setting resource limits, which
is after the monitor process has forked (so it has the old value).
Also, if the user did not authenticate, there is no pamh in the
monitor so we need to init pam here too.  This means we end up
calling pam_start() twice, which should be fixed, but at least the
session is always properly closed now.
2011-09-27 11:13:44 -04:00
Todd C. Miller
05bfd66693 If the invoking user cannot be resolved by uid fake the struct
passwd and store it in the cache so we can delref it on exit.
2011-09-25 06:35:40 -04:00
Todd C. Miller
842526d71f Don't error out if the group plugin cannot be loaded, just warn. 2011-09-24 10:24:40 -04:00
Todd C. Miller
0775147894 Quiet a false positive found by several static analysis tools.
These tools don't know that log_error() does not return (it longjmps
to error_jmp which returns to the sudo front-end).
2011-09-23 19:37:21 -04:00
Todd C. Miller
d56a17165a Also check sudoers gid if sudoers is group writable. 2011-08-13 18:34:37 -04:00
Todd C. Miller
6099e1bc42 Add dedicated callback function for runas_default sudoers setting
that only sets runas_pw if no runas user or group was specified by
the user.
2011-08-10 09:02:37 -04:00
Todd C. Miller
01ae3d4771 Go back to using a callback for runas_default to keep runas_pw in
sync.  This is needed to make per-entry runas_default settings work
with LDAP-based sudoers.  Instead of declaring it a callback in
def_data.in, sudo and testsudoers poke sudo_defs_table[] which is
a bit naughty, but avoids requiring stub functions in visudo and
the tests.
2011-08-09 14:54:42 -04:00
Todd C. Miller
8255ed69b9 Go back to escaping the command args for "sudo -i" and "sudo -s"
before calling the plugin.  Otherwise, spaces in the command args
are not treated properly.  The sudoers plugin will unescape non-spaces
to make matching easier.
2011-07-29 10:10:40 -04:00
Todd C. Miller
35d26ae34f Don't try to audit failure if the runas user does not exist. We don't
have the user's command at this point so there is nothing to audit.
Add a NULL check in audit_success() and audit_failure() just to be
on the safe side.
2011-07-27 12:11:33 -04:00
Todd C. Miller
80138c88ba Remove fallback to per-group lookup when matching groups in sudoers.
The sudo front-end will now use getgrouplist() to get the user's
list of groups if getgroups() fails or returns zero groups so we
always have a list of the user's groups.  For systems with
mbr_check_membership() which support more that NGROUPS_MAX groups
(Mac OS X), skip the call to getgroups() and use getgrouplist() so
we get all the groups.
2011-07-25 09:17:18 -04:00
Todd C. Miller
3dde167cf6 user_group is no longer used, remove it 2011-07-22 09:29:49 -04:00
Todd C. Miller
b124635b04 Instead of keeping separate groups and gids arrays, create struct
group_info and use it to store both, along with a count for each.
Cache group info on a per-user basis using getgrouplist() to get
the groups.  We no longer need special to special case the user or
list user for user_in_group() and thus no longer need to reset the
groups list when listing another user.
2011-07-20 11:58:45 -04:00
Todd C. Miller
6d8788a6cd Do not shadow global sudo_mode with a local variable in set_cmnd() 2011-07-18 16:23:38 -04:00
Todd C. Miller
54bf162e60 bash 2.x doesd not support the -l flag and exits with an error if
it is specified so use --login instead.  This causes an error with
bash 1.x (which uses -login instead) but this version is hopefully
less used than 2.x.
2011-07-17 10:37:15 -04:00
Todd C. Miller
56321ec778 Resolve the list of gids passed in from the sudo frontend (the
result of getgroups()) to names and store both the group names and
ids in the sudo_user struct.  When matching groups in the sudoers
file, match based on the names in the groups list first and
only do a gid-based match when we absolutely have to.  By matching
on the group name (as it is listed in sudoers) instead of id
(which we would have to resolve) we save a lot of group lookups
for sudoers files with a lot of groups in them.
2011-07-01 14:13:47 -04:00
Todd C. Miller
20972da410 Workaround for "sudo -i command" and newer versions of bash which
don't go into login mode when -c is specified unless -l is too.
2011-06-26 18:02:09 -04:00
Todd C. Miller
39be82e32f Set use_pty=true in command details when use_pty is set in sudoers.
From Ludwig Nussel
2011-06-22 10:06:35 -04:00
Todd C. Miller
67e8e56534 Set def_preserve_groups before searching for the command when the -P
flag is specified.
2011-05-26 12:52:59 -04:00
Todd C. Miller
bf7e7b5752 Add gettext.h convenience header. This is similar to but distinct from
the one included with the gettext package.
2011-05-20 11:48:17 -04:00
Todd C. Miller
42a3966a88 Minor warning/error cleanup 2011-05-18 13:44:36 -04:00
Todd C. Miller
6f8cd91928 can't -> "unable to" in warning/error messages 2011-05-18 12:36:26 -04:00
Todd C. Miller
c3a259f5ee Add calls to bindtextdomain() and textdomain()
Currently there are two domains, one for the sudo front-end and
one for the sudoers plugin and its associated utilities.
2011-05-17 16:38:40 -04:00
Todd C. Miller
b643b190a7 Prepare sudoers module messages for translation. 2011-05-16 16:32:05 -04:00
Todd C. Miller
24a087709a Only check gid of sudoers file if it is group-readable. 2011-05-16 12:19:07 -04:00
Todd C. Miller
f1078bd28e Keep track of sudoers grammar version and report it in the -V output. 2011-04-05 11:47:31 -04:00
Todd C. Miller
33516ed826 user_shell -> run_shell to avoid confusion with the user's SHELL variable. 2011-03-18 10:23:35 -04:00
Todd C. Miller
3506f01077 Add support for controlling whether utmp is updated and which user is
listed in the entry.
2011-03-15 15:53:49 -04:00
Todd C. Miller
cde2cb00f0 Add "user_shell" boolean as a way to indicate to the plugin that
the -s flag was given.
2011-03-11 15:02:13 -05:00
Todd C. Miller
383aef00b1 Log the TSID even if it is not a simple session ID. 2011-03-11 12:11:05 -05:00
Todd C. Miller
a092d2fdcf Move noexec handling to sudo front-end where it is documented as being. 2011-03-10 15:11:49 -05:00
Todd C. Miller
c7a7d31905 Add support for disabling exec via solaris privileges.
Includes preparation for moving noexec support out of sudoers
and into front end as documented.
2011-03-10 14:24:10 -05:00
Todd C. Miller
d6252de205 Fix return value of "sudo -l command" when command is not allowed, broken
in [c7097ea22111].  The default return value is now TRUE and a bad:
label is used when permission is denied.  Also fixed missing permissions
restoration on certain errors.  On error()/errorx(), the password and
group files are now closed before returning.
2011-03-08 09:38:21 -05:00
Todd C. Miller
47968912a2 Fix passing of login class back to sudo front end. 2011-03-07 16:55:08 -05:00
Todd C. Miller
e65bc35c6d Fix exit value for validate and list mode. 2011-03-06 15:52:40 -05:00
Todd C. Miller
a0ba308694 Fix non-interactive mode with sudoers plugin. 2011-03-06 15:38:02 -05:00
Todd C. Miller
3c0672e2e3 Allow sudoers file name, mode, uid and gid to be specified in the
settings list.  The sudo front end does not currently set these
but may in the future.
2011-02-23 13:38:52 -05:00
Todd C. Miller
ae2f7638f5 standardize on "return foo;" rather than "return(foo);" or "return (foo);" 2011-01-24 15:15:18 -05:00
Todd C. Miller
3316ac8ebc Do not reject sudoers file just because it is root-writable. 2011-01-24 14:25:51 -05:00
Todd C. Miller
f7f8b6867e Update copyright year to 2011 2011-01-20 16:46:56 -05:00
Todd C. Miller
e7a4529cf8 Fix "sudo -g" support in the sudoers module. 2011-01-11 10:42:01 -05:00
Todd C. Miller
1bb3518b33 Add extra out parameter to expand_iolog_path() to allow the caller
to split the path into dir and file components if needed.
2010-12-31 09:55:40 -05:00
Todd C. Miller
25036d7a75 Pass a single I/O log file name in command_details instead of
separate dir + file parameters.
2010-12-30 17:09:01 -05:00
Todd C. Miller
97b7ae8892 If no iolog file is specified by the policy plugin, use io_nextid()
to determine the next file in the sequence.
2010-12-29 11:07:45 -05:00
Todd C. Miller
02ed3d5b3e Add support for the iolog_compress variable in command_info. 2010-12-28 12:23:18 -05:00
Todd C. Miller
bff14f60e6 Add sigsetjmp() calls to all plugin entry points just to be safe. 2010-12-28 11:02:12 -05:00
Todd C. Miller
fba58fa3f7 Allow sudoers to specify the iolog file in addition to the iolog dir.
Add escape sequence support to iolog file and dir: sequence number,
    user, group, runas_user, runas_group, hostname and command in
    addition to any escape sequence recognized by strftime(3).
2010-12-27 12:18:32 -05:00