2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-04 00:05:11 +00:00

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.

This commit is contained in:
Todd C. Miller
1999-04-02 21:02:57 +00:00
parent 1116756bff
commit a234aee2c6

View File

@@ -231,9 +231,9 @@ int main(argc, argv)
else else
(void) sprintf(buf, "%s %s", Editor, stmp); (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); n = system(buf);
if (n == 0 || n == 256) { if (n != -1 && ((n >> 8) == 0 || (n >> 8) == 1)) {
struct stat statbuf; /* for sanity checking */ struct stat statbuf; /* for sanity checking */
/* make sure stmp exists */ /* make sure stmp exists */
@@ -279,8 +279,9 @@ int main(argc, argv)
parse_error = TRUE; parse_error = TRUE;
} }
} else { } else {
(void) fprintf(stderr, "%s: Editor (%s) failed, %s unchanged.\n", (void) fprintf(stderr,
Argv[0], Editor, sudoers); "%s: Editor (%s) failed with exit status %d, %s unchanged.\n",
Argv[0], Editor, n, sudoers);
Exit(-1); Exit(-1);
} }