Commit Graph

395 Commits

Author SHA1 Message Date
Todd C. Miller
572b4cf39a Don't try and build saved uid version of set_perms on systems w/o them.
Rename set_perms_saved_uid() -> set_perms_posix()
Make set_perms_setreuid simply be set_perms_fallback() and simply include
  the appropriate function at compile time (setreuid() vs. setuid()).
2000-12-30 03:59:40 +00:00
Todd C. Miller
998631b73a New Defaults options:
o stay_setuid - sudo will remain setuid if system has saved uids or setreuid(2)
 o env_reset - reset the environment to a sane default
 o env_keep - preserve environment variables that would otherwise be cleared

No longer use getenv/putenv/setenv functions--do environment munging by hand.
Potentially dangerous environment variables can be cleared only if they
contain '/' pr '%' characters to protect buggy programs.
Moved environment routines into env.c (new file)
2000-12-30 03:29:47 +00:00
Todd C. Miller
7ce284a132 Use exit(127), not exit(-1) 2000-11-03 14:36:32 +00:00
Todd C. Miller
7ea65e54bd Move set_perms() to its own file and use POSIX saved uid or setreuid()
if available.

Added stay_setuid option for systems that have libraries that perform
extra paranoia checks in system libraries for setuid programs (ie:
anything with issetugid(2)).
2000-11-03 05:37:44 +00:00
Todd C. Miller
70f16a284d strip more bits from the environment and add a facility for stripping
things only if they contain '/' or '%' to address printf format string
vulnerabilities in other programs.
2000-11-03 01:28:54 +00:00
Todd C. Miller
f31d6ce259 Remove debugging code that should not have been committed, oops. 2000-10-29 22:31:42 +00:00
Todd C. Miller
e23d30b913 Fix a coredump in the logging functions if gethostname(2) fails
by deferring the call to log_error() until things are better setup.

Fix return value of set_loginclass() in non-BSD-auth case.

Hard-code 'sudo' in the usage message so we can fit more options on a line
2000-10-27 22:41:48 +00:00
Todd C. Miller
0208b22686 Add support for BSD authentication. 2000-10-26 16:42:40 +00:00
Todd C. Miller
9745a31948 sudo_setenv() now exits on memory alloc failure instead of returning -1. 2000-09-14 20:48:58 +00:00
Todd C. Miller
deb5b07f40 Strip out NLSPATH and PATH_LOCALE from the environment for FreeBSD
and possibly others.
2000-09-07 21:41:16 +00:00
Todd C. Miller
ed7827decc Add always_set_home variable 2000-09-07 01:35:39 +00:00
Todd C. Miller
6525e882a4 The listpw and verifypw sudoers options would not take effect because
the value of the default was checked *before* sudoers was parsed.
Instead of passing in the value of PWCHECK_* to sudoers_lookup(),
pass in the arg for def_ival() so the check can be deferred until
after sudoers is parsed.
2000-08-12 20:48:29 +00:00
Todd C. Miller
d7050d5615 Add support for using getifaddrs() to get the list of ip addr / netmask
pairs.  Currently IPv4-only.
2000-06-04 23:57:22 +00:00
Todd C. Miller
7a2dfb77fb Call clean_env very early in main() for paranoia's sake. Idea from
Marc Esipovich.
2000-05-12 20:55:35 +00:00
Todd C. Miller
165bd7fafb Fix root, runas, and target authentication for non-passwd file auth
methods.
2000-05-09 15:42:38 +00:00
Todd C. Miller
455f27816f Bracket calls to syslog with an openlog() and closelog() since some
authentication methods (like PAM) may do their own logging via
syslog.  Since we don't use syslog much (usually just once per
session) this doesn't really incur a performance penalty.
It also Fixes a SEGV with pam_kafs.
2000-04-17 18:01:14 +00:00
Todd C. Miller
978e3f8bc0 Fix -H flag. runas_homedir is only valid after set_perms(PERM_RUNAS, mode) 2000-04-15 20:32:59 +00:00
Todd C. Miller
f32e054fe5 Make login class support work on BSD/OS 2000-03-24 20:13:12 +00:00
Todd C. Miller
fed49d49eb set_loginclass() should be static like the proto says 2000-03-24 00:16:41 +00:00
Todd C. Miller
78b6514e58 Add support for set_logname run-time default 2000-03-23 00:20:56 +00:00
Todd C. Miller
5684831592 User can always specify a login class if he/she is already root. 2000-03-07 19:26:02 +00:00
Todd C. Miller
935a51e76a FreeBSD login class (login.conf) support. 2000-03-07 04:29:46 +00:00
Todd C. Miller
24f8ee8807 Stash coredumpsize resource limit and retsore it before the exec()
Otherwise the child ends up with a coredumpsize of 0.
2000-02-28 23:58:17 +00:00
Todd C. Miller
f1c2ba6aa2 fix usage string 2000-02-27 03:54:20 +00:00
Todd C. Miller
54fbe08545 Added -S flag (read passwd from stdin) and tgetpass_flags global
that holds flags to be passed in to tgetpass().  Change echo_off
param to tgetpass() into a flags field.  There are currently 2
possible flags for tgetpass(): TGP_ECHO and TGP_STDIN.  In tgetpass(),
abstract the echo set/clear via macros and if (flags & TGP_ECHO)
but echo is not set on the terminal, but sure to set it.
2000-02-27 03:49:07 +00:00
Todd C. Miller
09b23e7b41 Add rootpw, runaspw, and targetpw options. 2000-02-18 17:56:28 +00:00
Todd C. Miller
fc08d7004c Move user_is_exempt prototype into sudo.h 2000-02-15 23:36:04 +00:00
Todd C. Miller
9e0bae9fc6 update copyright year on changed files 2000-01-17 23:46:26 +00:00
Todd C. Miller
217cae528a When using rlimit check for RLIM_INFINITY
When computing the value of maxfd, use min(getdtablesize(), RLIMIT_NOFILE)
2000-01-17 22:46:32 +00:00
Todd C. Miller
ccb808da31 Add 'shell_noargs' runtime option back in. We have to defer checking
until after the sudoers file has been parsed but since there are now
other options that operate that way this one can too.  Based on a patch
from bguillory@email.com.
2000-01-17 17:25:10 +00:00
Todd C. Miller
f68cc2f628 Add "listpw" and "verifypw" options. 2000-01-17 04:05:18 +00:00
Todd C. Miller
038dea2d3d Update statbuf.st_mode based on SUDOERS_MODE when we are chaning from
0400 to whatever SUDOERS_MODE is (converting from the old sudoers mode).
Assumes that SUDOERS_MODE is less restrictive than 0400 which should
always be the case.
2000-01-03 04:53:35 +00:00
Todd C. Miller
625e3e46d0 Make treatment of -l and -v sane wrt NOPASSWD flags. Now allow -l w/o a passwd
if there is *any* entry for the user on the host with a NOPASSWD flag.
For -v, only allow w/o a passwd if *all* entries for the user on the host
w/ the specified runas user have the NOPASSWD flag set.
2000-01-03 04:43:33 +00:00
Todd C. Miller
ac67ced558 Add check for initgroups() since old SYSV lacks this. 1999-12-09 04:04:47 +00:00
Todd C. Miller
12f5216097 Don't kill the user's tickets until after sudoers has been parsed
since tty_tickets and ticket_dir could be set in sudoers.
1999-12-05 02:54:20 +00:00
Todd C. Miller
449f67f776 o Kill shell_noargs option, it cannot work since the command needs to
be set before sudoers is parsed.
o Fix the "set_home" sudoers option (only worked at compile time).
o Fix "fqdn" sudoers option.  We now set host/shost via set_fqdn which
  gets called when the "fqdn" option is set in sudoers.
