From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Sat, 28 Feb 2004 22:19:48 +0000 Subject: Re: udev - TODO update Message-Id: <20040228221948.GA1359@vrfy.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="d6Gm4EdcadzBjdND" List-Id: References: <20040212234538.GC21117@vrfy.org> In-Reply-To: <20040212234538.GC21117@vrfy.org> To: linux-hotplug@vger.kernel.org --d6Gm4EdcadzBjdND Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Feb 27, 2004 at 02:19:11PM -0500, Robert Love wrote: > On Fri, 2004-02-27 at 12:37, Greg KH wrote: > > > Oh come on. You are so close to actually writing a patch that we can > > use for udev that it's not even funny :) > > > > Care to? > > Yah, when I find the time. ;-) I did it :) Please have a look. If this is what you want, I will solve the klibc beast. We don't need the same for the group ownership, or do we? > I started doing it (and wrote the previous snippet of code) around the > time of the "great daemonization" so I ended up holding off. I recall I > was also worried that, depending on when the permissions were parsed > once we moved to a daemon, they could be a race. Oh, I don't think that we still want the to implement daemon. udevd simply calls our normal udev now and this seems to work well. Or do I miss something? Greg? thanks, Kay --d6Gm4EdcadzBjdND Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="04-localuser.patch" ===== udev-add.c 1.53 vs edited ===== --- 1.53/udev-add.c Sat Feb 28 03:41:27 2004 +++ edited/udev-add.c Sat Feb 28 23:04:22 2004 @@ -32,6 +32,7 @@ #include #ifndef __KLIBC__ #include +#include #endif #include "libsysfs/sysfs/libsysfs.h" @@ -44,6 +45,8 @@ #include "udevdb.h" #include "klibc_fixups.h" +#define LOCAL_USER "$local" + /* * Right now the major/minor of a device is stored in a file called * "dev" in sysfs. @@ -132,6 +135,37 @@ return 0; } +/* get the local logged in user */ +static void set_to_local_user(char *user) +{ + struct utmp *u; + time_t recent = 0; + + strnfieldcpy(user, default_owner_str, OWNER_SIZE); + setutent(); + while (1) { + u = getutent(); + if (u == NULL) + break; + + /* is this a user login ? */ + if (u->ut_type != USER_PROCESS) + continue; + + /* is this a local login ? */ + if (strcmp(u->ut_host, "")) + continue; + + if (u->ut_time > recent) { + recent = u->ut_time; + strfieldcpy(user, u->ut_user); + dbg("set to local user '%s'", user); + break; + } + } + endutent(); +} + static int create_node(struct udevice *dev, int fake) { struct stat stats; @@ -175,6 +209,9 @@ if (endptr[0] == '\0') uid = (uid_t) id; else { + if (strncmp(dev->owner, LOCAL_USER, sizeof(LOCAL_USER)) == 0) + set_to_local_user(dev->owner); + struct passwd *pw = getpwnam(dev->owner); if (pw == NULL) dbg("specified user unknown '%s'", dev->owner); --d6Gm4EdcadzBjdND-- ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel