mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-23 23:10:57 +07:00
[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>
This commit is contained in:
parent
2023350eec
commit
10950dfe84
24
udev-add.c
24
udev-add.c
@ -28,12 +28,18 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <grp.h>
|
||||||
|
#ifndef __KLIBC__
|
||||||
|
#include <pwd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "udev.h"
|
#include "udev.h"
|
||||||
#include "udev_version.h"
|
#include "udev_version.h"
|
||||||
#include "namedev.h"
|
#include "namedev.h"
|
||||||
#include "udevdb.h"
|
#include "udevdb.h"
|
||||||
#include "libsysfs/libsysfs.h"
|
#include "libsysfs/libsysfs.h"
|
||||||
|
#include "klibc_fixups.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Right now the major/minor of a device is stored in a file called
|
* 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);
|
unsigned long id = strtoul(dev->owner, &endptr, 10);
|
||||||
if (*endptr == 0x00)
|
if (*endptr == 0x00)
|
||||||
uid = (uid_t) id;
|
uid = (uid_t) id;
|
||||||
else
|
else {
|
||||||
dbg("only numeric owner id supported: %s", dev->owner);
|
struct passwd *pw = getpwnam(dev->owner);
|
||||||
|
if (!pw)
|
||||||
|
dbg("user unknown: %s", dev->owner);
|
||||||
|
else
|
||||||
|
uid = pw->pw_uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*dev->group) {
|
if (*dev->group) {
|
||||||
@ -155,8 +166,13 @@ static int create_node(struct udevice *dev)
|
|||||||
unsigned long id = strtoul(dev->group, &endptr, 10);
|
unsigned long id = strtoul(dev->group, &endptr, 10);
|
||||||
if (*endptr == 0x00)
|
if (*endptr == 0x00)
|
||||||
gid = (gid_t) id;
|
gid = (gid_t) id;
|
||||||
else
|
else {
|
||||||
dbg("only numeric group id supported: %s", dev->group);
|
struct group *gr = getgrnam(dev->group);
|
||||||
|
if (!gr)
|
||||||
|
dbg("group unknown: %s", dev->group);
|
||||||
|
else
|
||||||
|
gid = gr->gr_gid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uid || gid) {
|
if (uid || gid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user