From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Love Date: Fri, 27 Feb 2004 01:36:38 +0000 Subject: Re: udev - TODO update Message-Id: <1077845798.1668.462.camel@localhost> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-ac72uSphB8D1wrKTTH1w" List-Id: References: <20040212234538.GC21117@vrfy.org> In-Reply-To: <20040212234538.GC21117@vrfy.org> To: linux-hotplug@vger.kernel.org --=-ac72uSphB8D1wrKTTH1w Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2004-02-26 at 20:27, Robert Love wrote: > On Thu, 2004-02-26 at 20:00, Greg KH wrote: > > > And how does a program determine the "current local user"? > > utmp. Here is an example. Just stick this code where we do the chmod(), and invoke it if the user is $local or whatever. The purpose being we want certain devices to be owned by the local user. Obviously we also need to do some stuff on login/logout, but consolehelper will do that for us. Robert Love --=-ac72uSphB8D1wrKTTH1w Content-Disposition: attachment; filename=local.c Content-Type: text/x-csrc; name=local.c; charset=UTF-8 Content-Transfer-Encoding: 7bit /* * detect the local user * * rml@ximian.com */ #include #include #include int main() { struct utmp *u; char user[UT_NAMESIZE] = "root"; time_t recent = 0; setutent(); while ((u = getutent())) { /* is this a user login ? */ if (u->ut_type != USER_PROCESS) continue; /* XXX: should probably check if the pid is stale */ /* is this a local login ? */ if (strcmp(u->ut_host, "")) continue; if (u->ut_time > recent) { recent = u->ut_time; strcpy(user, u->ut_user); } } endutent(); printf("%s\n", user); return 0; } --=-ac72uSphB8D1wrKTTH1w-- ------------------------------------------------------- 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