summaryrefslogtreecommitdiff
path: root/usr.bin/sudo/visudo.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/sudo/visudo.c')
-rw-r--r--usr.bin/sudo/visudo.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/usr.bin/sudo/visudo.c b/usr.bin/sudo/visudo.c
index ca2c3792cd7..7982fcfb4c1 100644
--- a/usr.bin/sudo/visudo.c
+++ b/usr.bin/sudo/visudo.c
@@ -81,7 +81,7 @@ extern int stat __P((const char *, struct stat *));
#endif /* POSIX_SIGNALS && !SA_RESETHAND */
#ifndef lint
-static const char rcsid[] = "$Sudo: visudo.c,v 1.121 2000/01/19 19:07:24 millert Exp $";
+static const char rcsid[] = "$Sudo: visudo.c,v 1.126 2000/03/23 04:38:22 millert Exp $";
#endif /* lint */
/*
@@ -93,6 +93,7 @@ static RETSIGTYPE Exit __P((int));
static void setup_signals __P((void));
int command_matches __P((char *, char *, char *, char *));
int addr_matches __P((char *));
+int hostname_matches __P((char *, char *, char *));
int netgr_matches __P((char *, char *, char *, char *));
int usergr_matches __P((char *, char *));
void init_parser __P((void));
@@ -121,7 +122,7 @@ main(argc, argv)
char **argv;
{
char buf[MAXPATHLEN*2]; /* buffer used for copying files */
- char *Editor = EDITOR; /* editor to use (default is EDITOR */
+ char *Editor; /* editor to use */
int sudoers_fd; /* sudoers file descriptor */
int stmp_fd; /* stmp file descriptor */
int n; /* length parameter */
@@ -158,15 +159,8 @@ main(argc, argv)
exit(1);
}
-#ifdef ENV_EDITOR
- /*
- * If we are allowing EDITOR and VISUAL envariables set Editor
- * base on whichever exists...
- */
- if (!(Editor = getenv("EDITOR")))
- if (!(Editor = getenv("VISUAL")))
- Editor = EDITOR;
-#endif /* ENV_EDITOR */
+ /* Setup defaults data structures. */
+ init_defaults();
/*
* Open sudoers, lock it and stat it.
@@ -216,10 +210,29 @@ main(argc, argv)
(void) close(stmp_fd);
(void) touch(stmp, sudoers_sb.st_mtime);
+
+ /* Parse sudoers to pull in editor and env_editor conf values. */
+ if ((yyin = fopen(stmp, "r"))) {
+ yyout = stdout;
+ init_defaults();
+ init_parser();
+ yyparse();
+ parse_error = FALSE;
+ yyrestart(yyin);
+ fclose(yyin);
+ }
} else
(void) close(stmp_fd);
/*
+ * If we are allowing EDITOR and VISUAL envariables set Editor
+ * base on whichever exists...
+ */
+ if (!def_flag(I_ENV_EDITOR) ||
+ (!(Editor = getenv("EDITOR")) && !(Editor = getenv("VISUAL"))))
+ Editor = def_str(I_EDITOR);
+
+ /*
* Edit the temp file and parse it (for sanity checking)
*/
do {
@@ -394,6 +407,13 @@ addr_matches(n)
}
int
+hostname_matches(s, l, p)
+ char *s, *l, *p;
+{
+ return(TRUE);
+}
+
+int
usergr_matches(g, u)
char *g, *u;
{