Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 99564 | Differences between
and this patch

Collapse All | Expand All

(-)udev-096.orig/udev.c (-1 / +1 lines)
Lines 128-134 Link Here
128
	}
128
	}
129
129
130
	sysfs_init();
130
	sysfs_init();
131
	udev_rules_init(&rules, 0);
131
	udev_rules_init(&rules);
132
132
133
	dev = sysfs_device_get(devpath);
133
	dev = sysfs_device_get(devpath);
134
	if (dev == NULL) {
134
	if (dev == NULL) {
(-)udev-096.orig/udevd.c (-2 / +2 lines)
Lines 908-914 Link Here
908
908
909
	/* parse the rules and keep it in memory */
909
	/* parse the rules and keep it in memory */
910
	sysfs_init();
910
	sysfs_init();
911
	udev_rules_init(&rules, 1);
911
	udev_rules_init(&rules);
912
912
913
	export_initial_seqnum();
913
	export_initial_seqnum();
914
914
Lines 1088-1094 Link Here
1088
		if (reload_config) {
1088
		if (reload_config) {
1089
			reload_config = 0;
1089
			reload_config = 0;
1090
			udev_rules_cleanup(&rules);
1090
			udev_rules_cleanup(&rules);
1091
			udev_rules_init(&rules, 1);
1091
			udev_rules_init(&rules);
1092
		}
1092
		}
1093
1093
1094
		/* forked child has returned */
1094
		/* forked child has returned */
(-)udev-096.orig/udev_device.c (+21 lines)
Lines 162-167 Link Here
162
			goto exit;
162
			goto exit;
163
		}
163
		}
164
164
165
		/* If we don't have owner and group id's, look them up now and
166
		   store them back in the rule for other devices. */
167
		unsigned long id;
168
		char *endptr;
169
		uid_t uid = 0;
170
		gid_t gid = 0;
171
172
		id = strtoul(udev->owner, &endptr, 10);
173
		if (endptr[0] != '\0') {
174
			if (strcmp(udev->owner, "root") != 0)
175
				uid = lookup_user(udev->owner);
176
			sprintf(udev->owner, "%u", (unsigned int) uid);
177
		}
178
179
		id = strtoul(udev->group, &endptr, 10);
180
		if (endptr[0] != '\0') {
181
			if (strcmp(udev->group, "root") != 0)
182
				gid = lookup_group(udev->group);
183
			sprintf(udev->group, "%u", (unsigned int) gid);
184
		}
185
165
		/* read current database entry, we may want to cleanup symlinks */
186
		/* read current database entry, we may want to cleanup symlinks */
166
		udev_old = udev_device_init();
187
		udev_old = udev_device_init();
167
		if (udev_old != NULL) {
188
		if (udev_old != NULL) {
(-)udev-096.orig/udev_rules.h (-2 / +1 lines)
Lines 98-107 Link Here
98
	char *buf;
98
	char *buf;
99
	size_t bufsize;
99
	size_t bufsize;
100
	size_t current;
100
	size_t current;
101
	int resolve_names;
102
};
101
};
103
102
104
extern int udev_rules_init(struct udev_rules *rules, int resolve_names);
103
extern int udev_rules_init(struct udev_rules *rules);
105
extern void udev_rules_cleanup(struct udev_rules *rules);
104
extern void udev_rules_cleanup(struct udev_rules *rules);
106
105
107
extern void udev_rules_iter_init(struct udev_rules *rules);
106
extern void udev_rules_iter_init(struct udev_rules *rules);
(-)udev-096.orig/udev_rules_parse.c (-28 / +1 lines)
Lines 473-510 Link Here
473
473
474
		if (strcasecmp(key, "OWNER") == 0) {
474
		if (strcasecmp(key, "OWNER") == 0) {
475
			valid = 1;
475
			valid = 1;
476
			if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) {
477
				char *endptr;
478
				strtoul(value, &endptr, 10);
479
				if (endptr[0] != '\0') {
480
					char owner[32];
481
					uid_t uid = lookup_user(value);
482
					dbg("replacing username='%s' by id=%i", value, uid);
483
					sprintf(owner, "%u", (unsigned int) uid);
484
					add_rule_key(rule, &rule->owner, operation, owner);
485
					continue;
486
				}
487
			}
488
489
			add_rule_key(rule, &rule->owner, operation, value);
476
			add_rule_key(rule, &rule->owner, operation, value);
490
			continue;
477
			continue;
491
		}
478
		}
492
479
493
		if (strcasecmp(key, "GROUP") == 0) {
480
		if (strcasecmp(key, "GROUP") == 0) {
494
			valid = 1;
481
			valid = 1;
495
			if (rules->resolve_names && (!strchr(value, '$') && !strchr(value, '%'))) {
496
				char *endptr;
497
				strtoul(value, &endptr, 10);
498
				if (endptr[0] != '\0') {
499
					char group[32];
500
					gid_t gid = lookup_group(value);
501
					dbg("replacing groupname='%s' by id=%i", value, gid);
502
					sprintf(group, "%u", (unsigned int) gid);
503
					add_rule_key(rule, &rule->group, operation, group);
504
					continue;
505
				}
506
			}
507
508
			add_rule_key(rule, &rule->group, operation, value);
482
			add_rule_key(rule, &rule->group, operation, value);
509
			continue;
483
			continue;
510
		}
484
		}
Lines 637-649 Link Here
637
	return retval;
611
	return retval;
638
}
612
}
639
613
640
int udev_rules_init(struct udev_rules *rules, int resolve_names)
614
int udev_rules_init(struct udev_rules *rules)
641
{
615
{
642
	struct stat stats;
616
	struct stat stats;
643
	int retval;
617
	int retval;
644
618
645
	memset(rules, 0x00, sizeof(struct udev_rules));
619
	memset(rules, 0x00, sizeof(struct udev_rules));
646
	rules->resolve_names = resolve_names;
647
620
648
	/* parse rules file or all matching files in directory */
621
	/* parse rules file or all matching files in directory */
649
	if (stat(udev_rules_filename, &stats) != 0)
622
	if (stat(udev_rules_filename, &stats) != 0)
(-)udev-096.orig/udevstart.c (-1 / +1 lines)
Lines 361-367 Link Here
361
	alarm(UDEV_ALARM_TIMEOUT);
361
	alarm(UDEV_ALARM_TIMEOUT);
362
362
363
	sysfs_init();
363
	sysfs_init();
364
	udev_rules_init(&rules, 1);
364
	udev_rules_init(&rules);
365
365
366
	udev_scan_class(&device_list);
366
	udev_scan_class(&device_list);
367
	udev_scan_block(&device_list);
367
	udev_scan_block(&device_list);
(-)udev-096.orig/udevtest.c (-1 / +1 lines)
Lines 83-89 Link Here
83
			devpath = argv[1];
83
			devpath = argv[1];
84
84
85
	sysfs_init();
85
	sysfs_init();
86
	udev_rules_init(&rules, 0);
86
	udev_rules_init(&rules);
87
87
88
	dev = sysfs_device_get(devpath);
88
	dev = sysfs_device_get(devpath);
89
	if (dev == NULL) {
89
	if (dev == NULL) {

Return to bug 99564