From: Kay Sievers Date: Tue, 21 Oct 2008 10:43:07 +0000 (+0200) Subject: add "root" == 0 shortcuts to lookup_user/group() X-Git-Tag: 174~1409 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20254eb02172d5763556ce5c50ce3a3c6c1d3070;p=systemd add "root" == 0 shortcuts to lookup_user/group() --- diff --git a/udev/udev-util.c b/udev/udev-util.c index d45d444e..76445bbc 100644 --- a/udev/udev-util.c +++ b/udev/udev-util.c @@ -129,6 +129,8 @@ uid_t util_lookup_user(struct udev *udev, const char *user) struct passwd *pw; uid_t uid = 0; + if (strcmp(user, "root") == 0) + return 0; errno = 0; pw = getpwnam(user); if (pw == NULL) { @@ -138,7 +140,6 @@ uid_t util_lookup_user(struct udev *udev, const char *user) err(udev, "error resolving user '%s': %m\n", user); } else uid = pw->pw_uid; - return uid; } @@ -147,6 +148,8 @@ extern gid_t util_lookup_group(struct udev *udev, const char *group) struct group *gr; gid_t gid = 0; + if (strcmp(group, "root") == 0) + return 0; errno = 0; gr = getgrnam(group); if (gr == NULL) { @@ -156,7 +159,6 @@ extern gid_t util_lookup_group(struct udev *udev, const char *group) err(udev, "error resolving group '%s': %m\n", group); } else gid = gr->gr_gid; - return gid; }