public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: debugedit@sourceware.org
Cc: Mark Wielaard <mark@klomp.org>
Subject: [PATCH 2/2] debugedit: Report errors if we cannot chmod the file.
Date: Thu,  1 Jul 2021 16:39:04 +0200	[thread overview]
Message-ID: <20210701143904.327222-2-mark@klomp.org> (raw)
In-Reply-To: <20210701143904.327222-1-mark@klomp.org>

 	* 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


      reply	other threads:[~2021-07-01 14:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 14:39 [PATCH 1/2] sepdebugcrcfix: " Mark Wielaard
2021-07-01 14:39 ` Mark Wielaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210701143904.327222-2-mark@klomp.org \
    --to=mark@klomp.org \
    --cc=debugedit@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).