[BACK]Return to visudo.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Diff for /src/usr.bin/sudo/Attic/visudo.c between version 1.12 and 1.13

version 1.12, 2002/01/17 16:48:01 version 1.13, 2003/03/15 21:23:54
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>   * Copyright (c) 1996, 1998-2003 Todd C. Miller <Todd.Miller@courtesan.com>
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
Line 73 
Line 73 
 #include "version.h"  #include "version.h"
   
 #ifndef lint  #ifndef lint
 static const char rcsid[] = "$Sudo: visudo.c,v 1.146 2002/01/17 15:35:54 millert Exp $";  static const char rcsid[] = "$Sudo: visudo.c,v 1.149 2003/03/15 20:31:02 millert Exp $";
 #endif /* lint */  #endif /* lint */
   
 /*  /*
Line 231 
Line 231 
                 Exit(-1);                  Exit(-1);
             }              }
   
           /* Add missing newline at EOF if needed. */
           if (n > 0 && buf[n - 1] != '\n') {
               buf[0] = '\n';
               write(stmp_fd, buf, 1);
           }
   
         (void) close(stmp_fd);          (void) close(stmp_fd);
         (void) touch(stmp, sudoers_sb.st_mtime);          (void) touch(stmp, sudoers_sb.st_mtime);
   
         /* Parse sudoers to pull in editor and env_editor conf values. */          /* Parse sudoers to pull in editor and env_editor conf values. */
         if ((yyin = fopen(stmp, "r"))) {          if ((yyin = fopen(stmp, "r"))) {
             yyout = stdout;              yyout = stdout;
               n = quiet;
               quiet = 1;
             init_parser();              init_parser();
             yyparse();              yyparse();
             parse_error = FALSE;              parse_error = FALSE;
             yyrestart(yyin);              quiet = n;
             fclose(yyin);              fclose(yyin);
         }          }
     } else      } else
Line 390 
Line 398 
              * for parse errors.               * for parse errors.
              */               */
             yyout = stdout;              yyout = stdout;
             if (parse_error)              yyin = fopen(stmp, "r+");
                 yyin = freopen(stmp, "r", yyin);  
             else  
                 yyin = fopen(stmp, "r");  
             if (yyin == NULL) {              if (yyin == NULL) {
                 (void) fprintf(stderr,                  (void) fprintf(stderr,
                     "%s: Can't re-open temporary file (%s), %s unchanged.\n",                      "%s: Can't re-open temporary file (%s), %s unchanged.\n",
Line 401 
Line 406 
                 Exit(-1);                  Exit(-1);
             }              }
   
               /* Add missing newline at EOF if needed. */
               if (fseek(yyin, -1, SEEK_END) == 0 && (ch = fgetc(yyin)) != '\n')
                   fputc('\n', yyin);
               rewind(yyin);
   
             /* Clean slate for each parse */              /* Clean slate for each parse */
             user_runas = NULL;              user_runas = NULL;
             init_defaults();              init_defaults();
             init_parser();              init_parser();
   
             /* Parse the sudoers file */              /* Parse the sudoers temp file */
               yyrestart(yyin);
             if (yyparse() && parse_error != TRUE) {              if (yyparse() && parse_error != TRUE) {
                 (void) fprintf(stderr,                  (void) fprintf(stderr,
                     "%s: Failed to parse temporary file (%s), unknown error.\n",                      "%s: Failed to parse temporary file (%s), unknown error.\n",
                     Argv[0], stmp);                      Argv[0], stmp);
                 parse_error = TRUE;                  parse_error = TRUE;
             }              }
               fclose(yyin);
         } else {          } else {
             (void) fprintf(stderr,              (void) fprintf(stderr,
                 "%s: Editor (%s) failed, %s unchanged.\n", Argv[0],                  "%s: Editor (%s) failed, %s unchanged.\n", Argv[0],
Line 432 
Line 444 
                                 Exit(0);                                  Exit(0);
                                 break;                                  break;
             }              }
             yyrestart(yyin);    /* reset lexer */  
         }          }
     } while (parse_error == TRUE);      } while (parse_error == TRUE);
   

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13