o Move the openlog() to store_syslogfac() so this gets overridden
  correctly from the sudoers file.
1999-12-02 20:31:25 +00:00
Todd C. Miller
6713b85dc6 Make the -s flag be exclusive too. Also reorder the flags in
the exclusive usage message so they are alphabetical.
1999-11-24 03:52:34 +00:00
Todd C. Miller
1976aec18c need sys/time.h if HAVE_SETRLIMIT 1999-11-16 06:09:23 +00:00
Todd C. Miller
d00a8de2f0 get rid of references to sudo-bugs. Now mention the web site or the sudo@ alias 1999-11-16 05:42:28 +00:00
Todd C. Miller
59666aca78 o Now use getrlimit to find the highest fd when closing all non-std fd's
o Turn off core dumps via setrlimit for the sake of paranoia
1999-11-04 19:01:11 +00:00
Todd C. Miller
e08f3f3937 For the sudo_root option, check against user_uid, not getuid() since
at this point, ruid == euid == 0.
1999-11-01 15:43:12 +00:00
Todd C. Miller
3acdd5b02f New krb5 code from Frank Cusack <fcusack@iconnet.net>. 1999-10-13 02:34:55 +00:00
Todd C. Miller
7f5c248933 in set_perms(), always call setuid(0) before changing the ruid/euid
so we always know it will succeed.
1999-10-11 23:42:57 +00:00
Todd C. Miller
2c4fefde5a o Add requiretty option
o Move O_NOCTTY to compat.h
1999-10-08 01:12:50 +00:00
Todd C. Miller
7769bf6a32 o Change defaults stuff to put the value right in the struct.
o Implement mailer_flags
o Store syslog stuff both in int and string form.  Setting the string
  form magically updates the int version.
o Add boolean attribute to strings where it makes sense to say !foo
1999-10-07 21:21:08 +00:00
Todd C. Miller
13bf42675d Add support for "Defaults" line in sudoers to make configuration variables
changable at runtime (and on a global, per-host and per-user basis).
Both the names and the internal representation are still subject to change.
It was necessary to make sudo_user.runas but a char ** instead of a
char * since this value can be changed by a Defaults line.  There is a
similar (but more complicated) issue with sudo_user.prompt but it
is handled differently at the moment.

Add a "-L" flag to list the name of options with their descriptions.  This
may only be temporary.

Move some prototypes to parse.h

Be much less restrictive on what is allowed for a username.
1999-09-08 08:06:28 +00:00
Todd C. Miller
61bd59c733 Only block SIGINT, SIGQUIT, SIGTSTP (which can be generated from
the keyboard).  Since we run with ruid/euid == 0 the user can't
really signal us in nasty ways.
1999-08-27 21:02:24 +00:00
Todd C. Miller
79faf00e5d fix --enable-noargs-shell 1999-08-27 15:53:29 +00:00
Todd C. Miller
b13e8006ec Add check for LONG_IS_QUAD
#undef MAXINT before including hpsecurity.h to silence an HP-UX warning
Check for U?LONG_LONG_MAX in snprintf.c and use LONG_IS_QUAD
1999-08-22 09:59:28 +00:00
Todd C. Miller
275c2fc980 Run most of the code as root, not the invoking user. It doesn't really
gain us anything to run as the user since an attacker can just have
an setuid(0) in their egg.  Running as root solves potential problems
wrt signalling.
1999-08-20 20:37:16 +00:00