linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev - TODO update
Date: Sat, 28 Feb 2004 22:19:48 +0000	[thread overview]
Message-ID: <20040228221948.GA1359@vrfy.org> (raw)
In-Reply-To: <20040212234538.GC21117@vrfy.org>

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

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

[-- Attachment #2: 04-localuser.patch --]
[-- Type: text/plain, Size: 1468 bytes --]

===== 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 <grp.h>
 #ifndef __KLIBC__
 #include <pwd.h>
+#include <utmp.h>
 #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);

  parent reply	other threads:[~2004-02-28 22:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-12 23:45 udev - TODO update Kay Sievers
2004-02-13  1:26 ` Greg KH
2004-02-13  1:59 ` Kay Sievers
2004-02-13  6:16 ` Daniel Drake
2004-02-13  8:31 ` Olaf Hering
2004-02-13 17:52 ` Mike Frysinger
2004-02-13 19:34 ` Daniel Stekloff
2004-02-13 22:53 ` Greg KH
2004-02-17  1:41 ` Greg KH
2004-02-17  1:48 ` Mike Frysinger
2004-02-27  0:41 ` Kay Sievers
2004-02-27  0:49 ` Robert Love
2004-02-27  1:00 ` Greg KH
2004-02-27  1:13 ` Mike Frysinger
2004-02-27  1:23 ` Mike Waychison
2004-02-27  1:27 ` Robert Love
2004-02-27  1:36 ` Robert Love
2004-02-27  2:24 ` Bill Nottingham
2004-02-27 11:03 ` Robert McMeekin
2004-02-27 15:45 ` Kay Sievers
2004-02-27 17:35 ` Greg KH
2004-02-27 17:37 ` Greg KH
2004-02-27 18:08 ` Mike Waychison
2004-02-27 19:10 ` Bill Nottingham
2004-02-27 19:19 ` Robert Love
2004-02-27 19:20 ` Robert Love
2004-02-28  0:55 ` Greg KH
2004-02-28 13:07 ` Erik van Konijnenburg
2004-02-28 16:47 ` Robert Love
2004-02-28 22:19 ` Kay Sievers [this message]
2004-02-28 22:37 ` Robert Love
2004-02-29  4:01 ` Kay Sievers
2004-03-01 22:44 ` Greg KH
2004-03-01 23:05 ` Robert Love
2004-03-01 23:16 ` Greg KH
2004-03-02  0:04 ` Kay Sievers
2004-03-02  0:09 ` Greg KH
2004-03-02  7:24 ` [linux-hotplug-devel] " Wout Mertens
2004-03-02  7:32 ` Wout Mertens
2004-03-02 20:15 ` Greg KH
2004-03-02 20:55 ` Wout Mertens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040228221948.GA1359@vrfy.org \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).