Skip to contentSkip to conversation

realm: fix inversion

PATCH Applied Simon Lodal 2 participants 3 messages Sep 22, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 realm: fix inversion

Make '--realm ! id' work as advertised.
Make save() output inversion correctly so it can be parsed back in, and work with iptables-restore and iptables-save.

Simon Lodal

extensions/libipt_realm.c +3 -2
diff -ruN iptables-1.2.11.orig/extensions/libipt_realm.c iptables-1.2.11.realm_inversion/extensions/libipt_realm.c
@@ -49,7 +49,8 @@
 	switch (c) {
 		char *end;
 	case '1':
-		check_inverse(optarg, &invert, &optind, 0);
+		if (check_inverse(optarg, &invert, &optind, 0))
+			optarg = argv[optind-1];
 		realminfo->id = strtoul(optarg, &end, 0);
 		if (*end == '/') {
 			realminfo->mask = strtoul(end+1, &end, 0);
@@ -72,7 +73,7 @@
 print_realm(unsigned long id, unsigned long mask, int invert, int numeric)
 {
 	if (invert)
-		fputc('!', stdout);
+		printf("! ");
 
 	if(mask != 0xffffffff)
 		printf("0x%lx/0x%lx ", id, mask);
#1 lore raw
Quoted 3 lines · Simon Lodal

Make '--realm ! id' work as advertised.
Make save() output inversion correctly so it can be parsed back in, and work with iptables-restore and iptables-save.

Applied, thanks.

Quoted 3 lines

Simon Lodal

#2 lore raw

Hmm ... just realized that inversion is generally a mess. Is there any kind of consensus on how to handle it, now/future?

There are 3 ways to specify inversion:

! --ip 1.2.3.4
--ip !1.2.3.4
--ip ! 1.2.3.4

None of them are both 1) documented and 2) working. Especially iptables-save and iptables-restore rarely works with inversion.

You should probably remove my patch in favor of a better solution for all modules.

Simon

Patrick McHardy skrev:

Quoted 9 lines
Quoted 3 lines · Simon Lodal

Make '--realm ! id' work as advertised.
Make save() output inversion correctly so it can be parsed back in, and work with iptables-restore and iptables-save.

Applied, thanks.