Blame SOURCES/quota-4.04-repquota-Fix-output-when-user-2-exists.patch

30c500
From 1806ee01060d363beac01fda28c613ab27dbc4df Mon Sep 17 00:00:00 2001
30c500
From: Jan Kara <jack@suse.cz>
30c500
Date: Wed, 10 Jan 2018 10:18:43 +0100
30c500
Subject: [PATCH] repquota: Fix output when user -2 exists
30c500
MIME-Version: 1.0
30c500
Content-Type: text/plain; charset=UTF-8
30c500
Content-Transfer-Encoding: 8bit
30c500
30c500
Vladimit Meshkov reported that when user -2 exists and user namespaces
30c500
are enabled in the kernel, repquota(8) fails to output anything. He also
30c500
analyzed this is because in such case repquota(8) tries to query info
30c500
for user -1 which is invalid ID, gets error from the kernel, and bails
30c500
out.
30c500
30c500
Fix the problem by stopping iteration over IDs when we reach ID -1.
30c500
30c500
Reported-by: Vladimir Meshkov <ubob74@gmail.com>
30c500
Signed-off-by: Jan Kara <jack@suse.cz>
30c500
Signed-off-by: Petr Písař <ppisar@redhat.com>
30c500
---
30c500
 quotaio_generic.c | 5 +++++
30c500
 quotaio_xfs.c     | 5 +++++
30c500
 2 files changed, 10 insertions(+)
30c500
30c500
diff --git a/quotaio_generic.c b/quotaio_generic.c
30c500
index 025d712..5b23955 100644
30c500
--- a/quotaio_generic.c
30c500
+++ b/quotaio_generic.c
30c500
@@ -204,6 +204,11 @@ int vfs_scan_dquots(struct quota_handle *h,
30c500
 		if (ret < 0)
30c500
 			break;
30c500
 		id = kdqblk.dqb_id + 1;
30c500
+		/* id -1 is invalid and the last one... */
30c500
+		if (id == -1) {
30c500
+			errno = ENOENT;
30c500
+			break;
30c500
+		}
30c500
 	}
30c500
 	free(dquot);
30c500
 
30c500
diff --git a/quotaio_xfs.c b/quotaio_xfs.c
30c500
index 1374cf4..56daf89 100644
30c500
--- a/quotaio_xfs.c
30c500
+++ b/quotaio_xfs.c
30c500
@@ -219,6 +219,11 @@ static int xfs_kernel_scan_dquots(struct quota_handle *h,
30c500
 		if (ret < 0)
30c500
 			break;
30c500
 		id = xdqblk.d_id + 1;
30c500
+		/* id -1 is invalid and the last one... */
30c500
+		if (id == -1) {
30c500
+			errno = ENOENT;
30c500
+			break;
30c500
+		}
30c500
 	}
30c500
 	free(dquot);
30c500
 
30c500
-- 
30c500
2.13.6
30c500