From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 1C318396E879 for ; Thu, 1 Jul 2021 14:39:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C318396E879 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x00.wildebeest.org [172.31.17.130]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 2E0F23000252; Thu, 1 Jul 2021 16:39:15 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 144C42E80F3B; Thu, 1 Jul 2021 16:39:15 +0200 (CEST) From: Mark Wielaard To: debugedit@sourceware.org Cc: Mark Wielaard Subject: [PATCH 2/2] debugedit: Report errors if we cannot chmod the file. Date: Thu, 1 Jul 2021 16:39:04 +0200 Message-Id: <20210701143904.327222-2-mark@klomp.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210701143904.327222-1-mark@klomp.org> References: <20210701143904.327222-1-mark@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: debugedit@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: debugedit development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2021 14:39:17 -0000 * tools/debugedit.c (main): Check result of chmod and call error if necessary. Signed-off-by: Mark Wielaard --- 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