Commit Graph

460 Commits

Author SHA1 Message Date
Todd C. Miller
21e3ca9cf8 More to a less restrictive, ISC-style license. 2004-02-13 21:36:43 +00:00
Aaron Spangler
b0226e939b Merged in LDAP Support 2004-02-13 02:08:27 +00:00
Todd C. Miller
c4a8ab8b99 Use the SET, CLR and ISSET macros. 2004-01-29 22:33:58 +00:00
Todd C. Miller
7a07ad8641 Don't look at prev_user until after we've parsed sudoers and done the
password check.  That way, if sudo/sudoedit is run from a root process
that was invoked by sudo, we check sudoers for root, not the previous
user.  This makes sudoedit much more useful and means that for the
sudo case, we get correct logging on who actually ran the command.
2004-01-29 21:15:27 +00:00
Todd C. Miller
5ccddf8176 Fix suspending the editor in -e mode. Because we do a fork() first
we need to be notified when the child has been stopped and then send
that same signal to ourself so the shell can do its job control thing.
2004-01-22 02:57:01 +00:00
Todd C. Miller
d1798a06b4 Allow non-exclusive flags when invoked as sudoedit.
Pretty print the long usage() line to not wrap (assumes 80 char display)
2004-01-21 23:55:39 +00:00
Todd C. Miller
2be964efea If sudo is invoked as "sudoedit" the -e flag is implied and no other
flags are permitted.
2004-01-21 23:01:35 +00:00
Todd C. Miller
4dc5700a6d Add a new flag, -e, that makes it possible to give users the ability
to edit files with the editor of their choice as the invoking user,
not the runas user.  Temporary files are used for the actual edit
and the temp file is copied over the original after the editor is done.
2004-01-21 22:25:10 +00:00
Todd C. Miller
8ab5b8c596 If real uid == 0 and the SUDO_USER environment variables is set,
use that to determine the invoking user's true identity.  That way
the proper info gets logged by someone who has done "sudo su" but
still uses sudo to as root.  We can't do this for non-root users
since that would open up a security hole, though perhaps it would
be acceptable to use getlogin(2) on OSes where this a system call
(and doesn't just look in the utmp file).
2004-01-21 22:06:02 +00:00
Todd C. Miller
063c2812e2 Back out portions of the -i commit that set NewArgv[0] in set_runaspw.
It is far to late to set NewArgv[0] there and will have no effect
anyway as cmnd and safe_cmnd have already been set.
2004-01-20 19:22:46 +00:00
Todd C. Miller
3001e7f296 In -i mode always set new environment based on the runas user's passwd entry. 2004-01-19 01:17:00 +00:00
Todd C. Miller
1ca6264df1 o Add -i that acts similar to "su -", based on patches from David J. MacKenzie
o Sort the flags in the usage message
2004-01-18 22:55:32 +00:00
Todd C. Miller
c823817275 Change euid to runas user before calling find_path(). Unfortunately,
though runas_user can be modified in sudoers we haven't parsed sudoers yet.
2004-01-17 21:34:05 +00:00
Todd C. Miller
03f5f4087c Fix a bug when set_runaspw() is used as a callback. We don't want to
reset the contents of runas_pw if the user specified a user via the -u flag.

Avoid unnecessary passwd lookups in set_authpw().  In most cases we already
have the info in runas_pw.
2004-01-17 18:49:59 +00:00
Todd C. Miller
febc09e147 Add set_runaspw() function to fill in runas_pw. This will be used
as a callback to update runas_pw when the runas user changes.
2004-01-16 23:09:20 +00:00
Todd C. Miller
ecfc813757 PERM_RUNAS -> PERM_FULL_RUNAS 2004-01-16 23:07:03 +00:00
Todd C. Miller
d55c3f63c7 Use closefrom() instead of doing the equivalent inline. 2004-01-12 19:03:54 +00:00
Todd C. Miller
8e421c95b8 update copyright year 2004-01-05 17:15:32 +00:00
Todd C. Miller
7536a781f0 Add support for preloading a shared object containing a dummy execve()
function that just sets error and returns -1.  This adds a
"noexec_file" option to load the filename as well as a "noexec" flag
to enable it unconditionally.  There is also a NOEXEC tag that can
be attached to specific commands and an EXEC tag to disable it.
2004-01-05 02:48:09 +00:00
Todd C. Miller
caf389c2fa Rename EXEC macro -> EXECV 2004-01-05 01:39:57 +00:00
Todd C. Miller
02f37dc2da Add support for tuples in def_data.in; these are implemented as an
enum type.  Currently there is only a single tuple enum but in the
future we may have one tuple enum per T_TUPLE entry in def_data.in.
Currently listpw, verifypw and lecture are tuples.  This avoids the
need to have two entries (one ival, one str) for pwflags and syslog
values.

lecture is now a tuple with the following values: never, once, always

We no longer use both an int and string entry for syslog facilities
and priorities.  Instead, there are logfac2str() and logpri2str()
functions that get used when we need to print the string values.
2003-12-30 22:31:30 +00:00
Todd C. Miller
6ad252765b Create def_* macros for each defaults value so we no longer need
the def_{flag,ival,str,list,mode} macros (which have been removed).
This is a step toward more flexible data types in def_data.in.
2003-12-30 22:20:21 +00:00
Todd C. Miller
7f773be1fe If we are in -k/-K mode, just spew to stderr. It is not unusual for
users to place "sudo -k" in a .logout file which can cause sudo to
be run during reboot after the YP/NIS/NIS+/LDAP/etc daemon has died.
Previously, this would result in useless mail and logging.
2003-12-23 02:18:13 +00:00
Todd C. Miller
f13528b0b1 add DARPA credit on affected files 2003-04-16 00:42:10 +00:00
Todd C. Miller
e15de8443d Don't change rl.rlim_max for RLIMIT_CORE. We need only set rl.rlim_cur
to 0 to turn off core dumps.  This may be needed for the RLIMIT_CORE
restoration on some OSes.
2003-04-09 20:13:04 +00:00
Todd C. Miller
dcf1a5acce Use warn/err and getprogname() throughout. The main exception is
openlog().  Since the admin may be filtering logs based on the
program name in the log files, hard code this to "sudo".
2003-04-02 18:25:30 +00:00
Todd C. Miller
632dbebef0 fix strlcpy() rval check (innocuous) 2003-04-01 15:02:49 +00:00
Todd C. Miller
48229cbac6 update copyright year 2003-03-15 20:31:02 +00:00
Todd C. Miller
b18a141ae9 Cast [ug]ids to unsigned long and printf with %lu 2003-03-15 20:19:58 +00:00
Todd C. Miller
4b7b3c7f59 Use stat_sudoers macro so --with-stow can work 2003-03-15 18:02:02 +00:00
Todd C. Miller
eebc763bd3 Use strlc{at,py} for paranoia's sake and exit on overflow. In all
cases the strings were either pre-allocated to the correct size of
length checks were done before the copy but a little paranoia can
go a long way.
2003-03-13 20:00:45 +00:00
Todd C. Miller
96376b6d4e snprintf() a uid as %lu, not %ld to match the MAX_UID_T_LEN test in
configure.
2003-03-13 16:58:25 +00:00
Todd C. Miller
804caf3956 Use snprintf() for paranoia 2003-03-12 23:46:54 +00:00
Todd C. Miller
c96a62e26c Use emalloc2() to allocate N things of a certain size. 2003-03-12 21:45:51 +00:00
Todd C. Miller
897b551372 fix typo in comment; Pedro Bastos 2002-11-26 17:09:59 +00:00
Todd C. Miller
b152da4cdb Revamp set_perms. We now use a version based on setresuid() or setreuid()
when possible since that allows us to support the stay_setuid option and
we always know exactly what the semantics will be (various Linux kernels
have broken POSIX saved uid support).
2002-11-22 19:09:49 +00:00
Todd C. Miller
faabf3bac7 Before exec, restore state of signal handlers to be the same as
when we were initialy invoked instead of just reseting to SIG_DFL.
Fixes a problem when using sudo with nohup.  Based on a patch from
Paul Markham.
2002-11-22 18:33:47 +00:00
Todd C. Miller
4f2d87e28c o timestamp_uid should be uid_t, not int
o clarify error message when sudo is run by root and no_root_sudo is set
2002-11-22 18:23:24 +00:00
Todd C. Miller
0f60107a1c No need for dump_badenv() now that dump_defaults() knows how to dump lists. 2002-05-05 19:58:29 +00:00
Todd C. Miller
c289159953 g/c second arg to set_perms--it is no longer used 2002-05-05 00:43:38 +00:00
Todd C. Miller
a30951d34c Add support for non-root timestamp dirs. This allows the timestamp
dir to be shared via NFS (though this is not recommended).
2002-05-03 22:48:17 +00:00
Todd C. Miller
99cc62452d Move endpwent() to be after set_perms(PERM_RUNAS, ...) and also call
endgrent() at the same time.
2002-03-12 03:19:04 +00:00
Todd C. Miller
ea24bef19c The SHELL environment variable was preserved from the user's
environment instead of being reset based on the passwd database
when the "env_reset" option was used.  Now it is reset as it should be.
2002-01-15 23:43:59 +00:00
Todd C. Miller
f039427253 Add a configure option to turn off use of POSIX saved IDs 2002-01-15 22:47:29 +00:00
Todd C. Miller
eb97ce45ea Only OR in MODE_RESET_HOME if MODE_RUN is set.
Fixes a problem where "sudo -l" would not work if always_set_home was set.
2002-01-15 20:39:59 +00:00
Todd C. Miller
26e835b096 o Move the call to rebuild_env() until after MODE_RESET_HOME is set.
Otherwise, the set_home option has no effect.

o Fix use of freed memory when the "fqdn" flag is set.  This was
  introduced by the fix for the "segv when gethostbynam() fails" bug.
  Also, we no longer call set_fqdn() if the "fqdn" flag is not set so
  there is no need to check the "fqdn" flag in set_fqdn() itself.
2002-01-15 01:53:02 +00:00
Todd C. Miller
9eac6eeaa3 If set_perms == set_perms_posix and the stay_setuid flag is not
set, set all uids to 0 and use set_perms_fallback().
2002-01-13 18:29:23 +00:00
Todd C. Miller
a82e7a8efe (c) 2002 2002-01-08 15:00:18 +00:00
Todd C. Miller
53299b78a0 Defer assigning new environment until right before the exec. 2002-01-08 14:20:57 +00:00
Todd C. Miller
afe8333fc2 XXX - should call find_path() as runas user, not root. Can't do
that until the parser changes though.
2001-12-15 00:45:13 +00:00