Commit Graph

194 Commits

Author SHA1 Message Date
Todd C. Miller
6190f376c1 If the user specified a uid with the -u flag and the uid exists in
the passwd file, set runas_user to the name, not the uid.

When comparing usernames in sudoers, if a name is really a uid (starts
with '#') compare it numerically to pw_uid.
2004-03-24 23:06:34 +00:00
Todd C. Miller
5bc294b715 More to a less restrictive, ISC-style license. 2004-02-13 21:36:43 +00:00
Todd C. Miller
db230cc520 Merge the NOPASSWD/PASSWD and NOEXEC/EXEC rules so that order is not
important.
2004-01-05 19:56:43 +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
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
94567681a7 add DARPA credit on affected files 2003-04-16 00:42:10 +00:00
Todd C. Miller
48229cbac6 update copyright year 2003-03-15 20:31: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
35b2800a8a Use emalloc2 and erealloc3 2003-03-12 22:16:13 +00:00
Todd C. Miller
b34e373908 Add some missing ';' rule terminators that bison warns about. 2003-01-20 21:13:42 +00:00
Todd C. Miller
a8153f4d5d Add support for Defaults>RunasUser 2003-01-17 23:09:45 +00:00
Todd C. Miller
5bf742d282 Add missing yyerror() calls; YYERROR does not seem to call this for us. 2002-11-28 23:43:22 +00:00
Todd C. Miller
fd140ff5da minor sign fixes pointed out by gcc -Wsign-compare 2002-11-22 19:11:47 +00:00
Todd C. Miller
7cc2f3b3e5 Remove Chris Jepeway's email address so people don't bug him ;-) 2002-03-16 00:44:48 +00:00
Todd C. Miller
cf2952dd83 Remove some XXX that are no longer relevant. 2001-12-30 18:41:12 +00:00
Todd C. Miller
ac4aa81153 typo in comment 2001-12-21 21:49:05 +00:00
Todd C. Miller
65fad4df35 o Reorder some headers and use STDC_HEADERS define properly
o Update copyright year
2001-12-14 19:52:54 +00:00
Todd C. Miller
5486390782 o Add a new token, DEFVAR, to indicate a Defaults variable name
o Add support for "+=" and "-=" list operators
 o replace some 1 and 0 with TRUE and FALSE for greater legibility.
2001-12-11 23:06:52 +00:00
Todd C. Miller
f0e806a12c honor quiet mode 2001-12-11 22:53:39 +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
1eeb9cb963 When checking to see if the host/user matches in a defaults spec, check
against TRUE, not just non-zero since it might be -1.
2000-03-24 23:58:59 +00:00
Todd C. Miller
9aeabf1b03 Fully qualified hosts w/ wildcards were not matching the FQHOST token type.
There's really no need for a separate token for fully-qualified vs.
unqualified anymore so FQHOST is now history and hostname_matches
now decides which hostname (short or long) to check based on whether
or not the pattern contains a '.'.
2000-03-23 04:38:20 +00:00
Todd C. Miller
5ce1fa96f2 Add support for wildcards in the hostname. 2000-03-23 04:09:53 +00:00
Todd C. Miller
9e0bae9fc6 update copyright year on changed files 2000-01-17 23:46:26 +00:00
Todd C. Miller
0b59a0974d netgr_matches needs to check shost as well as host since they may be different. 2000-01-11 18:20:41 +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
34d793254d fix parsing of runas lists:
o oprunasuser and runaslist now return a value
o in a runasspec, if a runaslist does not return TRUE, set runas_matches to
  FALSE.  Normally, a runaslist only returns FALSE for explicitly denied
  users.
o since runaslist does not modify the stack there is no need for a push/pop
  in runasalias.
1999-12-05 19:06:09 +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
3a8c0ca966 include strings.h everywhere we include string.h 1999-08-28 09:24:15 +00:00
Todd C. Miller
2b28160a5d minor change to first line printed in -l mode 1999-08-26 09:10:50 +00:00
Todd C. Miller
0d38bef9a7 include strcasecmp() for those without it 1999-08-24 17:37:38 +00:00
Todd C. Miller
51350b2c79 In "sudo -l" mode, the type of the stored (expanded) alias was not
stored with the contents.  This could lead to incorrect output
if the sudoers file had different alias types with the same name.
Normal parsing (ie: not in '-l' mode) is unaffected.
1999-08-24 15:58:39 +00:00
Todd C. Miller
0598093e2c sudoers_lookup() now returns a bitmap instead of an int. This makes it
possible to express things like "failed to validate because user not listed
for this host".  Some thigns that were previously VALIDATE_FOO are now
FLAG_FOO.  This may change later on.

Reorganized code in log_auth() and sudo.c to deal with above changes.

