Commit Graph

204 Commits

Author SHA1 Message Date
Todd C. Miller
4f03e9180c Reset used_runas to FALSE when re-intializing the parser. 2004-08-11 18:29:10 +00:00
Todd C. Miller
600e9e3942 Don't pass user_cmnd and user_args to command_matches(), just use
the globals there.  Since we keep state with statics anyway it is
misleading to pretend that passing in different cmnd and cmnd_args
will work.
2004-08-02 18:44:58 +00:00
Todd C. Miller
ce1b21d42c Add a check in visudo for runas_default being set after it has already
been used.
2004-06-08 19:55:53 +00:00
Todd C. Miller
13b0c693d2 Add a MATCHED macro for testing whether foo_matches has been set to
TRUE or FALSE.  This is more readable than checking for >=0 or < 0.
Doesn't change the actual code generated.
2004-06-08 17:53:52 +00:00
Todd C. Miller
713e419fe9 Remove trailing spaces, no actual code changes. 2004-06-06 23:58:11 +00:00
Todd C. Miller
318cd646fe Fix a >=0 that should be <0 that was improperly converted when UNSPEC was added. 2004-06-06 20:22:20 +00:00
Todd C. Miller
4e73e5c38c Add do {} while(0) around pop macro
Set cmnd_matches to UNSPEC, not NOMATCH when resetting it.
2004-06-06 19:54:23 +00:00
Todd C. Miller
a5c99554d4 Fix pastos introduced in SETNMATCH addition. 2004-06-06 19:39:56 +00:00
Todd C. Miller
46e37d41a9 Add NOMATCH and UNSPEC defines (-1 and -2 respectively) and use
these in parse.yacc.  Also in parse.yacc initialize the *_matches
vars to UNSPEC and add two macros, SETMATCH and SETNMATCH for use
when setting *_matches to a value that may be NOMATCH/UNSPEC/TRUE/FALSE.
2004-06-05 17:42:04 +00:00
Todd C. Miller
385372b4d7 Initialize runas to -2, not -1 since we need to be able to distinguish
between the initialized value and the value of a non-match when
passing along the runas value to multiple commands.

The result of this is that an unmatched runas is now set to -1, not 0.
This is required now that parse.c treats a FALSE value for runas as
being explicitly denied.
2004-06-05 15:17:10 +00:00
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