summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-02-18 12:18:56 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-02-18 12:22:54 +0900
commit72ca8f71c1640c8ab413bd46121396134420d506 (patch)
tree4d873ce22411b6651913c53cdd442bf9528d4dac /src/udev/udev-rules.c
parent145e020ac3fe15cfcffcaaaaa6f791820c20e70b (diff)
downloadsystemd-72ca8f71c1640c8ab413bd46121396134420d506.tar.gz
systemd-72ca8f71c1640c8ab413bd46121396134420d506.tar.bz2
systemd-72ca8f71c1640c8ab413bd46121396134420d506.zip
udev-rules: use parse_uid() or parse_gid()
Diffstat (limited to 'src/udev/udev-rules.c')
-rw-r--r--src/udev/udev-rules.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 4d755ae9bc..ce787786a6 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1334,13 +1334,11 @@ static void add_rule(UdevRules *rules, char *line,
} else if (streq(key, "OWNER")) {
uid_t uid;
- char *endptr;
if (op == OP_REMOVE)
LOG_AND_RETURN("Invalid %s operation", key);
- uid = strtoul(value, &endptr, 10);
- if (endptr[0] == '\0')
+ if (parse_uid(value, &uid) >= 0)
r = rule_add_key(&rule_tmp, TK_A_OWNER_ID, op, NULL, &uid);
else if (rules->resolve_name_timing == RESOLVE_NAME_EARLY && !strchr("$%", value[0])) {
uid = add_uid(rules, value);
@@ -1358,13 +1356,11 @@ static void add_rule(UdevRules *rules, char *line,
} else if (streq(key, "GROUP")) {
gid_t gid;
- char *endptr;
if (op == OP_REMOVE)
LOG_AND_RETURN("Invalid %s operation", key);
- gid = strtoul(value, &endptr, 10);
- if (endptr[0] == '\0')
+ if (parse_gid(value, &gid) >= 0)
r = rule_add_key(&rule_tmp, TK_A_GROUP_ID, op, NULL, &gid);
else if ((rules->resolve_name_timing == RESOLVE_NAME_EARLY) && !strchr("$%", value[0])) {
gid = add_gid(rules, value);