Safer versions of push/pushcp with in the do { ... } while (0) style

parse.yacc now saves info on the stack to allow parse.c to determine
if a user was listed, but not for the host he/she tried to run on.

Added --with-mail-if-no-host option
1999-08-19 16:30:09 +00:00
Todd C. Miller
804e168d90 o NewArgv and NewArgc don't need to be externally visible.
o If pedantic > 1, it is a parse error.
o Add -s (strict) option to visudo which sets pedantic to 2.
1999-08-17 15:29:47 +00:00
Todd C. Miller
b28ac86ab8 In pedantic mode we need to save *all* the aliases, not just those
that match, or we get spurious warnings.
1999-08-17 12:47:53 +00:00
Todd C. Miller
3a8b0be635 o --with-otp deprecated, use --without-passwd instead
o real dependencies in the Makefile
o --with-devel option to enable yacc, lex, and -Wall
o style -- "foo -> bar" becomes "foo->bar"
o ALL goes back to being a token, not a string but don't leak memory
o rename hsotspec -> host in parse.yacc
1999-08-14 15:34:55 +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
2ce523cd1f o add a 'val' element to aliasinfo struct and move -> parse.h
o find_alias() now returns an aliasinfo * instead of boolean
o add_alias() now takes a value parameter to store in the aliasinfo.val
o The cmnd, hostspec, runasuser, and user rules now return:
1) positive match
0) negative match (due to '!')
-1) no match
This means setting $$ explicitly in all cases, which I should have done in
the first place.  It also means that we always store a value that is != -1
and when we see a '!' we can set *_matches to !rv if rv != -1.
The upshot of all of this is that '!' now works the way it should in
lists and some of the rules are more uniform and sensible.
1999-08-09 22:25:17 +00:00
Todd C. Miller
76c801a685 Allow a list of users as the first thing in a user spec, not just a
single entry.  This makes things more uniform, though it does allow
you to write user specs that are hard to read.
1999-08-09 14:35:53 +00:00
Todd C. Miller
16ab377018 o Add '!' correctly when expanding Aliases.
o Add shortcut macros for append() to make things more readable.
o The separator in append() is now a string instead of a char.
o In append(), only prepend the separator if the last char is not a '!'.
  This is a hack but it greatly simplifies '!' handling.
o In -l mode, Runas lists and NOPASSWD/PASSWD tags are now inherited
  across entries in a list (matches current behavior).
o Fix formatting in -l mode such that items in a list are separated by
  a space.  Greatlt improves readability.
o Space for name field in struct aliasinfo is now allocated dyanically
  instead of using a (big) buffer.
o In add_alias(), only search the list once (lsearch instead of lfind + lsearch)
1999-08-04 17:28:47 +00:00
Todd C. Miller
716e0b5433 o Simpler '!' support now that the lexer deals with multiple !'s for us.
o In the case of opFOO, have FOO give a boolean return value and set
  foo_matches in opFOO, not FOO.
o Treat 'ALL' as a string since it gets fill()'d in parse.lex--fixes a
  small memory leak.  In the long run it may be better to just fix parse.lex
  and make ALL back into a token.  However, having it be a string is useful
  since it can be easily passed back to the parent rule if we so desire.
1999-08-04 09:35:56 +00:00
Todd C. Miller
0d732401f4 add 4th term to license similar to term 5 in the apache license 1999-07-31 16:19:50 +00:00
Todd C. Miller
c7fd99aa54 BSD-style copyright. Move parser-specific defines and structs into parse.h + other cosmetic changes 1999-07-22 12:51:18 +00:00
Todd C. Miller
26be17a3d6 Add contribution info in the main comment 1999-07-12 10:25:14 +00:00
Todd C. Miller
63209c1348 only save an entry if user_matches && host_matches, even if the stack is empty (fix for previous commit) 1999-07-08 10:46:28 +00:00
Todd C. Miller
fb54a0311a 1) Always save an entry on the stack if it is empty. This fixes the
-l and -v flags that were broken by earlier parser changes.

2) In a Runas list, don't negate FALSE -> TRUE since that would make !foo
match any time the user specified a runas user (via -u) other than foo.
1999-07-08 10:35:28 +00:00
Todd C. Miller
80287c981c Move interface-related defines to interfaces.h so we don't have to include
<netinet/in.h> everywhere.
1999-05-17 01:36:30 +00:00
Todd C. Miller
850a52aa6f o Replace _PASSWD_LEN braindeath with our own SUDO_MAX_PASS.
It turns out the old DES crypt does the right thing with passwords
   longert than 8 characters.
 o Fix common typo (necesary -> necessary)
 o Update TODO list
1999-05-14 16:30:14 +00:00