Report an error when quotacheck fails to cache quota files

This commit is contained in:
Petr Písař 2018-02-05 17:31:02 +01:00
parent 182a0dd855
commit 361e07183a
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,88 @@
From 7b6dfd6390476ec7b811c76e4e2653db2994cad4 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Mon, 5 Feb 2018 15:54:54 +0100
Subject: [PATCH] quotacheck: Report error when caching of quota file fails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Currently quotacheck returns with zero exit code even though caching of
quota file fails. Fix it to return with non-zero exit code in that case
as expected.
Reported-by: Christoph Biedl <debian.axhn@manchmal.in-ulm.de
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
quotacheck.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/quotacheck.c b/quotacheck.c
index 9d7940b..b1302b6 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -924,6 +924,7 @@ static int check_dir(struct mount_entry *mnt)
struct stat st;
int remounted = 0;
int failed = 0;
+ int ret;
if (lstat(mnt->me_dir, &st) < 0)
die(2, _("Cannot stat mountpoint %s: %s\n"), mnt->me_dir, strerror(errno));
@@ -939,14 +940,22 @@ static int check_dir(struct mount_entry *mnt)
*/
if (cfmt == QF_XFS)
goto start_scan;
- if (ucheck)
- if (process_file(mnt, USRQUOTA) < 0)
+ if (ucheck) {
+ ret = process_file(mnt, USRQUOTA);
+ if (ret < 0) {
+ failed |= ret;
ucheck = 0;
- if (gcheck)
- if (process_file(mnt, GRPQUOTA) < 0)
+ }
+ }
+ if (gcheck) {
+ ret = process_file(mnt, GRPQUOTA);
+ if (ret < 0) {
+ failed |= ret;
gcheck = 0;
+ }
+ }
if (!ucheck && !gcheck) /* Nothing to check? */
- return 0;
+ return failed;
if (!(flags & FL_NOREMOUNT)) {
/* Now we try to remount fs read-only to prevent races when scanning filesystem */
if (mount
@@ -978,8 +987,11 @@ start_scan:
!strcmp(mnt->me_type, MNTTYPE_EXT3) ||
!strcmp(mnt->me_type, MNTTYPE_NEXT3) ||
!strcmp(mnt->me_type, MNTTYPE_EXT4)) {
- if ((failed = ext2_direct_scan(mnt->me_devname)) < 0)
+ ret = ext2_direct_scan(mnt->me_devname);
+ if (ret < 0) {
+ failed |= ret;
goto out;
+ }
}
else {
#else
@@ -987,8 +999,11 @@ start_scan:
#endif
if (flags & FL_VERYVERBOSE)
putchar('\n');
- if ((failed = scan_dir(mnt->me_dir)) < 0)
+ ret = scan_dir(mnt->me_dir);
+ if (ret < 0) {
+ failed |= ret;
goto out;
+ }
}
dirs_done++;
if (flags & FL_VERBOSE || flags & FL_DEBUG)
--
2.13.6

View File

@ -68,6 +68,9 @@ Patch5: quota-4.04-warnquota-Check-snprintf-for-overflows.patch
Patch6: quota-4.04-warnquota-Fix-comparing-user-name-to-non-null-termin.patch
# Avoid questions in quotacheck non-interactive mode, in upstream after 4.04
Patch7: quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch
# Report an error when quotacheck fails to cache quota files,
# in upstream after 4.04
Patch8: quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -189,6 +192,7 @@ Linux/UNIX environment.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
# Regenerate build scripts
autoreconf -f -i
@ -335,6 +339,7 @@ make check
%changelog
* Mon Feb 05 2018 Petr Pisar <ppisar@redhat.com> - 1:4.04-4
- Avoid questions in quotacheck non-interactive mode
- Report an error when quotacheck fails to cache quota files
* Mon Feb 05 2018 Petr Pisar <ppisar@redhat.com> - 1:4.04-3
- rpcgen tool split from glibc-common package