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 1/2] sepdebugcrcfix: Report errors if we cannot chmod the file.
Date: Thu,  1 Jul 2021 16:39:03 +0200	[thread overview]
Message-ID: <20210701143904.327222-1-mark@klomp.org> (raw)

	* 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


             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 Mark Wielaard [this message]
2021-07-01 14:39 ` [PATCH 2/2] debugedit: " Mark Wielaard

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-1-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).