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) |