[PATCH 2/2] debugedit: Report errors if we cannot chmod the file.
Mark Wielaard
mark@klomp.org
Thu Jul 1 14:39:04 GMT 2021
* tools/debugedit.c (main): Check result of chmod and call error
if necessary.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tools/debugedit.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/debugedit.c b/tools/debugedit.c
index d0c6371..80b99fe 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -3420,7 +3420,8 @@ main (int argc, char *argv[])
}
/* Make sure we can read and write */
- chmod (file, stat_buf.st_mode | S_IRUSR | S_IWUSR);
+ if (chmod (file, stat_buf.st_mode | S_IRUSR | S_IWUSR) != 0)
+ error (0, errno, "Failed to chmod input file '%s' to make sure we can read and write", file);
fd = open (file, O_RDWR);
if (fd < 0)
@@ -3636,7 +3637,8 @@ main (int argc, char *argv[])
close (fd);
/* Restore old access rights */
- chmod (file, stat_buf.st_mode);
+ if (chmod (file, stat_buf.st_mode) != 0)
+ error (0, errno, "Failed to chmod input file '%s' to restore old access rights", file);
free ((char *) dso->filename);
destroy_strings (&dso->debug_str);
--
2.32.0
More information about the Debugedit
mailing list