summaryrefslogtreecommitdiff
path: root/udev-add.c
diff options
context:
space:
mode:
authorgreg@kroah.com <greg@kroah.com>2003-11-23 20:56:18 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:02 -0700
commit10950dfe84c064da2fde8d812c0c90cfba836d16 (patch)
treeebf613aec3e666490fcdcc3bbf09cda891995902 /udev-add.c
parent2023350eece60db60d30e387cfb644df09b9e8b6 (diff)
[PATCH] add support for string group and string user names in udev.permissions.
This only works if you are using glibc. Patch based on patch from Marco d'Itri <md@Linux.IT>
Diffstat (limited to 'udev-add.c')
-rw-r--r--udev-add.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/udev-add.c b/udev-add.c
index 7ba873a8d4..634a515c96 100644
--- a/udev-add.c
+++ b/udev-add.c
@@ -28,12 +28,18 @@
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <grp.h>
+#ifndef __KLIBC__
+#include <pwd.h>
+#endif
#include "udev.h"
#include "udev_version.h"
#include "namedev.h"
#include "udevdb.h"
#include "libsysfs/libsysfs.h"
+#include "klibc_fixups.h"
/*
* Right now the major/minor of a device is stored in a file called
@@ -146,8 +152,13 @@ static int create_node(struct udevice *dev)
unsigned long id = strtoul(dev->owner, &endptr, 10);
if (*endptr == 0x00)
uid = (uid_t) id;
- else
- dbg("only numeric owner id supported: %s", dev->owner);
+ else {
+ struct passwd *pw = getpwnam(dev->owner);
+ if (!pw)
+ dbg("user unknown: %s", dev->owner);
+ else
+ uid = pw->pw_uid;
+ }
}
if (*dev->group) {
@@ -155,8 +166,13 @@ static int create_node(struct udevice *dev)
unsigned long id = strtoul(dev->group, &endptr, 10);
if (*endptr == 0x00)
gid = (gid_t) id;
- else
- dbg("only numeric group id supported: %s", dev->group);
+ else {
+ struct group *gr = getgrnam(dev->group);
+ if (!gr)
+ dbg("group unknown: %s", dev->group);
+ else
+ gid = gr->gr_gid;
+ }
}
if (uid || gid) {