public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] sepdebugcrcfix: Report errors if we cannot chmod the file.
@ 2021-07-01 14:39 Mark Wielaard
  2021-07-01 14:39 ` [PATCH 2/2] debugedit: " Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2021-07-01 14:39 UTC (permalink / raw)
  To: debugedit; +Cc: Mark Wielaard

	* 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 2/2] debugedit: Report errors if we cannot chmod the file.
  2021-07-01 14:39 [PATCH 1/2] sepdebugcrcfix: Report errors if we cannot chmod the file Mark Wielaard
@ 2021-07-01 14:39 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2021-07-01 14:39 UTC (permalink / raw)
  To: debugedit; +Cc: Mark Wielaard

 	* 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-01 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01 14:39 [PATCH 1/2] sepdebugcrcfix: Report errors if we cannot chmod the file Mark Wielaard
2021-07-01 14:39 ` [PATCH 2/2] debugedit: " Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).