linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Love <rml@tech9.net>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev - TODO update
Date: Fri, 27 Feb 2004 01:36:38 +0000	[thread overview]
Message-ID: <1077845798.1668.462.camel@localhost> (raw)
In-Reply-To: <20040212234538.GC21117@vrfy.org>

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

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


[-- Attachment #2: local.c --]
[-- Type: text/x-csrc, Size: 591 bytes --]

/*
 * detect the local user
 *
 * rml@ximian.com
 */

#include <stdio.h>
#include <string.h>
#include <utmp.h>

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;
}

  parent reply	other threads:[~2004-02-27  1:36 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 [this message]
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
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=1077845798.1668.462.camel@localhost \
    --to=rml@tech9.net \
    --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).