=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/visudo.c,v retrieving revision 1.26 retrieving revision 1.27 diff -c -r1.26 -r1.27 *** src/usr.bin/sudo/Attic/visudo.c 2009/04/19 00:09:00 1.26 --- src/usr.bin/sudo/Attic/visudo.c 2009/06/21 14:48:42 1.27 *************** *** 1,5 **** /* ! * Copyright (c) 1996, 1998-2005, 2007-2008 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any --- 1,5 ---- /* ! * Copyright (c) 1996, 1998-2005, 2007-2009 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any *************** *** 85,102 **** #include "parse.h" #include "redblack.h" #include - #include "version.h" #ifndef lint ! __unused static const char rcsid[] = "$Sudo: visudo.c,v 1.231 2009/04/16 12:22:04 millert Exp $"; #endif /* lint */ struct sudoersfile { char *path; - int fd; char *tpath; int tfd; int modified; struct sudoersfile *next; }; --- 85,102 ---- #include "parse.h" #include "redblack.h" #include #ifndef lint ! __unused static const char rcsid[] = "$Sudo: visudo.c,v 1.234 2009/05/25 12:02:42 millert Exp $"; #endif /* lint */ struct sudoersfile { char *path; char *tpath; + int fd; int tfd; int modified; + int doedit; struct sudoersfile *next; }; *************** *** 172,178 **** while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) { switch (ch) { case 'V': ! (void) printf("%s version %s\n", getprogname(), version); exit(0); case 'c': checkonly++; /* check mode */ --- 172,178 ---- while ((ch = getopt(argc, argv, "Vcf:sq")) != -1) { switch (ch) { case 'V': ! (void) printf("%s version %s\n", getprogname(), PACKAGE_VERSION); exit(0); case 'c': checkonly++; /* check mode */ *************** *** 215,222 **** * Parse the existing sudoers file(s) in quiet mode to highlight any * existing errors and to pull in editor and env_editor conf values. */ ! if ((yyin = open_sudoers(sudoers_path, NULL)) == NULL) error(1, "%s", sudoers_path); init_parser(sudoers_path, 0); yyparse(); (void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER); --- 215,223 ---- * Parse the existing sudoers file(s) in quiet mode to highlight any * existing errors and to pull in editor and env_editor conf values. */ ! if ((yyin = open_sudoers(sudoers_path, TRUE, NULL)) == NULL) { error(1, "%s", sudoers_path); + } init_parser(sudoers_path, 0); yyparse(); (void) update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER); *************** *** 228,233 **** --- 229,236 ---- /* Edit the sudoers file(s) */ tq_foreach_fwd(&sudoerslist, sp) { + if (!sp->doedit) + continue; if (sp != tq_first(&sudoerslist)) { printf("press return to edit %s: ", sp->path); while ((ch = getchar()) != EOF && ch != '\n') *************** *** 747,754 **** * any subsequent files #included via a callback from the parser. */ FILE * ! open_sudoers(path, keepopen) const char *path; int *keepopen; { struct sudoersfile *entry; --- 750,758 ---- * any subsequent files #included via a callback from the parser. */ FILE * ! open_sudoers(path, doedit, keepopen) const char *path; + int doedit; int *keepopen; { struct sudoersfile *entry; *************** *** 766,771 **** --- 770,777 ---- entry->next = NULL; entry->fd = open(entry->path, O_RDWR | O_CREAT, SUDOERS_MODE); entry->tpath = NULL; + entry->tfd = -1; + entry->doedit = doedit; if (entry->fd == -1) { warning("%s", entry->path); efree(entry);