Avoid questions in quotacheck non-interactive mode

This commit is contained in:
Petr Písař 2018-02-05 17:28:18 +01:00
parent 6903144869
commit 182a0dd855
3 changed files with 68 additions and 8 deletions

View File

@ -0,0 +1,36 @@
From 4179911dc38af1b6499704a7f7fb710a40c95bdb Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Mon, 5 Feb 2018 15:39:12 +0100
Subject: [PATCH] quotacheck: Avoid question in non-interactive mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
A question when quota file version is incorrect is asked even if
quotacheck is run in non-interactive mode. Avoid asking the question in
that case and fail the check instead.
Reproted-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_v2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/quotacheck_v2.c b/quotacheck_v2.c
index 4cc8558..86fbf42 100644
--- a/quotacheck_v2.c
+++ b/quotacheck_v2.c
@@ -363,7 +363,8 @@ static int check_header(char *filename, int fd, int type, int version)
"specified on command line (%d). Quota file header "
"may be corrupted.\n"),
le32toh(head.dqh_version), version);
- if (!ask_yn(_("Continue checking assuming version from command line?"), 1))
+ if (!(flags & FL_INTERACTIVE) ||
+ !ask_yn(_("Continue checking assuming version from command line?"), 1))
return -1;
detected_versions[type] = version;
} else
--
2.13.6

View File

@ -1,7 +1,7 @@
From a0ef0ff21c0d64993aed7174b7800579992b240f Mon Sep 17 00:00:00 2001
From 59b280ebe22eceaf4250cb3b776674619a4d4ece Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 5 Feb 2018 11:07:41 +0100
Subject: [PATCH 2/2] warnquota: Fix comparing user name to non-null-terminated
Subject: [PATCH] warnquota: Fix comparing user name to non-null-terminated
utmp.ut_user
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
@ -34,23 +34,41 @@ that does not fit into utmp log format. It's better not to warn than
spamming unrelated user.
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
quota_nld.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
quota_nld.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/quota_nld.c b/quota_nld.c
index ea541e0..eecc89f 100644
index ea541e0..8559f25 100644
--- a/quota_nld.c
+++ b/quota_nld.c
@@ -270,7 +270,7 @@ static void write_console_warning(struct quota_warning *warn)
@@ -262,6 +262,8 @@ static void write_console_warning(struct quota_warning *warn)
warn->warntype == QUOTA_NL_BSOFTBELOW) && !(flags & FL_PRINTBELOW))
return;
uid2user(warn->caused_id, user);
+ if (strlen(user) > UT_NAMESIZE)
+ goto skip_utmp;
strcpy(dev, "/dev/");
setutent();
@@ -270,7 +272,7 @@ static void write_console_warning(struct quota_warning *warn)
if (uent->ut_type != USER_PROCESS)
continue;
/* Entry for a different user? */
- if (strcmp(user, uent->ut_user))
+ if (strncmp(user, uent->ut_user, UT_NAMESIZE) || strlen(user) > UT_NAMESIZE)
+ if (strncmp(user, uent->ut_user, UT_NAMESIZE))
continue;
sstrncpy(dev+5, uent->ut_line, PATH_MAX-5);
if (stat(dev, &st) < 0)
@@ -281,6 +283,7 @@ static void write_console_warning(struct quota_warning *warn)
}
}
if (!max_atime) {
+skip_utmp:
/*
* This can happen quite easily so don't spam syslog with
* the error
--
2.13.6

View File

@ -10,7 +10,7 @@
Name: quota
Epoch: 1
Version: 4.04
Release: 3%{?dist}
Release: 4%{?dist}
Summary: System administration tools for monitoring users' disk usage
# quota_nld.c, quotaio_xfs.h: GPLv2
# bylabel.c copied from util-linux: GPLv2+
@ -66,6 +66,8 @@ Patch5: quota-4.04-warnquota-Check-snprintf-for-overflows.patch
# Fix user name search in utmp log,
# <https://sourceforge.net/p/linuxquota/patches/48/>, in upstream after 4.04
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
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -186,6 +188,7 @@ Linux/UNIX environment.
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
# Regenerate build scripts
autoreconf -f -i
@ -330,6 +333,9 @@ make check
%changelog
* Mon Feb 05 2018 Petr Pisar <ppisar@redhat.com> - 1:4.04-4
- Avoid questions in quotacheck non-interactive mode
* Mon Feb 05 2018 Petr Pisar <ppisar@redhat.com> - 1:4.04-3
- rpcgen tool split from glibc-common package
- Pass TIRPC header files location to all RPC compilation units