From: Todd C. Miller Date: Thu, 11 Oct 2001 17:20:33 +0000 (+0000) Subject: Ignore editor exit value since XPG4 says vi's exit value is the count X-Git-Tag: SUDO_1_6_4~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d6e0c7049ecad32fc4544c56cbde5187ae205a3d;p=sudo Ignore editor exit value since XPG4 says vi's exit value is the count of editing errors made (failed searches, etc). --- diff --git a/visudo.c b/visudo.c index 307978ebf..adbf3c86f 100644 --- a/visudo.c +++ b/visudo.c @@ -338,10 +338,14 @@ main(argc, argv) av[n++] = stmp; av[n++] = NULL; - /* Do the edit -- some SYSV editors exit with 1 instead of 0 */ + /* + * Do the edit: + * We cannot check the editor's exit value against 0 since + * XPG4 specifies that vi's exit value is a function of the + * number of errors during editing (?!?!). + */ now = time(NULL); - n = run_command(Editor, av); - if (n != -1 && ((n >> 8) == 0 || (n >> 8) == 1)) { + if (run_command(Editor, av) != -1) { /* * Sanity checks. */ @@ -388,8 +392,8 @@ main(argc, argv) } } else { (void) fprintf(stderr, - "%s: Editor (%s) failed with exit status %d, %s unchanged.\n", - Argv[0], Editor, n, sudoers); + "%s: Editor (%s) failed, %s unchanged.\n", Argv[0], + Editor, sudoers); Exit(-1); } @@ -636,9 +640,8 @@ run_command(path, argv) (void) sigsetmask(omask); #endif /* POSIX_SIGNALS */ - if (pid == -1) - status = -1; - return(status); + /* XXX - should use WEXITSTATUS() */ + return(pid == -1 ? -1 : (status >> 8)); } /*