2 * Copyright (c) 1996, 1998-2005, 2007-2009
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 */
55 # ifdef HAVE_STRINGS_H
58 #endif /* HAVE_STRING_H */
61 #endif /* HAVE_UNISTD_H */
68 #include <netinet/in.h>
69 #include <arpa/inet.h>
71 #if TIME_WITH_SYS_TIME
80 # include <emul/timespec.h>
84 #include "interfaces.h"
96 struct sudoersfile *next;
100 * Function prototypes
102 static RETSIGTYPE quit __P((int));
103 static char *get_args __P((char *));
104 static char *get_editor __P((char **));
105 static void get_hostname __P((void));
106 static char whatnow __P((void));
107 static int check_aliases __P((int, int));
108 static int check_syntax __P((char *, int, int));
109 static int edit_sudoers __P((struct sudoersfile *, char *, char *, int));
110 static int install_sudoers __P((struct sudoersfile *, int));
111 static int print_unused __P((void *, void *));
112 static int reparse_sudoers __P((char *, char *, int, int));
113 static int run_command __P((char *, char **));
114 static void print_selfref __P((char *, int, int, int));
115 static void print_undefined __P((char *, int, int, int));
116 static void setup_signals __P((void));
117 static void usage __P((void)) __attribute__((__noreturn__));
119 extern void yyerror __P((const char *));
120 extern void yyrestart __P((FILE *));
123 * External globals exported by the parser
125 extern struct rbtree *aliases;
127 extern char *sudoers, *errorfile;
128 extern int errorlineno, parse_error;
139 struct interface *interfaces;
140 struct sudo_user sudo_user;
141 struct passwd *list_pw;
142 static struct sudoerslist {
143 struct sudoersfile *first, *last;
145 static struct rbtree *alias_freelist;
152 struct sudoersfile *sp;
153 char *args, *editor, *sudoers_path;
154 int ch, checkonly, quiet, strict, oldperms;
155 #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
156 extern char *malloc_options;
157 malloc_options = "AFGJPR";
161 if ((Argc = argc) < 1)
167 checkonly = oldperms = quiet = strict = FALSE;
168 sudoers_path = _PATH_SUDOERS;
169 while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) {
172 (void) printf("%s version %s\n", getprogname(), PACKAGE_VERSION);
175 checkonly++; /* check mode */
178 sudoers_path = optarg; /* sudoers file path */
182 strict++; /* strict mode */
185 quiet++; /* quiet mode */
199 /* Mock up a fake sudo_user struct. */
201 if ((sudo_user.pw = sudo_getpwuid(getuid())) == NULL)
202 errorx(1, "you don't exist in the passwd database");
205 /* Setup defaults data structures. */
209 exit(check_syntax(sudoers_path, quiet, strict));
212 * Parse the existing sudoers file(s) in quiet mode to highlight any
213 * existing errors and to pull in editor and env_editor conf values.
215 if ((yyin = open_sudoers(sudoers_path, TRUE, NULL)) == NULL) {
216 error(1, "%s", sudoers_path);
218 init_parser(sudoers_path, 0);
220 (void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER);
222 editor = get_editor(&args);
224 /* Install signal handlers to clean up temp files if we are killed. */
227 /* Edit the sudoers file(s) */
228 tq_foreach_fwd(&sudoerslist, sp) {
231 if (sp != tq_first(&sudoerslist)) {
232 printf("press return to edit %s: ", sp->path);
233 while ((ch = getchar()) != EOF && ch != '\n')
236 edit_sudoers(sp, editor, args, -1);
239 /* Check edited files for a parse error and re-edit any that fail. */
240 reparse_sudoers(editor, args, strict, quiet);
242 /* Install the sudoers temp files. */
243 tq_foreach_fwd(&sudoerslist, sp) {
245 (void) unlink(sp->tpath);
247 (void) install_sudoers(sp, oldperms);
254 * Edit each sudoers file.
255 * Returns TRUE on success, else FALSE.
258 edit_sudoers(sp, editor, args, lineno)
259 struct sudoersfile *sp;
263 int tfd; /* sudoers temp file descriptor */
264 int modified; /* was the file modified? */
265 int ac; /* argument count */
266 char **av; /* argument vector for run_command */
267 char *cp; /* scratch char pointer */
268 char buf[PATH_MAX*2]; /* buffer used for copying files */
269 char linestr[64]; /* string version of lineno */
270 struct timespec ts1, ts2; /* time before and after edit */
271 struct timespec orig_mtim; /* starting mtime of sudoers file */
272 off_t orig_size; /* starting size of sudoers file */
273 ssize_t nread; /* number of bytes read */
274 struct stat sb; /* stat buffer */
277 if (fstat(sp->fd, &sb) == -1)
279 if (stat(sp->path, &sb) == -1)
281 error(1, "can't stat %s", sp->path);
282 orig_size = sb.st_size;
283 orig_mtim.tv_sec = mtim_getsec(sb);
284 orig_mtim.tv_nsec = mtim_getnsec(sb);
286 /* Create the temp file if needed and set timestamp. */
287 if (sp->tpath == NULL) {
288 easprintf(&sp->tpath, "%s.tmp", sp->path);
289 tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
291 error(1, "%s", sp->tpath);
293 /* Copy sp->path -> sp->tpath and reset the mtime. */
294 if (orig_size != 0) {
295 (void) lseek(sp->fd, (off_t)0, SEEK_SET);
296 while ((nread = read(sp->fd, buf, sizeof(buf))) > 0)
297 if (write(tfd, buf, nread) != nread)
298 error(1, "write error");
300 /* Add missing newline at EOF if needed. */
301 if (nread > 0 && buf[nread - 1] != '\n') {
308 (void) touch(-1, sp->tpath, &orig_mtim);
310 /* Find the length of the argument vector */
311 ac = 3 + (lineno > 0);
316 for (wasblank = FALSE, cp = args; *cp; cp++) {
317 if (isblank((unsigned char) *cp))
326 /* Build up argument vector for the command */
327 av = emalloc2(ac, sizeof(char *));
328 if ((av[0] = strrchr(editor, '/')) != NULL)
334 (void) snprintf(linestr, sizeof(linestr), "+%d", lineno);
338 for ((cp = strtok(args, " \t")); cp; (cp = strtok(NULL, " \t")))
341 av[ac++] = sp->tpath;
346 * We cannot check the editor's exit value against 0 since
347 * XPG4 specifies that vi's exit value is a function of the
348 * number of errors during editing (?!?!).
351 if (run_command(editor, av) != -1) {
356 if (stat(sp->tpath, &sb) < 0) {
357 warningx("cannot stat temporary file (%s), %s unchanged",
358 sp->tpath, sp->path);
361 if (sb.st_size == 0 && orig_size != 0) {
362 warningx("zero length temporary file (%s), %s unchanged",
363 sp->tpath, sp->path);
368 warningx("editor (%s) failed, %s unchanged", editor, sp->path);
372 /* Set modified bit if use changed the file. */
374 if (orig_size == sb.st_size &&
375 orig_mtim.tv_sec == mtim_getsec(sb) &&
376 orig_mtim.tv_nsec == mtim_getnsec(sb)) {
378 * If mtime and size match but the user spent no measurable
379 * time in the editor we can't tell if the file was changed.
381 #ifdef HAVE_TIMESPECSUB2
382 timespecsub(&ts1, &ts2);
384 timespecsub(&ts1, &ts2, &ts2);
386 if (timespecisset(&ts2))
391 * If modified in this edit session, mark as modified.
394 sp->modified = modified;
396 warningx("%s unchanged", sp->tpath);
402 * Parse sudoers after editing and re-edit any ones that caused a parse error.
403 * Returns TRUE on success, else FALSE.
406 reparse_sudoers(editor, args, strict, quiet)
410 struct sudoersfile *sp, *last;
415 * Parse the edited sudoers files and do sanity checking
418 sp = tq_first(&sudoerslist);
419 last = tq_last(&sudoerslist);
420 fp = fopen(sp->tpath, "r+");
422 errorx(1, "can't re-open temporary file (%s), %s unchanged.",
423 sp->tpath, sp->path);
425 /* Clean slate for each parse */
427 init_parser(sp->path, quiet);
429 /* Parse the sudoers temp file */
431 if (yyparse() && !parse_error) {
432 warningx("unabled to parse temporary file (%s), unknown error",
435 errorfile = sp->path;
438 if (!parse_error && check_aliases(strict, quiet) != 0) {
440 errorfile = sp->path;
444 * Got an error, prompt the user for what to do now
448 case 'Q' : parse_error = FALSE; /* ignore parse error */
450 case 'x' : cleanup(0);
456 /* Edit file with the parse error */
457 tq_foreach_fwd(&sudoerslist, sp) {
458 if (errorfile == NULL || strcmp(sp->path, errorfile) == 0) {
459 edit_sudoers(sp, editor, args, errorlineno);
464 errorx(1, "internal error, can't find %s in list!", sudoers);
467 /* If any new #include directives were added, edit them too. */
468 for (sp = last->next; sp != NULL; sp = sp->next) {
469 printf("press return to edit %s: ", sp->path);
470 while ((ch = getchar()) != EOF && ch != '\n')
472 edit_sudoers(sp, editor, args, errorlineno);
474 } while (parse_error);
480 * Set the owner and mode on a sudoers temp file and
481 * move it into place. Returns TRUE on success, else FALSE.
484 install_sudoers(sp, oldperms)
485 struct sudoersfile *sp;
491 * Change mode and ownership of temp file so when
492 * we move it to sp->path things are kosher.
495 /* Use perms of the existing file. */
497 if (fstat(sp->fd, &sb) == -1)
499 if (stat(sp->path, &sb) == -1)
501 error(1, "can't stat %s", sp->path);
502 (void) chown(sp->tpath, sb.st_uid, sb.st_gid);
503 (void) chmod(sp->tpath, sb.st_mode & 0777);
505 if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
506 warning("unable to set (uid, gid) of %s to (%d, %d)",
507 sp->tpath, SUDOERS_UID, SUDOERS_GID);
510 if (chmod(sp->tpath, SUDOERS_MODE) != 0) {
511 warning("unable to change mode of %s to 0%o", sp->tpath,
518 * Now that sp->tpath is sane (parses ok) it needs to be
519 * rename(2)'d to sp->path. If the rename(2) fails we try using
520 * mv(1) in case sp->tpath and sp->path are on different file systems.
522 if (rename(sp->tpath, sp->path) == 0) {
526 if (errno == EXDEV) {
528 warningx("%s and %s not on the same file system, using mv to rename",
529 sp->tpath, sp->path);
531 /* Build up argument vector for the command */
532 if ((av[0] = strrchr(_PATH_MV, '/')) != NULL)
541 if (run_command(_PATH_MV, av)) {
542 warningx("command failed: '%s %s %s', %s unchanged",
543 _PATH_MV, sp->tpath, sp->path, sp->path);
544 (void) unlink(sp->tpath);
552 warning("error renaming %s, %s unchanged", sp->tpath, sp->path);
553 (void) unlink(sp->tpath);
597 const struct passwd *pw;
599 return (pw->pw_passwd);
603 * Assuming a parse error occurred, prompt the user for what they want
604 * to do now. Returns the first letter of their choice.
612 (void) fputs("What now? ", stdout);
614 for (c = choice; c != '\n' && c != EOF;)
626 (void) puts("Options are:");
627 (void) puts(" (e)dit sudoers file again");
628 (void) puts(" e(x)it without saving changes to sudoers file");
629 (void) puts(" (Q)uit and save changes to sudoers file (DANGER!)\n");
635 * Install signal handlers for visudo.
643 * Setup signal handlers to cleanup nicely.
645 zero_bytes(&sa, sizeof(sa));
646 sigemptyset(&sa.sa_mask);
647 sa.sa_flags = SA_RESTART;
648 sa.sa_handler = quit;
649 (void) sigaction(SIGTERM, &sa, NULL);
650 (void) sigaction(SIGHUP, &sa, NULL);
651 (void) sigaction(SIGINT, &sa, NULL);
652 (void) sigaction(SIGQUIT, &sa, NULL);
656 run_command(path, argv)
663 switch (pid = fork()) {
665 error(1, "unable to run %s", path);
666 break; /* NOTREACHED */
670 closefrom(STDERR_FILENO + 1);
672 warning("unable to run %s", path);
674 break; /* NOTREACHED */
679 rv = sudo_waitpid(pid, &status, 0);
683 } while (rv == -1 && errno == EINTR);
685 if (rv == -1 || !WIFEXITED(status))
687 return(WEXITSTATUS(status));
691 check_syntax(sudoers_path, quiet, strict)
699 if ((yyin = fopen(sudoers_path, "r")) == NULL) {
701 warning("unable to open %s", sudoers_path);
704 init_parser(sudoers_path, quiet);
705 if (yyparse() && !parse_error) {
707 warningx("failed to parse %s file, unknown error", sudoers_path);
709 errorfile = sudoers_path;
711 if (!parse_error && check_aliases(strict, quiet) != 0) {
713 errorfile = sudoers_path;
718 if (errorlineno != -1)
719 (void) printf("parse error in %s near line %d\n", errorfile,
722 (void) printf("parse error in %s\n", errorfile);
724 (void) printf("%s: parsed OK\n", sudoers_path);
727 /* Check mode and owner in strict mode. */
729 if (strict && fstat(fileno(yyin), &sb) == 0)
731 if (strict && stat(sudoers_path, &sb) == 0)
734 if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
737 fprintf(stderr, "%s: wrong owner (uid, gid) should be (%d, %d)\n",
738 sudoers_path, SUDOERS_UID, SUDOERS_GID);
741 if ((sb.st_mode & 07777) != SUDOERS_MODE) {
744 fprintf(stderr, "%s: bad permissions, should be mode 0%o\n",
745 sudoers_path, SUDOERS_MODE);
754 * Used to open (and lock) the initial sudoers file and to also open
755 * any subsequent files #included via a callback from the parser.
758 open_sudoers(path, doedit, keepopen)
763 struct sudoersfile *entry;
766 /* Check for existing entry */
767 tq_foreach_fwd(&sudoerslist, entry) {
768 if (strcmp(path, entry->path) == 0)
772 entry = emalloc(sizeof(*entry));
773 entry->path = estrdup(path);
776 entry->fd = open(entry->path, O_RDWR | O_CREAT, SUDOERS_MODE);
779 entry->doedit = doedit;
780 if (entry->fd == -1) {
781 warning("%s", entry->path);
785 if (!lock_file(entry->fd, SUDO_TLOCK))
786 errorx(1, "%s busy, try again later", entry->path);
787 if ((fp = fdopen(entry->fd, "r")) == NULL)
788 error(1, "%s", entry->path);
789 /* XXX - macro here? */
790 if (sudoerslist.last == NULL)
791 sudoerslist.first = sudoerslist.last = entry;
793 sudoerslist.last->next = entry;
794 sudoerslist.last = entry;
797 /* Already exists, open .tmp version if there is one. */
798 if (entry->tpath != NULL) {
799 if ((fp = fopen(entry->tpath, "r")) == NULL)
800 error(1, "%s", entry->tpath);
802 if ((fp = fdopen(entry->fd, "r")) == NULL)
803 error(1, "%s", entry->path);
807 if (keepopen != NULL)
816 char *Editor, *EditorArgs, *EditorPath, *UserEditor, *UserEditorArgs;
819 * Check VISUAL and EDITOR environment variables to see which editor
820 * the user wants to use (we may not end up using it though).
821 * If the path is not fully-qualified, make it so and check that
822 * the specified executable actually exists.
824 UserEditorArgs = NULL;
825 if ((UserEditor = getenv("VISUAL")) == NULL || *UserEditor == '\0')
826 UserEditor = getenv("EDITOR");
827 if (UserEditor && *UserEditor == '\0')
829 else if (UserEditor) {
830 UserEditorArgs = get_args(UserEditor);
831 if (find_path(UserEditor, &Editor, NULL, getenv("PATH")) == FOUND) {
834 if (def_env_editor) {
835 /* If we are honoring $EDITOR this is a fatal error. */
836 errorx(1, "specified editor (%s) doesn't exist!", UserEditor);
838 /* Otherwise, just ignore $EDITOR. */
845 * See if we can use the user's choice of editors either because
846 * we allow any $EDITOR or because $EDITOR is in the allowable list.
848 Editor = EditorArgs = EditorPath = NULL;
849 if (def_env_editor && UserEditor) {
851 EditorArgs = UserEditorArgs;
852 } else if (UserEditor) {
853 struct stat editor_sb;
854 struct stat user_editor_sb;
855 char *base, *userbase;
857 if (stat(UserEditor, &user_editor_sb) != 0) {
858 /* Should never happen since we already checked above. */
859 error(1, "unable to stat editor (%s)", UserEditor);
861 EditorPath = estrdup(def_editor);
862 Editor = strtok(EditorPath, ":");
864 EditorArgs = get_args(Editor);
866 * Both Editor and UserEditor should be fully qualified but
869 if ((base = strrchr(Editor, '/')) == NULL)
871 if ((userbase = strrchr(UserEditor, '/')) == NULL) {
878 * We compare the basenames first and then use stat to match
881 if (strcmp(base, userbase) == 0) {
882 if (stat(Editor, &editor_sb) == 0 && S_ISREG(editor_sb.st_mode)
883 && (editor_sb.st_mode & 0000111) &&
884 editor_sb.st_dev == user_editor_sb.st_dev &&
885 editor_sb.st_ino == user_editor_sb.st_ino)
888 } while ((Editor = strtok(NULL, ":")));
892 * Can't use $EDITOR, try each element of def_editor until we
893 * find one that exists, is regular, and is executable.
895 if (Editor == NULL || *Editor == '\0') {
897 EditorPath = estrdup(def_editor);
898 Editor = strtok(EditorPath, ":");
900 EditorArgs = get_args(Editor);
901 if (sudo_goodpath(Editor, NULL))
903 } while ((Editor = strtok(NULL, ":")));
905 /* Bleah, none of the editors existed! */
906 if (Editor == NULL || *Editor == '\0')
907 errorx(1, "no editor found (editor path = %s)", def_editor);
914 * Split out any command line arguments and return them.
923 while (*args && !isblank((unsigned char) *args))
927 while (*args && isblank((unsigned char) *args))
930 return(*args ? args : NULL);
934 * Look up the hostname and set user_host and user_shost.
939 char *p, thost[MAXHOSTNAMELEN + 1];
941 if (gethostname(thost, sizeof(thost)) != 0) {
942 user_host = user_shost = "localhost";
945 thost[sizeof(thost) - 1] = '\0';
946 user_host = estrdup(thost);
948 if ((p = strchr(user_host, '.'))) {
950 user_shost = estrdup(user_host);
953 user_shost = user_host;
958 alias_remove_recursive(name, type, strict, quiet)
968 if ((a = alias_find(name, type)) != NULL) {
969 tq_foreach_fwd(&a->members, m) {
970 if (m->type == ALIAS) {
971 if (strcmp(name, m->name) == 0) {
972 print_selfref(m->name, type, strict, quiet);
975 if (!alias_remove_recursive(m->name, type, strict, quiet))
982 a = alias_remove(name, type);
984 rbinsert(alias_freelist, a);
989 * Iterate through the sudoers datastructures looking for undefined
990 * aliases or unused aliases.
993 check_aliases(strict, quiet)
998 struct member *m, *binding;
999 struct privilege *priv;
1000 struct userspec *us;
1002 int atype, error = 0;
1004 alias_freelist = rbcreate(alias_compare);
1006 /* Forward check. */
1007 tq_foreach_fwd(&userspecs, us) {
1008 tq_foreach_fwd(&us->users, m) {
1009 if (m->type == ALIAS) {
1011 if (alias_find(m->name, USERALIAS) == NULL) {
1012 print_undefined(m->name, USERALIAS, strict, quiet);
1017 tq_foreach_fwd(&us->privileges, priv) {
1018 tq_foreach_fwd(&priv->hostlist, m) {
1019 if (m->type == ALIAS) {
1021 if (alias_find(m->name, HOSTALIAS) == NULL) {
1022 print_undefined(m->name, HOSTALIAS, strict, quiet);
1027 tq_foreach_fwd(&priv->cmndlist, cs) {
1028 tq_foreach_fwd(&cs->runasuserlist, m) {
1029 if (m->type == ALIAS) {
1031 if (alias_find(m->name, RUNASALIAS) == NULL) {
1032 print_undefined(m->name, RUNASALIAS, strict, quiet);
1037 if ((m = cs->cmnd)->type == ALIAS) {
1039 if (alias_find(m->name, CMNDALIAS) == NULL) {
1040 print_undefined(m->name, CMNDALIAS, strict, quiet);
1048 /* Reverse check (destructive) */
1049 tq_foreach_fwd(&userspecs, us) {
1050 tq_foreach_fwd(&us->users, m) {
1051 if (m->type == ALIAS) {
1052 if (!alias_remove_recursive(m->name, USERALIAS, strict, quiet))
1056 tq_foreach_fwd(&us->privileges, priv) {
1057 tq_foreach_fwd(&priv->hostlist, m) {
1058 if (m->type == ALIAS)
1059 if (!alias_remove_recursive(m->name, HOSTALIAS, strict,
1063 tq_foreach_fwd(&priv->cmndlist, cs) {
1064 tq_foreach_fwd(&cs->runasuserlist, m) {
1065 if (m->type == ALIAS)
1066 if (!alias_remove_recursive(m->name, RUNASALIAS,
1070 if ((m = cs->cmnd)->type == ALIAS)
1071 if (!alias_remove_recursive(m->name, CMNDALIAS, strict,
1077 tq_foreach_fwd(&defaults, d) {
1085 case DEFAULTS_RUNAS:
1092 continue; /* not an alias */
1094 tq_foreach_fwd(&d->binding, binding) {
1095 for (m = binding; m != NULL; m = m->next) {
1096 if (m->type == ALIAS)
1097 if (!alias_remove_recursive(m->name, atype, strict, quiet))
1102 rbdestroy(alias_freelist, alias_free);
1104 /* If all aliases were referenced we will have an empty tree. */
1105 if (!no_aliases() && !quiet)
1106 alias_apply(print_unused, strict ? "Error" : "Warning");
1108 return (strict ? error : 0);
1112 print_undefined(name, type, strict, quiet)
1119 warningx("%s: %s_Alias `%s' referenced but not defined",
1120 strict ? "Error" : "Warning",
1121 type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
1122 type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
1128 print_selfref(name, type, strict, quiet)
1135 warningx("%s: %s_Alias `%s' references self",
1136 strict ? "Error" : "Warning",
1137 type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
1138 type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
1144 print_unused(v1, v2)
1148 struct alias *a = (struct alias *)v1;
1149 char *prefix = (char *)v2;
1151 warningx("%s: unused %s_Alias %s", prefix,
1152 a->type == HOSTALIAS ? "Host" : a->type == CMNDALIAS ? "Cmnd" :
1153 a->type == USERALIAS ? "User" : a->type == RUNASALIAS ? "Runas" :
1154 "Unknown", a->name);
1159 * Unlink any sudoers temp files that remain.
1165 struct sudoersfile *sp;
1167 tq_foreach_fwd(&sudoerslist, sp) {
1168 if (sp->tpath != NULL)
1169 (void) unlink(sp->tpath);
1178 * Unlink sudoers temp files (if any) and exit.
1185 #define emsg " exiting due to signal.\n"
1186 write(STDERR_FILENO, getprogname(), strlen(getprogname()));
1187 write(STDERR_FILENO, emsg, sizeof(emsg) - 1);
1194 (void) fprintf(stderr, "usage: %s [-c] [-q] [-s] [-V] [-f sudoers]\n",