]> granicus.if.org Git - sudo/commitdiff
Shift return value of system(3) by 8 to get real exit value and if it is not 1 or...
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 2 Apr 1999 21:02:57 +0000 (21:02 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 2 Apr 1999 21:02:57 +0000 (21:02 +0000)
visudo.c

index b9da8c6a0e6e2ccbde131a9621889f628833c448..ff1ac552733dda83a7d31420dcf49ef3d06423ec 100644 (file)
--- 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);
        }