sepdebugcrcfix: Report errors if we cannot chmod the file.
authorMark Wielaard <mark@klomp.org>
Thu, 1 Jul 2021 14:30:24 +0000 (16:30 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 5 Jul 2021 13:26:18 +0000 (15:26 +0200)
* tools/sepdebugcrcfix.c (main): Check result of chmod and call error
if necessary.

Signed-off-by: Mark Wielaard <mark@klomp.org>
tools/sepdebugcrcfix.c

index 024d09ccd37b597c4092e77f6a164b7f0f937ad7..da50e6c979c7f36219d439ca6dc0b2b8710ccc37 100644 (file)
@@ -352,7 +352,8 @@ main (int argc, char **argv)
        }
 
       /* Make sure we can read and write */
-      chmod (fname, stat_buf.st_mode | S_IRUSR | S_IWUSR);
+      if (chmod (fname, stat_buf.st_mode | S_IRUSR | S_IWUSR) != 0)
+       error (0, errno, _("cannot chmod \"%s\" to make sure we can read and write"), fname);
 
       bool failed = false;
       int fd = open64 (fname, O_RDWR);
@@ -389,7 +390,8 @@ main (int argc, char **argv)
        }
 
       /* Restore old access rights. Including any suid bits reset. */
-      chmod (fname, stat_buf.st_mode);
+      if (chmod (fname, stat_buf.st_mode) != 0)
+       error (0, errno, _("cannot chmod \"%s\" to restore old access rights"), fname);
 
       if (failed)
        failed_count++;
This page took 0.043196 seconds and 5 git commands to generate.