From: kay.sievers@vrfy.org Date: Thu, 10 Mar 2005 01:46:26 +0000 (+0100) Subject: [PATCH] don't lookup "root" in the userdb X-Git-Tag: 055~31 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=783272f045faf39325678eef0d55a41d7306e2d3;p=systemd [PATCH] don't lookup "root" in the userdb --- diff --git a/udev_add.c b/udev_add.c index f47ca25f..58f4ee11 100644 --- a/udev_add.c +++ b/udev_add.c @@ -114,8 +114,8 @@ static int create_node(struct udevice *udev, struct sysfs_class_device *class_de char filename[PATH_SIZE]; char partitionname[PATH_SIZE]; struct name_entry *name_loop; - uid_t uid = 0; - gid_t gid = 0; + uid_t uid; + gid_t gid; int tail; int i; @@ -126,24 +126,30 @@ static int create_node(struct udevice *udev, struct sysfs_class_device *class_de if (strchr(udev->name, '/')) create_path(filename); - if (udev->owner[0] != '\0') { + if (strcmp(udev->owner, "root") == 0) + uid = 0; + else { char *endptr; - unsigned long id = strtoul(udev->owner, &endptr, 10); + unsigned long id; + id = strtoul(udev->owner, &endptr, 10); if (endptr[0] == '\0') uid = (uid_t) id; else uid = lookup_user(udev->owner); } - if (udev->group[0] != '\0') { + if (strcmp(udev->group, "root") == 0) + gid = 0; + else { char *endptr; - unsigned long id = strtoul(udev->group, &endptr, 10); + unsigned long id; + id = strtoul(udev->group, &endptr, 10); if (endptr[0] == '\0') gid = (gid_t) id; else - gid = lookup_group(udev->group); + gid = lookup_user(udev->group); } if (!udev->test_run) { diff --git a/udev_utils.c b/udev_utils.c index d572581f..afa9790f 100644 --- a/udev_utils.c +++ b/udev_utils.c @@ -85,8 +85,8 @@ int udev_init_device(struct udevice *udev, const char* devpath, const char *subs } udev->mode = 0660; - strcpy(udev->owner, "0"); - strcpy(udev->group, "0"); + strcpy(udev->owner, "root"); + strcpy(udev->group, "root"); return 0; }