linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Only lookup uid/gid when applying rules
@ 2006-08-01 10:35 Roy Marples
  2006-08-01 12:35 ` Kay Sievers
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: Roy Marples @ 2006-08-01 10:35 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 568 bytes --]

Hi List

Attached is a patch that stops udev from doing a uid/gid lookup unless it is 
actually going to use the rule.

This is important as udev ships with rules for user/group names that may not 
exist in /etc/passwd. Normally this would not be a problem, but if a system 
is configured for LDAP, NIS or some other off line system at boot time then 
things get very nasty.

See Gentoo bug #99564 for futher commentary on this
http://bugs.gentoo.org/show_bug.cgi?id=99564

Thanks

-- 
Roy Marples <uberlord@gentoo.org>
Gentoo/Linux Developer (baselayout, networking)

[-- Attachment #2: udev-nolookup.patch --]
[-- Type: text/x-diff, Size: 3850 bytes --]

diff -u udev-094.orig/udev.c udev-094/udev.c
--- udev-094.orig/udev.c	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udev.c	2006-07-07 14:41:39.000000000 +0100
@@ -128,7 +128,7 @@
 	}
 
 	sysfs_init();
-	udev_rules_init(&rules, 0);
+	udev_rules_init(&rules);
 
 	dev = sysfs_device_get(devpath);
 	if (dev == NULL) {
diff -u udev-094.orig/udevd.c udev-094/udevd.c
--- udev-094.orig/udevd.c	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udevd.c	2006-07-07 14:41:56.000000000 +0100
@@ -908,7 +908,7 @@
 
 	/* parse the rules and keep it in memory */
 	sysfs_init();
-	udev_rules_init(&rules, 1);
+	udev_rules_init(&rules);
 
 	export_initial_seqnum();
 
@@ -1088,7 +1088,7 @@
 		if (reload_config) {
 			reload_config = 0;
 			udev_rules_cleanup(&rules);
-			udev_rules_init(&rules, 1);
+			udev_rules_init(&rules);
 		}
 
 		/* forked child has returned */
diff -u udev-094.orig/udev_rules.h udev-094/udev_rules.h
--- udev-094.orig/udev_rules.h	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udev_rules.h	2006-07-07 14:41:27.000000000 +0100
@@ -98,10 +98,9 @@
 	char *buf;
 	size_t bufsize;
 	size_t current;
-	int resolve_names;
 };
 
-extern int udev_rules_init(struct udev_rules *rules, int resolve_names);
+extern int udev_rules_init(struct udev_rules *rules);
 extern void udev_rules_cleanup(struct udev_rules *rules);
 
 extern void udev_rules_iter_init(struct udev_rules *rules);
diff -u udev-094.orig/udev_rules_parse.c udev-094/udev_rules_parse.c
--- udev-094.orig/udev_rules_parse.c	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udev_rules_parse.c	2006-07-07 14:41:00.000000000 +0100
@@ -473,38 +473,12 @@
 
 		if (strcasecmp(key, "OWNER") == 0) {
 			valid = 1;
-			if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) {
-				char *endptr;
-				strtoul(value, &endptr, 10);
-				if (endptr[0] != '\0') {
-					char owner[32];
-					uid_t uid = lookup_user(value);
-					dbg("replacing username='%s' by id=%i", value, uid);
-					sprintf(owner, "%u", (unsigned int) uid);
-					add_rule_key(rule, &rule->owner, operation, owner);
-					continue;
-				}
-			}
-
 			add_rule_key(rule, &rule->owner, operation, value);
 			continue;
 		}
 
 		if (strcasecmp(key, "GROUP") == 0) {
 			valid = 1;
-			if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) {
-				char *endptr;
-				strtoul(value, &endptr, 10);
-				if (endptr[0] != '\0') {
-					char group[32];
-					gid_t gid = lookup_group(value);
-					dbg("replacing groupname='%s' by id=%i", value, gid);
-					sprintf(group, "%u", (unsigned int) gid);
-					add_rule_key(rule, &rule->group, operation, group);
-					continue;
-				}
-			}
-
 			add_rule_key(rule, &rule->group, operation, value);
 			continue;
 		}
@@ -637,13 +611,12 @@
 	return retval;
 }
 
-int udev_rules_init(struct udev_rules *rules, int resolve_names)
+int udev_rules_init(struct udev_rules *rules)
 {
 	struct stat stats;
 	int retval;
 
 	memset(rules, 0x00, sizeof(struct udev_rules));
-	rules->resolve_names = resolve_names;
 
 	/* parse rules file or all matching files in directory */
 	if (stat(udev_rules_filename, &stats) != 0)
diff -u udev-094.orig/udevstart.c udev-094/udevstart.c
--- udev-094.orig/udevstart.c	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udevstart.c	2006-07-07 14:42:25.000000000 +0100
@@ -361,7 +361,7 @@
 	alarm(UDEV_ALARM_TIMEOUT);
 
 	sysfs_init();
-	udev_rules_init(&rules, 1);
+	udev_rules_init(&rules);
 
 	udev_scan_class(&device_list);
 	udev_scan_block(&device_list);
diff -u udev-094.orig/udevtest.c udev-094/udevtest.c
--- udev-094.orig/udevtest.c	2006-07-07 14:39:34.000000000 +0100
+++ udev-094/udevtest.c	2006-07-07 14:42:11.000000000 +0100
@@ -83,7 +83,7 @@
 			devpath = argv[1];
 
 	sysfs_init();
-	udev_rules_init(&rules, 0);
+	udev_rules_init(&rules);
 
 	dev = sysfs_device_get(devpath);
 	if (dev == NULL) {

[-- Attachment #3: Type: text/plain, Size: 348 bytes --]

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

[-- Attachment #4: Type: text/plain, Size: 226 bytes --]

_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2006-08-05  3:37 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 10:35 [PATCH] Only lookup uid/gid when applying rules Roy Marples
2006-08-01 12:35 ` Kay Sievers
2006-08-01 12:54 ` Roy Marples
2006-08-01 13:12 ` Kay Sievers
2006-08-01 13:56 ` Roy Marples
2006-08-04 23:32 ` Roy Marples
2006-08-05  0:04 ` Kay Sievers
2006-08-05  0:29 ` Marco d'Itri
2006-08-05  0:40 ` Kay Sievers
2006-08-05  0:43 ` Marco d'Itri
2006-08-05  0:49 ` Kay Sievers
2006-08-05  0:52 ` Marco d'Itri
2006-08-05  2:20 ` Roy Marples
2006-08-05  2:42 ` Kay Sievers
2006-08-05  2:59 ` Roy Marples
2006-08-05  3:07 ` Kay Sievers
2006-08-05  3:37 ` Roy Marples

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).