From martin.vogt at itwm.fraunhofer.de Wed Feb 24 03:53:53 2010 From: martin.vogt at itwm.fraunhofer.de (Martin Vogt) Date: Wed, 24 Feb 2010 12:53:53 +0100 Subject: [ConsoleKit] consolekit userid session counters Message-ID: <4B851351.2010305@itwm.fraunhofer.de> Hello list, is there a mechanism in consolekit which counts the number of session for a user? I like to run an action if the "user_sessioncounter" reaches zero. Example: I added to ssh: >session optional pam_ck_connector.so and if a user logs into the machine: >if test "$reason" = "session_added"; then > if [ -c /dev/nvidiactl ] ; then > setfacl -m u:${CK_SESSION_USER_UID}:rw /dev/nvidia* > fi >else > if [ -c /dev/nvidiactl ] ; then > setfacl -x u:${CK_SESSION_USER_UID} /dev/nvidia* > fi >fi I'm adding him to the nvidia device. (this is for this project: http://www.virtualgl.org/) But if the users login twice and then logouts from one session all the permissions are revoked. :( An environment variable like ${CK_SESSION_COUNTER_FOR_USER_UID} would be helpful here. Is there such a mechanism? regards, Martin From kay.sievers at vrfy.org Wed Feb 24 08:52:11 2010 From: kay.sievers at vrfy.org (Kay Sievers) Date: Wed, 24 Feb 2010 08:52:11 -0800 Subject: [ConsoleKit] consolekit userid session counters In-Reply-To: <4B851351.2010305@itwm.fraunhofer.de> References: <4B851351.2010305@itwm.fraunhofer.de> Message-ID: On Wed, Feb 24, 2010 at 03:53, Martin Vogt wrote: > is there a mechanism in consolekit which counts the number > of session for a user? > > I like to run an action if the "user_sessioncounter" reaches zero. > But if the users login twice and then logouts > from one session all the permissions are revoked. :( > > An environment variable like > > ${CK_SESSION_COUNTER_FOR_USER_UID} > > would be helpful here. > > Is there such a mechanism? You can read the database, it's an ini-file, and it is dumped before the script is called. Kay From stef at bononline.nl Fri Feb 26 00:58:06 2010 From: stef at bononline.nl (Stef Bon) Date: Fri, 26 Feb 2010 09:58:06 +0100 Subject: [ConsoleKit] consolekit userid session counters In-Reply-To: <4B851351.2010305@itwm.fraunhofer.de> References: <4B851351.2010305@itwm.fraunhofer.de> Message-ID: <201002260958.06966.stef@bononline.nl> On Wednesday 24 February 2010 12:53:53 Martin Vogt wrote: > Hello list, > > is there a mechanism in consolekit which counts the number > of session for a user? Hello, I've had a simular problem. The ConsoleKIt data is not in a format where to get these kinds of characteristics of. First session, not the first session for a user... how many sessions? Therefore, and to get a construction to start scripts/programs when a session is added and when it's removed, I've created a script which is started by the ConsoleKit daemon, run_scripts.ck which is in /etc/ConsoleKit/run-session.d. I'm using it to generaly start scripts/programs when a session starts, and when it ends, in my case the adding of the user to autofs managed directories and start a fuse module. I'ts able to start scripts via the at daemon or directly. It's using some configuration files, so it may look complicated, but you'll get the idea I hope. One of the things - apart from starting scripts - is to maintain a table in /tmp/ConsoleKit which looks like: /tmp/ConsoleKit/sessions/Session1/session ...................................................unixuser .....................................Session2/session ..................................................unixuser ......................../users/root/Session2 -> ../../sessions/Session2 ................................/sbon/Seession1 -> ../../sessions/Session1 It's very easy now for scripts to count the number of sessions. Stef Bon > > I like to run an action if the "user_sessioncounter" reaches zero. > > Example: > > I added to ssh: > >session optional pam_ck_connector.so > > and if a user logs into the machine: > >if test "$reason" = "session_added"; then > > > > if [ -c /dev/nvidiactl ] ; then > > > > setfacl -m u:${CK_SESSION_USER_UID}:rw /dev/nvidia* > > > > fi > > > >else > > > > if [ -c /dev/nvidiactl ] ; then > > > > setfacl -x u:${CK_SESSION_USER_UID} /dev/nvidia* > > > > fi > > > >fi > > I'm adding him to the nvidia device. > (this is for this project: http://www.virtualgl.org/) > > But if the users login twice and then logouts > from one session all the permissions are revoked. :( > > An environment variable like > > ${CK_SESSION_COUNTER_FOR_USER_UID} > > would be helpful here. > > Is there such a mechanism? > > regards, > > Martin > _______________________________________________ > ConsoleKit mailing list > ConsoleKit at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/consolekit From stef at bononline.nl Fri Feb 26 03:40:42 2010 From: stef at bononline.nl (Stef Bon) Date: Fri, 26 Feb 2010 12:40:42 +0100 Subject: [ConsoleKit] consolekit userid session counters In-Reply-To: <4B879F7E.3000202@itwm.fraunhofer.de> References: <4B851351.2010305@itwm.fraunhofer.de> <201002260958.06966.stef@bononline.nl> <4B879F7E.3000202@itwm.fraunhofer.de> Message-ID: <201002261240.42996.stef@bononline.nl> On Friday 26 February 2010 11:16:30 you wrote: > Stef Bon wrote: > > On Wednesday 24 February 2010 12:53:53 Martin Vogt wrote: > >> Hello list, > >> > >> is there a mechanism in consolekit which counts the number > >> of session for a user? > > > > Hello, > > > > I'ts able to start scripts via the at daemon or directly. > > It's using some configuration files, so it may look complicated, but > > you'll get the idea I hope. > > Thanks. > Your mail havent had the url in it but it was easy to find > it with google :) > > http://linux.bononline.nl/linux/runsessionscripts/ > > > Martin Yes sorry, I just reread the mail and just wanted to add the url. I also want to add the following: with Upstart things are getting much more easier and better. When a session starts, there should be a event trigger send to upstart init, with the name "session-started" . This should start the desired session.... ssh, kde, normal login. My point is that they should not be started by kdm or login itself, but by upstart... Now when there is an event session-started, with the right parameters/configuration, everything to start the session properly should follow. From the system point of view this is so much better than having various applications starting the session: one central point. Now to get back to your problem, the script you're having should also start after the session-started event, (something like "start on ...") and everything is running like it should. Stef Bon