XDG_RUNTIME_DIR on a system with no "logins"

Guillermo Rodriguez guillerodriguez.dev at gmail.com
Wed Dec 18 12:10:14 UTC 2019


El mié., 18 dic. 2019 a las 10:56, Pekka Paalanen
(<ppaalanen at gmail.com>) escribió:
>
> On Tue, 17 Dec 2019 19:18:15 +0100 (CET)
> Jan Engelhardt <jengelh at inai.de> wrote:
>
> > On Tuesday 2019-12-17 18:55, Guillermo Rodriguez wrote:
> >
> > >Hi all,
> > >
> > >Weston requires XDG_RUNTIME_DIR to exist. The specification for this
> > >(https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html)
> > >says:
> > >
> > >===
> > >$XDG_RUNTIME_DIR defines the base directory relative to which
> > >user-specific non-essential runtime files and other file objects (such
> > >as sockets, named pipes, ...) should be stored. The directory MUST be
> > >owned by the user, and he MUST be the only one having read and write
> > >access to it. Its Unix access mode MUST be 0700.
> > >
> > >The lifetime of the directory MUST be bound to the user being logged
> > >in. It MUST be created when the user first logs in and if the user
> > >fully logs out the directory MUST be removed. If the user logs in more
> > >than once he should get pointed to the same directory, and it is
> > >mandatory that the directory continues to exist from his first login
> > >to his last logout on the system, and not removed in between. Files in
> > >the directory MUST not survive reboot or a full logout/login cycle.
> > >===
> > >
> > >But how is this done for a system where normally no users "log in",
> > >e.g. a fixed-function embedded system with a graphical user interface?
> >
> > Well you simply create the directory before running the program that desires
> > said directory. Does not matter if the user identity change is by way of
> > a system manager, runuser(8), or login(8)/PAM (as called by xdm/etc.).
> >
> >
> > kiosk.service
> >  User=npc
> >  ExecStart=/home/npc/startx.sh
> >
> > startx.sh:
> >  export XDG_RUNTIME_DIR=/home/npc/xdg
> >  rm -Rf "$XDG_RUNTIME_DIR"
> >  mkdir "$XDG_RUNTIME_DIR"
> >  weston # or whatever

OK so I can just "make up" a xdg dir which is not bound to any specific
user. Although this obviously wouldn't meet the specs quoted above
("The lifetime of the directory MUST be bound to the user being logged
in" ...)

In my application I need to run several clients, and each one is started
from a separate SysV init script. I guess that I will need to define the
XDG_RUNTIME_DIR env var to point to this "made up" location in each
script. A bit ugly...

>
> If you invent XDG_RUNTIME_DIR like this, please also make sure to
> adhere to the XDG specification requirements. Specifically, it is a
> good idea to use a tmpfs for this. If it is backed by an actual
> disk, it may incur unnecessary disk I/O, which in embedded systems
> might be really bad.
>
>
> Thanks,
> pq

Thanks,

Guillermo


More information about the wayland-devel mailing list