Commit Graph

237 Commits

Author SHA1 Message Date
Todd C. Miller
af53e335a1 don't check timestamp mtime if we are just going to remove it 2007-07-06 13:49:41 +00:00
Todd C. Miller
50004e00b8 Fix fd leak when lecture file option is enabled. From Jerry Brown 2005-11-11 16:22:58 +00:00
Todd C. Miller
3bb5c181b0 Move declatation of struct timespec to its own include files for
systems without it since it needs time_t defined.
2005-06-23 03:04:35 +00:00
Todd C. Miller
c7ea24f2cc Add explicit cast from mode_t -> u_int in printf to silence warnings on Solaris 2005-04-24 23:24:58 +00:00
Todd C. Miller
304dc46d7f Add efree() for consistency with emalloc() et al. Allows us to rely
on C89 behavior (free(NULL) is valid) even on K&R.
2005-03-29 14:29:47 +00:00
Todd C. Miller
cc84c41fbe Fix some printf format mismatches on error. 2005-02-12 23:46:13 +00:00
Todd C. Miller
778d587063 Update copyright years. 2005-02-12 22:56:07 +00:00
Todd C. Miller
3b8b88407f Add __unused to rcsids 2005-01-27 15:42:30 +00:00
Todd C. Miller
2c2daa8eca Use: #include <config.h>
Not: #include "config.h"
That way we get the correct config.h when build dir != src dir
2004-11-19 18:39:14 +00:00
Todd C. Miller
9846e562ad Implement group caching and use the passwd and group caches throughout. 2004-11-16 04:24:11 +00:00
Todd C. Miller
51375f969f Add local error/warning functions like err/warn but that call an additional
cleanup routine in the error case.  This means we no longer need to compile
a special version of alloc.o for visudo.
2004-11-15 15:53:53 +00:00
Todd C. Miller
0f056c0d5f Use timespec throughout. 2004-09-08 15:48:23 +00:00
Todd C. Miller
7f772c822f Add an extra param to touch() for nsec 2004-09-07 19:55:37 +00:00
Todd C. Miller
1c20ff1a6d Use utimes() and futimes() instead of utime() in touch(), emulating as needed.
Not all systems are able to support setting the times of an fd so touch()
takes both an fd and a file name as arguments.
2004-09-07 17:14:52 +00:00
Todd C. Miller
31f98d84df Don't ask for a password if invoking user == target user. 2004-06-10 20:19:38 +00:00
Todd C. Miller
ba803b6e1b Remove trailing spaces, no actual code changes. 2004-06-06 23:58:09 +00:00
Todd C. Miller
d33ad95208 Use PATH_MAX, not MAXPATHLEN since the former is standardized. 2004-06-01 01:22:27 +00:00
Todd C. Miller
51c9ed3198 Preliminary changes to support nsr-tandem-nsk. Based on patches from
Tom Bates.
2004-05-17 20:08:46 +00:00
Todd C. Miller
5b217d36a3 More to a less restrictive, ISC-style license. 2004-02-13 21:36:43 +00:00
Todd C. Miller
e404f54c23 Add Stan Lee / Uncle Ben quote to the lecture from RedHat 2004-01-16 23:16:24 +00:00
Todd C. Miller
9eba370a09 Update copyright year 2004-01-05 01:13:50 +00:00
Todd C. Miller
b289f73870 Add a new option, lecture_file, that can be used to point to a custom
sudo lecture.
2004-01-05 01:12:22 +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
6c51ebd37a add DARPA credit on affected files 2003-04-16 00:42:09 +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
f761cef5c8 oflow detection in expand_prompt() was faulty (false positives).
The count was based on strlcat() return value which includes the
length of the entire string.
2003-04-01 14:58:55 +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
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
0b0f8d6d32 Add %U and %H escapes and redo prompt rewriting. "%%" now gets collapsed
to "%" as was originally intended.  This also gets rid of lastchar (does
lookahead instead of lookback) which should simplify the logic slightly.
2002-12-14 19:15:30 +00:00
Todd C. Miller
982218c343 Don't call set_perms() when doing timestamp stuff unless timestamp_uid != 0. 2002-05-05 00:45:51 +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
db63aefb21 The the loop used to expand %h and %u, the lastchar variable was not being
initialized.  This means that if the last char in the prompt is '%' and the
first char is 'h' or 'u' a extra copy of the host or user name would be
copied, for which space had not been allocated.
2002-04-25 15:30:12 +00:00
Todd C. Miller
46dd419cd9 o Reorder some headers and use STDC_HEADERS define properly
o Update copyright year
2001-12-14 19:52:47 +00:00
Todd C. Miller
dea43637e8 fix I_TS_TIMEOUT vs. I_TIMESTAMP_TIMEOUT pasto in previous commit 2001-11-02 20:59:22 +00:00
Todd C. Miller
3550d52a90 Add new T_UINT type that most things use instead of T_INT
If timestamp_timeout is < 0 then treat the ticket as never expiring
(to be expired manually by the user).
2001-11-02 20:56:20 +00:00
Todd C. Miller
4f69069533 Use stashed user_gid when checking against exempt gid since sudo
sets its gid to a a value that makes sudoers readable.  Previously
if you used gid 0 as the exempt group everyone would be exempt.
From Paul Kranenburg <pk@cs.few.eur.nl>
2001-03-30 13:54:27 +00:00
Todd C. Miller
d956d77528 Move defaults info into its own files from which we generate
.h and .c files.  This makes adding or rearranging variables
much simpler.
2000-12-31 01:38:37 +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
192b2ae6c3 If the targetpw flag is set, use target username as part of the timestamp path.
If tty tickets are in effect cat the tty and the target username with a
':' as the separator.
2000-05-10 04:56:28 +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
fc08d7004c Move user_is_exempt prototype into sudo.h 2000-02-15 23:36:04 +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
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
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
Todd C. Miller
2386dc1b45 o Add a "pedentic" flag to the parser. This makes sudo warn in cases
where an alias may be used before it is defined.  Only turned on for visudo
and testsudoers.
o Add --disable-authentication option that makes sudo not require
authentication by default.  The PASSWD tag can be used to require
authentication for an entry.  We no longer overload --without-passwd.
1999-08-12 14:37:27 +00:00
Todd C. Miller
76148d5316 o Move lock_file() and touch() into fileops.c so visudo can use them
o Visudo now locks the sudoers temp file instead of bailing when
the temp file already exists.  This fixes the problem of stale
temp files but it does *require* that you not try to put the
temp file in a world-writable directory.  This shoud not be
an issue as the temp file should live in the same dir as sudoers.
o Visudo now only installs the temp file as sudoers if it changed.
1999-08-07 09:59:43 +00:00