:: Re: [DNG] libpam-xdg-support / libp…
Kezdőlap
Delete this message
Reply to this message
Szerző: tilt!
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] libpam-xdg-support / libpam-systemd
On 09/11/2015 07:33 AM, tilt! wrote:
> [...]
> #1 A "prefix" for XDG_RUNTIME_DIR, meaning the directory where
> runtime directories are created; [...]
>
 >    XDG_RUNTIME_PREFIX="/tmp/xdg-runtime/user"

>
> This definition could go to "/etc/xdg/runtime-prefix.default"
>
> #2 A procedure that, if called with no arguments, considers the
> setting of #1 and returns a value for XDG_RUNTIME_DIR for the current
> user:
>
 >    . /etc/xdg/runtime-prefix.default

>
 >    xdg_runtime_dir_default() {
 >       echo "$XDG_RUNTIME_PREFIX/$(/usr/bin/id -ru)"
 >    }

>
> This code could go to "/etc/xdg/runtime-dir-default.sh".
>
> #3 An integration in the X session that applies these settings:
>
 >    . /etc/xdg/runtime-dir-default.sh

>
 >    export XDG_RUNTIME_DIR="$(xdg_runtime_dir_default)"

>
> This code could go to "/etc/X11/Xsession.d/61xdg-runtime-dir".
> [...]
> Unaddressed remained the deletion of $XDG_RUNTIME_DIR when a user
> has "fully logged out" as mandated by [2].


Ok, that's an understatement, correct is:

Unadressed remains the lifecycle of $XDG_RUNTIME_DIR, specifically:

* When is $XDG_RUNTIME_PREFIX created?

If $XDG_RUNTIME_PREFIX hosts every user's runtime directory,
it may not be created with ownership of the user, so to do
this alone:

      # as user:


      mkdir -p -m 700 "$XDG_RUNTIME_DIR" # wrong!


is the wrong approach, the prefix has to be created owned by
root, readable by all, and subdirectories have to be created
owned by user, read/writeable for user only.

      # as root:


      mkdir -p -m 755 "$XDG_RUNTIME_PREFIX"


Currently my best guess is that this should be performed
at system startup.

* When is $XDG_RUNTIME_DIR created?

If the prefix is created like described above, it requires
root permissions to create the per-user directory:

     # as root:


     # let $uid be the user ID of the affected user;
     # let $xdg:runtime_dir be the requested runtime directory:


     if ! test -d "$xdg_runtime_dir" ; then
        mkdir -p -m 700 "$xdg_runtime_dir"
        chown $uid:$(id -g $uid) "$xdg_runtime_dir"
     fi


Currently my best guess is that this should be performed
everytime the user starts an X session (it's an X thing
after all, right), but Xsession.d is executed as the
user, not root. Changing into the user ID is a thing of
the display manager, there's no general way to hook in.
Remains PAM. Probably.

* When is $XDG_RUNTIME_DIR deleted?

If the per-user runtime directory is created as i described
above, user permissions suffice to delete it, so it was
sufficent to

     # as user:


     rm -rf "$XDG_RUNTIME_DIR"


Unfortunately i am in the dark over what it means that a
user has "fully logged out". Does it mean that no processes
run with the user's identity anymore? That the user has no
X session running? That the user has no PAM session running?
And, if any of these mean that the user has "fully logged
out", how to hook into such an event and perform the code
suggested above?

Kind regards,
T.