Blob Blame Raw
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

Testing revealed that it's not easy to set even individual grace times
over RPC protocol. Since the usage of it is limited, just disallow that.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 edquota.8  |    2 --
 edquota.c  |    8 ++++++--
 setquota.8 |    2 --
 setquota.c |    6 +++++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/edquota.8 b/edquota.8
index 2ef4cb6..4b1406b 100644
--- a/edquota.8
+++ b/edquota.8
@@ -38,8 +38,6 @@ edquota \- edit user quotas
 .BR \-u \ |
 .B \-g
 ] [
-.B \-rm
-] [
 .B \-F
 .I format-name
 ] [
diff --git a/edquota.c b/edquota.c
index c0b2f76..4d247fa 100644
--- a/edquota.c
+++ b/edquota.c
@@ -80,8 +80,8 @@ void usage(void)
 #endif
 	errstr(_("Usage:\n\tedquota %1$s[-u] [-F formatname] [-p username] [-f filesystem] username ...\n\
 \tedquota %1$s-g [-F formatname] [-p groupname] [-f filesystem] groupname ...\n\
-\tedquota %1$s[-u|g] [-F formatname] [-f filesystem] -t\n\
-\tedquota %1$s[-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n"), rpcflag);
+\tedquota [-u|g] [-F formatname] [-f filesystem] -t\n\
+\tedquota [-u|g] [-F formatname] [-f filesystem] -T username|groupname ...\n"), rpcflag);
 	fputs(_("\n\
 -u, --user                    edit user data\n\
 -g, --group                   edit group data\n"), stderr);
@@ -183,6 +183,10 @@ int parse_options(int argc, char **argv)
 		errstr(_("Prototype name does not make sense when editing grace period or times.\n"));
 		usage();
 	}
+	if (flags & FL_REMOTE && (flags & (FL_EDIT_TIMES | FL_EDIT_PERIOD))) {
+		errstr(_("Cannot change grace times over RPC protocol.\n"));
+		usage();
+	}
 	return optind;
 }
 
diff --git a/setquota.8 b/setquota.8
index 6c3dc88..db9d054 100644
--- a/setquota.8
+++ b/setquota.8
@@ -84,8 +84,6 @@ setquota \- set disk quotas
 .B setquota
 .B \-T
 [
-.B \-rm
-] [
 .B \-u
 |
 .B \-g
diff --git a/setquota.c b/setquota.c
index d1cffcb..fe29ec2 100644
--- a/setquota.c
+++ b/setquota.c
@@ -58,7 +58,7 @@ static void usage(void)
   setquota [-u|-g] %1$s[-F quotaformat] <-p protouser|protogroup> <user|group> -a|<filesystem>...\n\
   setquota [-u|-g] %1$s[-F quotaformat] -b [-c] -a|<filesystem>...\n\
   setquota [-u|-g] [-F quotaformat] -t <blockgrace> <inodegrace> -a|<filesystem>...\n\
-  setquota [-u|-g] %1$s[-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n\n\
+  setquota [-u|-g] [-F quotaformat] <user|group> -T <blockgrace> <inodegrace> -a|<filesystem>...\n\n\
 -u, --user                 set limits for user\n\
 -g, --group                set limits for group\n\
 -a, --all                  set limits for all filesystems\n\
@@ -202,6 +202,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)
-- 
1.7.4