diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2003-11-12 03:47:57 -0800 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:06:23 -0700 |
commit | c19a6b304cd7a727da9758853134b557f5f40705 (patch) | |
tree | 7bd0a01e2ddabf1d37a10292a0a28efbde655c34 /udev-add.c | |
parent | ebc180a2b79913557f7872dbfe12f922f1fdf0e1 (diff) |
[PATCH] add uid/gid to nodes
set uid/gid of node specified in udev.permissions
only numeric id's are supported cause we can't resolve with
klibc or libc before real /etc is mounted
Diffstat (limited to 'udev-add.c')
-rw-r--r-- | udev-add.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/udev-add.c b/udev-add.c index d237834c68..eb1c0fb676 100644 --- a/udev-add.c +++ b/udev-add.c @@ -67,7 +67,8 @@ exit: } /* - * We also want to add some permissions here, and possibly some symlinks + * we possibly want to add some symlinks here + * only numeric owner/group id's are supported */ static int create_node(struct udevice *dev) { @@ -106,7 +107,35 @@ static int create_node(struct udevice *dev) dbg("mknod(%s, %#o, %u, %u) failed with error '%s'", filename, dev->mode, dev->major, dev->minor, strerror(errno)); - // FIXME set the ownership of the node + uid_t uid = 0; + gid_t gid = 0; + + if (*dev->owner) { + char *endptr; + 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); + } + + if (*dev->group) { + char *endptr; + 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); + } + + if (uid || gid) { + dbg("chown(%s, %u, %u)", filename, uid, gid); + retval = chown(filename, uid, gid); + if (retval) + dbg("chown(%s, %u, %u) failed with error '%s'", filename, + uid, gid, strerror(errno)); + } + return retval; } |