Skip to contentSkip to conversation

the problem of option '-a', '-A', '-d' and '-D'

DISCUSSION Yu Zhiguo 2 participants 4 messages Jul 21, 2008 – Jul 22, 2008

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

Hello steve,

Now options '-a', '-A', '-d' and '-D' can be used simultaneously in a rule,
but just the last one of them is effective.
This usage will make users confused, for example:

 # auditctl -a entry,always -F uid=500 -A task,always -F uid=600 -a exit,always
 is equal to:
 # auditctl -a exit,always -F uid=500 -F uid=600

I think we'd better not allow these options be used simultaneously,
otherwise an error message will be reported.
What's your opinion? If you agree with me, I'll make a patch.

Signature · 14 lines
Regards
Yu Zhiguo
--------------------------------------------------
Yu Zhiguo
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL: +86+25-86630566-836
COINS: 79955-836
FAX: +86+25-83317685
MAIL: [email protected]
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not an intended recipient of this communication, you are hereby notified that any dissemination, distribution or copying hereof is strictly prohibited.  If you have received this communication in error, please notify me by reply e-mail, permanently delete this communication from your system, and destroy any hard copies you may have printed.
#1 lore raw
Quoted 3 lines · On Monday 21 July 2008 03:15:29 Yu Zhiguo wrote:

I think we'd better not allow these options be used simultaneously,
otherwise an error message will be reported.
What's your opinion? If you agree with me, I'll make a patch.

Correct, it should not allow multiple rule insert/delete options.

-Steve

author
#2 lore raw

Hello Mr. Steve,

This is the patch, can you apply it?
If there are some deficiencies, please give me your indication.

Quoted 3 lines · Steve Grubb
Quoted 1 line

What's your opinion? If you agree with me, I'll make a patch.

Correct, it should not allow multiple rule insert/delete options. -Steve

Now options '-a', '-A', '-d' can be used simultaneously in a rule, but just the last one of them is effective. This usage will make users confused.
So it had better not allow these options be used simultaneously, otherwise an error message will be reported.

---
 src/auditctl.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)
src/auditctl.c +23 -4
index 2c136ea..9f31067 100644
@@ -165,9 +165,16 @@ static void usage(void)
      );
 }
 
-/* Returns 0 ok, 1 deprecated action, 2 error */
+/*
+ * Returns 0 ok, 1 deprecated action, 2 rule error,
+ * 3 multiple rule insert/delete
+ */
 static int audit_rule_setup(const char *opt, int *flags, int *act)
 {
+	static int multiple = 0;
+	if (++multiple != 1)
+		return 3;
+
 	if (strstr(opt, "task"))
 		*flags = AUDIT_FILTER_TASK;
 	else if (strstr(opt, "entry"))
@@ -530,7 +537,11 @@ static int setopt(int count, char *vars[])
 			retval = -1;
 		} else {
 			rc = audit_rule_setup(optarg, &add, &action);
-			if (rc > 1) {
+			if (rc == 3) {
+				fprintf(stderr,
+					"Multiple rule insert/delete operation is not allowed\n");
+				retval = -1;
+			} else if (rc == 2) {
 				fprintf(stderr,
 					"Append rule - bad keyword %s\n",
 					optarg);
@@ -550,7 +561,11 @@ static int setopt(int count, char *vars[])
 			retval = -1;
 		} else {
 			rc = audit_rule_setup(optarg, &add, &action);
-			if (rc > 1) {
+			if (rc == 3) {
+				fprintf(stderr,
+					"Multiple rule insert/delete operation is not allowed\n");
+				retval = -1;
+			} else if (rc == 2) {
 				fprintf(stderr,
 				"Add rule - bad keyword %s\n", optarg);
 				retval = -1;
@@ -566,7 +581,11 @@ static int setopt(int count, char *vars[])
 		break;
         case 'd':
 		rc = audit_rule_setup(optarg, &del, &action);
-		if (rc > 1) {
+		if (rc == 3) {
+			fprintf(stderr,
+				"Multiple rule insert/delete operation is not allowed\n");
+			retval = -1;
+		} else if (rc == 2) {
 			fprintf(stderr, "Delete rule - bad keyword %s\n",
 				optarg);
 			retval = -1;
#3 lore raw
Quoted 2 lines · On Monday 21 July 2008 21:24:54 Yu Zhiguo wrote:

  This is the patch, can you apply it?
  If there are some deficiencies, please give me your indication.

Looks good. Thanks for the patch.

-Steve