From a234aee2c66f795ad19a65ee39ed6833244efaaa Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 2 Apr 1999 21:02:57 +0000 Subject: [PATCH] Shift return value of system(3) by 8 to get real exit value and if it is not 1 or 0 print the retval along with the error message. --- visudo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/visudo.c b/visudo.c index b9da8c6a0..ff1ac5527 100644 --- a/visudo.c +++ b/visudo.c @@ -231,9 +231,9 @@ int main(argc, argv) else (void) sprintf(buf, "%s %s", Editor, stmp); - /* do the edit -- some SYSV editors return 256 instead of 0 */ + /* do the edit -- some SYSV editors exit with 1 instead of 0 */ n = system(buf); - if (n == 0 || n == 256) { + if (n != -1 && ((n >> 8) == 0 || (n >> 8) == 1)) { struct stat statbuf; /* for sanity checking */ /* make sure stmp exists */ @@ -279,8 +279,9 @@ int main(argc, argv) parse_error = TRUE; } } else { - (void) fprintf(stderr, "%s: Editor (%s) failed, %s unchanged.\n", - Argv[0], Editor, sudoers); + (void) fprintf(stderr, + "%s: Editor (%s) failed with exit status %d, %s unchanged.\n", + Argv[0], Editor, n, sudoers); Exit(-1); } -- 2.40.0