[systemd-devel] Best practice for prepopulating the CacheDirectory of dynamic users
Antoine Pietri
antoine.pietri1 at gmail.com
Wed Feb 28 17:22:37 UTC 2018
On Wed, Feb 28, 2018 at 6:13 PM, Lennart Poettering
<lennart at poettering.net> wrote:
>> Okay! Does that also apply to the other possible approach I sent in my
>> second mail? (Running a `dummy sh -c read` service with systemd-run,
>> do the setup and kill it when the setup is done). The advantage of
>> that one is that you can do any arbitrary processing while staying in
>> the Python code.
>
> I am not sure I follow?
If you run from the script:
systemd-run -P -p DynamicUser=yes -p CacheDirectory=mywrapper sh -c read
This will do all the setup with the symlink to /var/cache/private, and
then just hang. While the process is hanging, you can do the
processing you need in the cache directory, including populating it
with whatever you want.
Once your processing is over, you can kill the systemd-run process. On
subsequent calls to systemd-run, the files you added will just be
recursively chmod()ed by systemd, so you should just get back the
directory populated with your files with the correct permissions.
--
Antoine Pietri
More information about the systemd-devel
mailing list