2 * Copyright (c) 1996, 1998-2005, 2007-2010
3 * Todd C. Miller <Todd.Miller@courtesan.com>
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * Sponsored in part by the Defense Advanced Research Projects
18 * Agency (DARPA) and Air Force Research Laboratory, Air Force
19 * Materiel Command, USAF, under agreement number F39502-99-1-0512.
23 * Lock the sudoers file for safe editing (ala vipw) and check for parse errors.
34 #include <sys/types.h>
35 #include <sys/param.h>
37 #include <sys/socket.h>
40 # include <sys/file.h>
51 #endif /* STDC_HEADERS */
54 #endif /* HAVE_STRING_H */
57 #endif /* HAVE_STRINGS_H */
60 #endif /* HAVE_UNISTD_H */
67 #include <netinet/in.h>
68 #include <arpa/inet.h>
70 #if TIME_WITH_SYS_TIME
80 #include "interfaces.h"
86 struct sudoersfile *prev, *next;
93 TQ_DECLARE(sudoersfile);
98 static RETSIGTYPE quit __P((int));
99 static char *get_args __P((char *));
100 static char *get_editor __P((char **));
101 static void get_hostname __P((void));
102 static char whatnow __P((void));
103 static int check_aliases __P((int, int));
104 static int check_syntax __P((char *, int, int));
105 static int edit_sudoers __P((struct sudoersfile *, char *, char *, int));
106 static int install_sudoers __P((struct sudoersfile *, int));
107 static int print_unused __P((void *, void *));
108 static int reparse_sudoers __P((char *, char *, int, int));
109 static int run_command __P((char *, char **));
110 static void print_selfref __P((char *, int, int, int));
111 static void print_undefined __P((char *, int, int, int));
112 static void setup_signals __P((void));
113 static void usage __P((void)) __attribute__((__noreturn__));
115 extern void yyerror __P((const char *));
116 extern void yyrestart __P((FILE *));
119 * External globals exported by the parser
121 extern struct rbtree *aliases;
123 extern char *sudoers, *errorfile;
124 extern int errorlineno, parse_error;
135 struct interface *interfaces;
136 struct sudo_user sudo_user;
137 struct passwd *list_pw;
138 static struct sudoersfile_list sudoerslist;
139 static struct rbtree *alias_freelist;
146 struct sudoersfile *sp;
147 char *args, *editor, *sudoers_path;
148 int ch, checkonly, quiet, strict, oldperms;
149 #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
150 extern char *malloc_options;
151 malloc_options = "AFGJPR";
155 if ((Argc = argc) < 1)
161 checkonly = oldperms = quiet = strict = FALSE;
162 sudoers_path = _PATH_SUDOERS;
163 while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) {
166 (void) printf("%s version %s\n", getprogname(), PACKAGE_VERSION);
169 checkonly++; /* check mode */
172 sudoers_path = optarg; /* sudoers file path */
176 strict++; /* strict mode */
179 quiet++; /* quiet mode */
193 /* Mock up a fake sudo_user struct. */
195 if ((sudo_user.pw = sudo_getpwuid(getuid())) == NULL)
196 errorx(1, "you don't exist in the passwd database");
199 /* Setup defaults data structures. */
203 exit(check_syntax(sudoers_path, quiet, strict));
206 * Parse the existing sudoers file(s) in quiet mode to highlight any
207 * existing errors and to pull in editor and env_editor conf values.
209 if ((yyin = open_sudoers(sudoers_path, TRUE, NULL)) == NULL) {
210 error(1, "%s", sudoers_path);
212 init_parser(sudoers_path, 0);
214 (void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER);
216 editor = get_editor(&args);
218 /* Install signal handlers to clean up temp files if we are killed. */
221 /* Edit the sudoers file(s) */
222 tq_foreach_fwd(&sudoerslist, sp) {
225 if (sp != tq_first(&sudoerslist)) {
226 printf("press return to edit %s: ", sp->path);
227 while ((ch = getchar()) != EOF && ch != '\n')
230 edit_sudoers(sp, editor, args, -1);
233 /* Check edited files for a parse error and re-edit any that fail. */
234 reparse_sudoers(editor, args, strict, quiet);
236 /* Install the sudoers temp files. */
237 tq_foreach_fwd(&sudoerslist, sp) {
239 (void) unlink(sp->tpath);
241 (void) install_sudoers(sp, oldperms);
248 * Edit each sudoers file.
249 * Returns TRUE on success, else FALSE.
252 edit_sudoers(sp, editor, args, lineno)
253 struct sudoersfile *sp;
257 int tfd; /* sudoers temp file descriptor */
258 int modified; /* was the file modified? */
259 int ac; /* argument count */
260 char **av; /* argument vector for run_command */
261 char *cp; /* scratch char pointer */
262 char buf[PATH_MAX*2]; /* buffer used for copying files */
263 char linestr[64]; /* string version of lineno */
264 struct timeval tv, tv1, tv2; /* time before and after edit */
265 struct timeval orig_mtim; /* starting mtime of sudoers file */
266 off_t orig_size; /* starting size of sudoers file */
267 ssize_t nread; /* number of bytes read */
268 struct stat sb; /* stat buffer */
271 if (fstat(sp->fd, &sb) == -1)
273 if (stat(sp->path, &sb) == -1)
275 error(1, "can't stat %s", sp->path);
276 orig_size = sb.st_size;
277 mtim_get(&sb, &orig_mtim);
279 /* Create the temp file if needed and set timestamp. */
280 if (sp->tpath == NULL) {
281 easprintf(&sp->tpath, "%s.tmp", sp->path);
282 tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
284 error(1, "%s", sp->tpath);
286 /* Copy sp->path -> sp->tpath and reset the mtime. */
287 if (orig_size != 0) {
288 (void) lseek(sp->fd, (off_t)0, SEEK_SET);
289 while ((nread = read(sp->fd, buf, sizeof(buf))) > 0)
290 if (write(tfd, buf, nread) != nread)
291 error(1, "write error");
293 /* Add missing newline at EOF if needed. */
294 if (nread > 0 && buf[nread - 1] != '\n') {
301 (void) touch(-1, sp->tpath, &orig_mtim);
303 /* Find the length of the argument vector */
304 ac = 3 + (lineno > 0);
309 for (wasblank = FALSE, cp = args; *cp; cp++) {
310 if (isblank((unsigned char) *cp))
319 /* Build up argument vector for the command */
320 av = emalloc2(ac, sizeof(char *));
321 if ((av[0] = strrchr(editor, '/')) != NULL)
327 (void) snprintf(linestr, sizeof(linestr), "+%d", lineno);
331 for ((cp = strtok(args, " \t")); cp; (cp = strtok(NULL, " \t")))
334 av[ac++] = sp->tpath;
339 * We cannot check the editor's exit value against 0 since
340 * XPG4 specifies that vi's exit value is a function of the
341 * number of errors during editing (?!?!).
344 if (run_command(editor, av) != -1) {
349 if (stat(sp->tpath, &sb) < 0) {
350 warningx("cannot stat temporary file (%s), %s unchanged",
351 sp->tpath, sp->path);
354 if (sb.st_size == 0 && orig_size != 0) {
355 warningx("zero length temporary file (%s), %s unchanged",
356 sp->tpath, sp->path);
361 warningx("editor (%s) failed, %s unchanged", editor, sp->path);
365 /* Set modified bit if use changed the file. */
368 if (orig_size == sb.st_size && timevalcmp(&orig_mtim, &tv, ==)) {
370 * If mtime and size match but the user spent no measurable
371 * time in the editor we can't tell if the file was changed.
373 timevalsub(&tv1, &tv2);
374 if (timevalisset(&tv2))
379 * If modified in this edit session, mark as modified.
382 sp->modified = modified;
384 warningx("%s unchanged", sp->tpath);
390 * Parse sudoers after editing and re-edit any ones that caused a parse error.
391 * Returns TRUE on success, else FALSE.
394 reparse_sudoers(editor, args, strict, quiet)
398 struct sudoersfile *sp, *last;
403 * Parse the edited sudoers files and do sanity checking
406 sp = tq_first(&sudoerslist);
407 last = tq_last(&sudoerslist);
408 fp = fopen(sp->tpath, "r+");
410 errorx(1, "can't re-open temporary file (%s), %s unchanged.",
411 sp->tpath, sp->path);
413 /* Clean slate for each parse */
415 init_parser(sp->path, quiet);
417 /* Parse the sudoers temp file */
419 if (yyparse() && !parse_error) {
420 warningx("unabled to parse temporary file (%s), unknown error",
423 errorfile = sp->path;
427 if (!update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER) ||
428 check_aliases(strict, quiet) != 0) {
430 errorfile = sp->path;
435 * Got an error, prompt the user for what to do now
439 case 'Q' : parse_error = FALSE; /* ignore parse error */
441 case 'x' : cleanup(0);
447 /* Edit file with the parse error */
448 tq_foreach_fwd(&sudoerslist, sp) {
449 if (errorfile == NULL || strcmp(sp->path, errorfile) == 0) {
450 edit_sudoers(sp, editor, args, errorlineno);
455 errorx(1, "internal error, can't find %s in list!", sudoers);
458 /* If any new #include directives were added, edit them too. */
459 for (sp = last->next; sp != NULL; sp = sp->next) {
460 printf("press return to edit %s: ", sp->path);
461 while ((ch = getchar()) != EOF && ch != '\n')
463 edit_sudoers(sp, editor, args, errorlineno);
465 } while (parse_error);
471 * Set the owner and mode on a sudoers temp file and
472 * move it into place. Returns TRUE on success, else FALSE.
475 install_sudoers(sp, oldperms)
476 struct sudoersfile *sp;
482 * Change mode and ownership of temp file so when
483 * we move it to sp->path things are kosher.
486 /* Use perms of the existing file. */
488 if (fstat(sp->fd, &sb) == -1)
490 if (stat(sp->path, &sb) == -1)
492 error(1, "can't stat %s", sp->path);
493 (void) chown(sp->tpath, sb.st_uid, sb.st_gid);
494 (void) chmod(sp->tpath, sb.st_mode & 0777);
496 if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
497 warning("unable to set (uid, gid) of %s to (%d, %d)",
498 sp->tpath, SUDOERS_UID, SUDOERS_GID);
501 if (chmod(sp->tpath, SUDOERS_MODE) != 0) {
502 warning("unable to change mode of %s to 0%o", sp->tpath,
509 * Now that sp->tpath is sane (parses ok) it needs to be
510 * rename(2)'d to sp->path. If the rename(2) fails we try using
511 * mv(1) in case sp->tpath and sp->path are on different file systems.
513 if (rename(sp->tpath, sp->path) == 0) {
517 if (errno == EXDEV) {
519 warningx("%s and %s not on the same file system, using mv to rename",
520 sp->tpath, sp->path);
522 /* Build up argument vector for the command */
523 if ((av[0] = strrchr(_PATH_MV, '/')) != NULL)
532 if (run_command(_PATH_MV, av)) {
533 warningx("command failed: '%s %s %s', %s unchanged",
534 _PATH_MV, sp->tpath, sp->path, sp->path);
535 (void) unlink(sp->tpath);
543 warning("error renaming %s, %s unchanged", sp->tpath, sp->path);
544 (void) unlink(sp->tpath);
588 const struct passwd *pw;
590 return (pw->pw_passwd);
594 * Assuming a parse error occurred, prompt the user for what they want
595 * to do now. Returns the first letter of their choice.
603 (void) fputs("What now? ", stdout);
605 for (c = choice; c != '\n' && c != EOF;)
617 (void) puts("Options are:");
618 (void) puts(" (e)dit sudoers file again");
619 (void) puts(" e(x)it without saving changes to sudoers file");
620 (void) puts(" (Q)uit and save changes to sudoers file (DANGER!)\n");
626 * Install signal handlers for visudo.
634 * Setup signal handlers to cleanup nicely.
636 zero_bytes(&sa, sizeof(sa));
637 sigemptyset(&sa.sa_mask);
638 sa.sa_flags = SA_RESTART;
639 sa.sa_handler = quit;
640 (void) sigaction(SIGTERM, &sa, NULL);
641 (void) sigaction(SIGHUP, &sa, NULL);
642 (void) sigaction(SIGINT, &sa, NULL);
643 (void) sigaction(SIGQUIT, &sa, NULL);
647 run_command(path, argv)
654 switch (pid = fork()) {
656 error(1, "unable to run %s", path);
657 break; /* NOTREACHED */
661 closefrom(STDERR_FILENO + 1);
663 warning("unable to run %s", path);
665 break; /* NOTREACHED */
670 rv = sudo_waitpid(pid, &status, 0);
674 } while (rv == -1 && errno == EINTR);
676 if (rv == -1 || !WIFEXITED(status))
678 return(WEXITSTATUS(status));
682 check_syntax(sudoers_path, quiet, strict)
690 if ((yyin = fopen(sudoers_path, "r")) == NULL) {
692 warning("unable to open %s", sudoers_path);
695 init_parser(sudoers_path, quiet);
696 if (yyparse() && !parse_error) {
698 warningx("failed to parse %s file, unknown error", sudoers_path);
700 errorfile = sudoers_path;
702 if (!parse_error && check_aliases(strict, quiet) != 0) {
704 errorfile = sudoers_path;
709 if (errorlineno != -1)
710 (void) printf("parse error in %s near line %d\n", errorfile,
713 (void) printf("parse error in %s\n", errorfile);
715 (void) printf("%s: parsed OK\n", sudoers_path);
718 /* Check mode and owner in strict mode. */
720 if (strict && fstat(fileno(yyin), &sb) == 0)
722 if (strict && stat(sudoers_path, &sb) == 0)
725 if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
728 fprintf(stderr, "%s: wrong owner (uid, gid) should be (%d, %d)\n",
729 sudoers_path, SUDOERS_UID, SUDOERS_GID);
732 if ((sb.st_mode & 07777) != SUDOERS_MODE) {
735 fprintf(stderr, "%s: bad permissions, should be mode 0%o\n",
736 sudoers_path, SUDOERS_MODE);
745 * Used to open (and lock) the initial sudoers file and to also open
746 * any subsequent files #included via a callback from the parser.
749 open_sudoers(path, doedit, keepopen)
754 struct sudoersfile *entry;
757 /* Check for existing entry */
758 tq_foreach_fwd(&sudoerslist, entry) {
759 if (strcmp(path, entry->path) == 0)
763 entry = emalloc(sizeof(*entry));
764 entry->path = estrdup(path);
768 entry->fd = open(entry->path, O_RDWR | O_CREAT, SUDOERS_MODE);
770 entry->doedit = doedit;
771 if (entry->fd == -1) {
772 warning("%s", entry->path);
776 if (!lock_file(entry->fd, SUDO_TLOCK))
777 errorx(1, "%s busy, try again later", entry->path);
778 if ((fp = fdopen(entry->fd, "r")) == NULL)
779 error(1, "%s", entry->path);
780 tq_append(&sudoerslist, entry);
782 /* Already exists, open .tmp version if there is one. */
783 if (entry->tpath != NULL) {
784 if ((fp = fopen(entry->tpath, "r")) == NULL)
785 error(1, "%s", entry->tpath);
787 if ((fp = fdopen(entry->fd, "r")) == NULL)
788 error(1, "%s", entry->path);
792 if (keepopen != NULL)
801 char *Editor, *EditorArgs, *EditorPath, *UserEditor, *UserEditorArgs;
804 * Check VISUAL and EDITOR environment variables to see which editor
805 * the user wants to use (we may not end up using it though).
806 * If the path is not fully-qualified, make it so and check that
807 * the specified executable actually exists.
809 UserEditorArgs = NULL;
810 if ((UserEditor = getenv("VISUAL")) == NULL || *UserEditor == '\0')
811 UserEditor = getenv("EDITOR");
812 if (UserEditor && *UserEditor == '\0')
814 else if (UserEditor) {
815 UserEditorArgs = get_args(UserEditor);
816 if (find_path(UserEditor, &Editor, NULL, getenv("PATH"), 0) == FOUND) {
819 if (def_env_editor) {
820 /* If we are honoring $EDITOR this is a fatal error. */
821 errorx(1, "specified editor (%s) doesn't exist!", UserEditor);
823 /* Otherwise, just ignore $EDITOR. */
830 * See if we can use the user's choice of editors either because
831 * we allow any $EDITOR or because $EDITOR is in the allowable list.
833 Editor = EditorArgs = EditorPath = NULL;
834 if (def_env_editor && UserEditor) {
836 EditorArgs = UserEditorArgs;
837 } else if (UserEditor) {
838 struct stat editor_sb;
839 struct stat user_editor_sb;
840 char *base, *userbase;
842 if (stat(UserEditor, &user_editor_sb) != 0) {
843 /* Should never happen since we already checked above. */
844 error(1, "unable to stat editor (%s)", UserEditor);
846 EditorPath = estrdup(def_editor);
847 Editor = strtok(EditorPath, ":");
849 EditorArgs = get_args(Editor);
851 * Both Editor and UserEditor should be fully qualified but
854 if ((base = strrchr(Editor, '/')) == NULL)
856 if ((userbase = strrchr(UserEditor, '/')) == NULL) {
863 * We compare the basenames first and then use stat to match
866 if (strcmp(base, userbase) == 0) {
867 if (stat(Editor, &editor_sb) == 0 && S_ISREG(editor_sb.st_mode)
868 && (editor_sb.st_mode & 0000111) &&
869 editor_sb.st_dev == user_editor_sb.st_dev &&
870 editor_sb.st_ino == user_editor_sb.st_ino)
873 } while ((Editor = strtok(NULL, ":")));
877 * Can't use $EDITOR, try each element of def_editor until we
878 * find one that exists, is regular, and is executable.
880 if (Editor == NULL || *Editor == '\0') {
882 EditorPath = estrdup(def_editor);
883 Editor = strtok(EditorPath, ":");
885 EditorArgs = get_args(Editor);
886 if (sudo_goodpath(Editor, NULL))
888 } while ((Editor = strtok(NULL, ":")));
890 /* Bleah, none of the editors existed! */
891 if (Editor == NULL || *Editor == '\0')
892 errorx(1, "no editor found (editor path = %s)", def_editor);
899 * Split out any command line arguments and return them.
908 while (*args && !isblank((unsigned char) *args))
912 while (*args && isblank((unsigned char) *args))
915 return(*args ? args : NULL);
919 * Look up the hostname and set user_host and user_shost.
924 char *p, thost[MAXHOSTNAMELEN + 1];
926 if (gethostname(thost, sizeof(thost)) != 0) {
927 user_host = user_shost = "localhost";
930 thost[sizeof(thost) - 1] = '\0';
931 user_host = estrdup(thost);
933 if ((p = strchr(user_host, '.'))) {
935 user_shost = estrdup(user_host);
938 user_shost = user_host;
943 alias_remove_recursive(name, type, strict, quiet)
953 if ((a = alias_find(name, type)) != NULL) {
954 tq_foreach_fwd(&a->members, m) {
955 if (m->type == ALIAS) {
956 if (strcmp(name, m->name) == 0) {
957 print_selfref(m->name, type, strict, quiet);
960 if (!alias_remove_recursive(m->name, type, strict, quiet))
967 a = alias_remove(name, type);
969 rbinsert(alias_freelist, a);
974 * Iterate through the sudoers datastructures looking for undefined
975 * aliases or unused aliases.
978 check_aliases(strict, quiet)
983 struct member *m, *binding;
984 struct privilege *priv;
987 int atype, error = 0;
989 alias_freelist = rbcreate(alias_compare);
992 tq_foreach_fwd(&userspecs, us) {
993 tq_foreach_fwd(&us->users, m) {
994 if (m->type == ALIAS) {
996 if (alias_find(m->name, USERALIAS) == NULL) {
997 print_undefined(m->name, USERALIAS, strict, quiet);
1002 tq_foreach_fwd(&us->privileges, priv) {
1003 tq_foreach_fwd(&priv->hostlist, m) {
1004 if (m->type == ALIAS) {
1006 if (alias_find(m->name, HOSTALIAS) == NULL) {
1007 print_undefined(m->name, HOSTALIAS, strict, quiet);
1012 tq_foreach_fwd(&priv->cmndlist, cs) {
1013 tq_foreach_fwd(&cs->runasuserlist, m) {
1014 if (m->type == ALIAS) {
1016 if (alias_find(m->name, RUNASALIAS) == NULL) {
1017 print_undefined(m->name, RUNASALIAS, strict, quiet);
1022 if ((m = cs->cmnd)->type == ALIAS) {
1024 if (alias_find(m->name, CMNDALIAS) == NULL) {
1025 print_undefined(m->name, CMNDALIAS, strict, quiet);
1033 /* Reverse check (destructive) */
1034 tq_foreach_fwd(&userspecs, us) {
1035 tq_foreach_fwd(&us->users, m) {
1036 if (m->type == ALIAS) {
1037 if (!alias_remove_recursive(m->name, USERALIAS, strict, quiet))
1041 tq_foreach_fwd(&us->privileges, priv) {
1042 tq_foreach_fwd(&priv->hostlist, m) {
1043 if (m->type == ALIAS)
1044 if (!alias_remove_recursive(m->name, HOSTALIAS, strict,
1048 tq_foreach_fwd(&priv->cmndlist, cs) {
1049 tq_foreach_fwd(&cs->runasuserlist, m) {
1050 if (m->type == ALIAS)
1051 if (!alias_remove_recursive(m->name, RUNASALIAS,
1055 if ((m = cs->cmnd)->type == ALIAS)
1056 if (!alias_remove_recursive(m->name, CMNDALIAS, strict,
1062 tq_foreach_fwd(&defaults, d) {
1070 case DEFAULTS_RUNAS:
1077 continue; /* not an alias */
1079 tq_foreach_fwd(&d->binding, binding) {
1080 for (m = binding; m != NULL; m = m->next) {
1081 if (m->type == ALIAS)
1082 if (!alias_remove_recursive(m->name, atype, strict, quiet))
1087 rbdestroy(alias_freelist, alias_free);
1089 /* If all aliases were referenced we will have an empty tree. */
1090 if (!no_aliases() && !quiet)
1091 alias_apply(print_unused, strict ? "Error" : "Warning");
1093 return (strict ? error : 0);
1097 print_undefined(name, type, strict, quiet)
1104 warningx("%s: %s_Alias `%s' referenced but not defined",
1105 strict ? "Error" : "Warning",
1106 type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
1107 type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
1113 print_selfref(name, type, strict, quiet)
1120 warningx("%s: %s_Alias `%s' references self",
1121 strict ? "Error" : "Warning",
1122 type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
1123 type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
1129 print_unused(v1, v2)
1133 struct alias *a = (struct alias *)v1;
1134 char *prefix = (char *)v2;
1136 warningx("%s: unused %s_Alias %s", prefix,
1137 a->type == HOSTALIAS ? "Host" : a->type == CMNDALIAS ? "Cmnd" :
1138 a->type == USERALIAS ? "User" : a->type == RUNASALIAS ? "Runas" :
1139 "Unknown", a->name);
1144 * Unlink any sudoers temp files that remain.
1150 struct sudoersfile *sp;
1152 tq_foreach_fwd(&sudoerslist, sp) {
1153 if (sp->tpath != NULL)
1154 (void) unlink(sp->tpath);
1163 * Unlink sudoers temp files (if any) and exit.
1170 #define emsg " exiting due to signal.\n"
1171 write(STDERR_FILENO, getprogname(), strlen(getprogname()));
1172 write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
1179 (void) fprintf(stderr, "usage: %s [-c] [-q] [-s] [-V] [-f sudoers]\n",