- fixed dvb permissions (bz #179993) - added support for scsi media changer (bz #181911) - fixed pktcdvd device creation (bz #161268)
105 lines
2.7 KiB
Diff
105 lines
2.7 KiB
Diff
If we're looking for a user's primary GID, look up the primary GID instead of
|
|
guessing the name of the user's primary group.
|
|
|
|
--- udev-084/udev_libc_wrapper.h 2006-01-30 02:51:38.000000000 -0500
|
|
+++ udev-084/udev_libc_wrapper.h 2006-02-13 17:22:56.000000000 -0500
|
|
@@ -139,6 +139,7 @@
|
|
#endif
|
|
|
|
extern uid_t lookup_user(const char *user);
|
|
+extern gid_t lookup_user_primary_group(const char *user);
|
|
extern gid_t lookup_group(const char *group);
|
|
|
|
extern size_t strlcpy(char *dst, const char *src, size_t size);
|
|
--- udev-084/udev_libc_wrapper.c 2006-01-30 02:51:38.000000000 -0500
|
|
+++ udev-084/udev_libc_wrapper.c 2006-02-13 17:38:48.000000000 -0500
|
|
@@ -106,6 +106,20 @@
|
|
return uid;
|
|
}
|
|
|
|
+gid_t lookup_user_primary_group(const char *user)
|
|
+{
|
|
+ struct passwd *pw;
|
|
+ gid_t gid = 0;
|
|
+
|
|
+ pw = getpwnam(user);
|
|
+ if (pw == NULL)
|
|
+ info("specified user unknown '%s'", user);
|
|
+ else
|
|
+ gid = pw->pw_gid;
|
|
+
|
|
+ return gid;
|
|
+}
|
|
+
|
|
gid_t lookup_group(const char *group)
|
|
{
|
|
struct group *gr;
|
|
@@ -126,7 +140,8 @@
|
|
#define GROUP_FILE "/etc/group"
|
|
|
|
/* return the id of a passwd style line, selected by the users name */
|
|
-static unsigned long get_id_by_name(const char *uname, const char *dbfile)
|
|
+static unsigned long get_id_field_by_name(const char *uname, const char *dbfile,
|
|
+ int field)
|
|
{
|
|
unsigned long id = 0;
|
|
char line[LINE_SIZE];
|
|
@@ -165,8 +180,14 @@
|
|
if (name == NULL)
|
|
continue;
|
|
|
|
- /* skip pass */
|
|
- if (strsep(&pos, ":") == NULL)
|
|
+ /* skip password and n other fields */
|
|
+ field -= 2;
|
|
+ while (field > 0) {
|
|
+ if ((pos == NULL) || (strsep(&pos, ":") == NULL))
|
|
+ continue;
|
|
+ field--;
|
|
+ }
|
|
+ if (pos == NULL)
|
|
continue;
|
|
|
|
/* get id */
|
|
@@ -189,6 +210,15 @@
|
|
return id;
|
|
}
|
|
|
|
+static unsigned long get_id_by_name(const char *uname, const char *dbfile)
|
|
+{
|
|
+ return get_id_field_by_name(uname, dbfile, 3);
|
|
+}
|
|
+static unsigned long get_second_id_by_name(const char *uname, const char *dbfile)
|
|
+{
|
|
+ return get_id_field_by_name(uname, dbfile, 4);
|
|
+}
|
|
+
|
|
uid_t lookup_user(const char *user)
|
|
{
|
|
unsigned long id;
|
|
@@ -197,6 +227,14 @@
|
|
return (uid_t) id;
|
|
}
|
|
|
|
+gid_t lookup_user_primary_group(const char *user)
|
|
+{
|
|
+ unsigned long id;
|
|
+
|
|
+ id = get_second_id_by_name(user, PASSWD_FILE);
|
|
+ return (gid_t) id;
|
|
+}
|
|
+
|
|
gid_t lookup_group(const char *group)
|
|
{
|
|
unsigned long id;
|
|
--- udev-084/extras/volume_id/vol_id.c 2006-01-30 02:51:38.000000000 -0500
|
|
+++ udev-084/extras/volume_id/vol_id.c 2006-02-13 17:22:56.000000000 -0500
|
|
@@ -151,7 +151,7 @@
|
|
|
|
/* drop all privileges */
|
|
nobody_uid = lookup_user("nobody");
|
|
- nobody_gid = lookup_group("nogroup");
|
|
+ nobody_gid = lookup_user_primary_group("nobody");
|
|
if (nobody_uid > 0 && nobody_gid > 0) {
|
|
if (setgroups(0, NULL) != 0 ||
|
|
setgid(nobody_gid) != 0 ||
|