Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 3c5e24b127c80e47535551d9f74c4847 > files > 7

quota-3.13-5.el5.src.rpm

From 3d94a1325ade4a6541998912e5aa48562bca34a3 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Tue, 8 Mar 2011 23:36:47 +0100
Subject: [PATCH] Disable grace period/times remote setting

This is back-port of patches:

From 8d4c4a761c27a81d96ae8c49e1b8d32d66b6751e Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Tue, 8 Mar 2011 23:36:47 +0100
Subject: [PATCH 1/2] Fix synopsis and properly report errors during remote grace period setting

From 418a9f20ee870953790b4331327ccb24ca8f1e47 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Wed, 9 Mar 2011 15:37:37 +0100
Subject: [PATCH 2/2] Forbid grace time setting over RPC

For quota-3.13. Upstream recognised setting grace period or time remotely
cannot work and removed this stub and justified manual not to confuse users.

In addition, the new condition in setgrace() has been corrected to disallow
remote setting and to allow local setting.
---
 edquota.c  |    8 ++++++--
 setquota.c |   13 +++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/edquota.c b/edquota.c
index faaff76..5d63ac6 100644
--- a/edquota.c
+++ b/edquota.c
@@ -68,8 +68,8 @@ void usage(void)
 	errstr("%s%s%s%s",
 		_("Usage:\n  edquota [-r] [-u] [-x] [-F formatname] [-p username] [-f filesystem] username ...\n"),
 		_("  edquota [-r] -g [-x] [-F formatname] [-p groupname] [-f filesystem] groupname ...\n"),
-		_("  edquota [-r] [-u|g] [-x] [-F formatname] [-f filesystem] -t\n"),
-		_("  edquota [-r] [-u|g] [-x] [-F formatname] [-f filesystem] -T username|groupname ...\n"));
+		_("  edquota [-u|g] [-x] [-F formatname] [-f filesystem] -t\n"),
+		_("  edquota [-u|g] [-x] [-F formatname] [-f filesystem] -T username|groupname ...\n"));
 #else
 	errstr("%s%s%s%s",
 		_("Usage:\n  edquota [-u] [-x] [-F formatname] [-p username] [-f filesystem] username ...\n"),
@@ -149,6 +149,10 @@ int main(int argc, char **argv)
 
 	if ((tflag && argc != 0) || (Tflag && argc < 1))
 		usage();
+	if (rflag && (Tflag || tflag)) {
+		errstr(_("Cannot change grace times over RPC protocol.\n"));
+		usage();
+	}
 
 	init_kernel_interface();
 	handles = create_handle_list(dirname ? 1 : 0, dirname ? &dirname : NULL, quotatype, fmt, rflag ? 0 : IOI_LOCALONLY, 0);
diff --git a/setquota.c b/setquota.c
index 3916655..e0d2f66 100644
--- a/setquota.c
+++ b/setquota.c
@@ -159,6 +159,10 @@ static void parse_options(int argcnt, char **argstr)
 		errstr(_("Batch mode and prototype user cannot be used together.\n"));
 		usage();
 	}
+	if (flags & FL_RPC && (flags & (FL_GRACE | FL_INDIVIDUAL_GRACE))) {
+		errstr(_("Cannot set grace times over RPC protocol.\n"));
+		usage();
+	}
 	if (flags & FL_GRACE)
 		otherargs = 2;
 	else if (flags & FL_INDIVIDUAL_GRACE)
@@ -307,14 +311,19 @@ static int batch_setlimits(struct quota_handle **handles)
 /* Set grace times */
 static int setgraces(struct quota_handle **handles)
 {
-	int i;
+	int i, ret = 0;
 
 	for (i = 0; handles[i]; i++) {
+		if (!handles[i]->qh_ops->write_info) {
+			errstr(_("Setting grace period on %s is not supported.\n"), handles[i]->qh_quotadev);
+			ret = -1;
+			continue;
+		}
 		handles[i]->qh_info.dqi_bgrace = toset.dqb_btime;
 		handles[i]->qh_info.dqi_igrace = toset.dqb_itime;
 		mark_quotafile_info_dirty(handles[i]);
 	}
-	return 0;
+	return ret;
 }
 
 /* Set grace times for individual user */
-- 
1.7.4