Commit Graph

155 Commits

Author SHA1 Message Date
Todd C. Miller
24155a405a Use WIFEXITED and WEXITSTATUS macros. If there are systems out there
that want to run sudo that still don't support these we can try to
deal with that later.
2004-01-22 02:44:13 +00:00
Todd C. Miller
f068ee01c4 Prefer VISUAL over EDITOR like old vipw did. 2004-01-20 19:18:44 +00:00
Todd C. Miller
327729a7e6 Add stub set_runaspw() function 2004-01-16 23:09:34 +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
4e74e8c530 add DARPA credit on affected files 2003-04-16 00:42:10 +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
48229cbac6 update copyright year 2003-03-15 20:31:02 +00:00
Todd C. Miller
6e118c64b5 fclose() yyin after each yyparse() is done and use fopen() instead of
using freopen().
2003-01-07 00:10:04 +00:00
Todd C. Miller
35cf881d76 o The parser needs sudoers to end with a newline but some editors (emacs) may
not add one.  Check for a missing newline at EOF and add one if needed.
o Set quiet flag during initial sudoers parse (to get options)
o Move yyrestart() call and always use freopen() to open yyin after
  initial sudoers parse.
2003-01-06 20:06:12 +00:00
Todd C. Miller
1b6bfbf452 Don't use memory after it has been freed. 2002-01-17 15:35:54 +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
3c4691a1d0 o Add -f option (alternate sudoers file)
o Convert to use getopt(3)
2001-12-12 00:41:33 +00:00
Todd C. Miller
8f896ec2e2 In check-only mode, don't create sudoers if it does not already exist. 2001-12-11 23:22:54 +00:00
Todd C. Miller
f7f91aff57 Add check-only mode 2001-12-11 22:51:17 +00:00
Todd C. Miller
241cb64cc4 Kill POSIX_SIGNALS define and old signal support now that we emulate POSIX ones
Also be sure to correctly initialize struct sigaction.
2001-12-08 19:44:30 +00:00
Todd C. Miller
717eb3fdf2 Change 2 Exit() -> exit()
Avoid stdio in Exit() and call _exit() if we are a signal handler.
We no longer print the signal number but the user can just check the
exit value for that.
2001-11-02 17:52:12 +00:00
Todd C. Miller
d6e0c7049e Ignore editor exit value since XPG4 says vi's exit value is the count
of editing errors made (failed searches, etc).
2001-10-11 17:20:33 +00:00
Todd C. Miller
132f59534d pasto 2001-02-23 18:03:46 +00:00
Todd C. Miller
394ececcb8 SA_RESETHAND means the opposite of what I was thinking--oops
To block all signals in old-style signals use ~0, not 0xffffffff
2001-02-17 21:11:41 +00:00
Todd C. Miller
af80178b85 Block all signals in Exit() to avoid a signal race. There is still a
tiny window but I'm not going to worry about it.
2001-01-17 16:34:36 +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
6448c3523e If there was a syntax error and the user just wants to quit, unlink
sudoers if it is zero length.
2000-12-15 04:19:24 +00:00
Todd C. Miller
f14cf7973d 'Q' means ignore parse error, not 'q' 2000-12-15 04:10:54 +00:00
Todd C. Miller
02559d3447 Open sudoers for writing with mode SUDOERS_MODE
From Dimitry Andric <dim@xs4all.nl>
2000-12-15 03:57:53 +00:00
Todd C. Miller
7ce284a132 Use exit(127), not exit(-1) 2000-11-03 14:36:32 +00:00
Todd C. Miller
d9a6458794 Remove extraneous call to init_defaults() and set runas_user to NULL
betweem parses so init_defaults will reset it each time, thus avoiding
a reference to free()d data.
2000-06-05 02:57:10 +00:00
Todd C. Miller
61048797f0 Add a missing check for UserEditor == NULL
Add missing '+' before line number when invoking editor to fix a syntax error
2000-06-04 23:51:05 +00:00
Todd C. Miller
0c061c0376 Visudo now does its own fork/exec instead of calling system(3). 2000-04-01 22:25:41 +00:00
Todd C. Miller
6dd2d9592e Visudo now checks for the existence of an editor and gives a sensible
error if it does not exist.

The path to the editor for visudo is now a colon-separated list of
allowable editors.  If the user has $EDITOR set and it matches
one of the allowed editors that editor will be used.  If not,
the first editor in the list that actually exists is used.
2000-04-01 21:23:28 +00:00
Todd C. Miller
ffca544b6c 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:22 +00:00
Todd C. Miller
5ce1fa96f2 Add support for wildcards in the hostname. 2000-03-23 04:09:53 +00:00
Todd C. Miller
09b23e7b41 Add rootpw, runaspw, and targetpw options. 2000-02-18 17:56:28 +00:00
Todd C. Miller
44c5092fab enveditor -> env_editor 2000-02-18 17:11:43 +00:00
Todd C. Miller
020125336c Add 'editor' and 'enveditor' sudoers defaults and make visudo honor them.
This means that visudo will now parse the sudoers file *before* it is
edited so a bogus sudoers file will cause a warning to go to stderr.
Also, visudo checks the variables once--it does not check them after
each editor run since that could be confusing.
2000-02-16 00:03:44 +00:00
Todd C. Miller
d9790399b3 Fix sudoers locking in visudo. We now lock the sudoers file itself, not
the temp file (since locking the temp file can foul up editors).  The
previous locking scheme didn't work because the fd was closed too early.
2000-01-19 19:07:24 +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
a720dfa30a Treat EOF at whatnow prompt like 'x' instead of looping. 1999-12-16 18:02:14 +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
bbc51dac5c Call yyrestart() on a parse error to reset the lexer state. 1999-11-09 20:12:20 +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
8fcdf8a300 Don't need to worry about catching too many signals since we do locking
on the tmp file.  If a lockfile is really stale, it will be detected
and overwritten.
1999-08-27 21:01:06 +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
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
Todd C. Miller
145992dce2 o /etc/stmp -> /etc/sudoers.tmp since solaris uses stmp as shadow temp file
o _PATH_SUDO_SUDOERS -> _PATH_SUDOERS and _PATH_SUDO_STMP -> _PATH_SUDOERS_TMP
1999-08-06 09:37:03 +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
4dc01cc916 o BSD-style copyright
o Use "struct sudo_user" instead of old globals.
o some cometic cleanup
1999-07-22 12:57:47 +00:00
Todd C. Miller
b144c103f0 stylistic changes 1999-07-12 10:53:09 +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