[PATCH 1/2] sepdebugcrcfix: Report errors if we cannot chmod the file.
Mark Wielaard
mark@klomp.org
Thu Jul 1 14:39:03 GMT 2021
* tools/sepdebugcrcfix.c (main): Check result of chmod and call error
if necessary.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tools/sepdebugcrcfix.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/sepdebugcrcfix.c b/tools/sepdebugcrcfix.c
index 024d09c..da50e6c 100644
--- a/tools/sepdebugcrcfix.c
+++ b/tools/sepdebugcrcfix.c
@@ -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++;
--
2.32.0
More information about the Debugedit
mailing list