Check for setuid and setgid calls failure in edquota tool

This commit is contained in:
Petr Písař 2017-07-04 14:34:05 +02:00
parent 464dafff94
commit 342168313d
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,38 @@
From 9aa3a11857109297b521d0a8926dd90361b991ed Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Thu, 18 May 2017 12:28:51 +0300
Subject: [PATCH] quotaops: check setgid/setuid return code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
setgid/setuid syscalls may fail for different reasons,
do not ignore these errors.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
quotaops.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/quotaops.c b/quotaops.c
index 56cf622..5e6026e 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -218,8 +218,10 @@ int editprivs(char *tmpfile)
int i;
sigprocmask(SIG_SETMASK, &omask, NULL);
- setgid(getgid());
- setuid(getuid());
+ if (setgid(getgid()))
+ die(1, _("%s failed: %s\n"), "setgid", strerror(errno));
+ if (setuid(getuid()))
+ die(1, _("%s failed: %s\n"), "setuid", strerror(errno));
if (!(ed = getenv("VISUAL")))
if (!(ed = getenv("EDITOR")))
ed = _PATH_VI;
--
2.9.4

View File

@ -68,6 +68,9 @@ Patch11: quota-4.03-Do-not-install-quota_nld.8-when-quota_nld-is-not-ins.patc
Patch12: quota-4.03-quotacheck-change-to-the-directory-before-opening-it.patch
# Fix an undefined behavior on parsing yes-no answer, in upstream after 4.03
Patch13: quota-4.03-quotacheck-fix-ask_yn-UB-when-fgets-returns-NULL.patch
# Check for setuid and setgid calls failure in edquota tool,
# in upstream after 4.03
Patch14: quota-4.03-quotaops-check-setgid-setuid-return-code.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -189,6 +192,7 @@ Linux/UNIX environment.
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
# Unpack forgotten LDAP scripts
tar -xzkf %{SOURCE5}
# Regenerate build scripts, also because of Respect-enviroment-CFLAGS.patch
@ -308,6 +312,7 @@ make check
- Fix disabling features at build time
- Fix a race between checking for and opening a directory to be scanned
- Fix an undefined behavior on parsing yes-no answer
- Check for setuid and setgid calls failure in edquota tool
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1:4.03-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild