[ConsoleKit] consolekit userid session counters
Stef Bon
stef at bononline.nl
Fri Feb 26 00:58:06 PST 2010
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
More information about the ConsoleKit
mailing list