Hi,<div><br></div><div>So for OSTree I am trying to move to a model where services populate the contents of /var on *start*.  See previous discussion here:</div><div><br></div><div><a href="https://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg07859.html">https://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg07859.html</a></div><div><br></div><div>The really great part about this is that one is then able to totally reset OS state at any time by simply just doing a shutdown of services, then "rm -rf /var/*", then  reboot.  (You can also reset /etc, that's a separate discussion)</div><div><br></div><div>Now while patching the service code itself got me pretty far, ultimately there are a lot of RPMs and such out there...so what I ended up doing for rpm-ostree was to generate tmpfiles.d snippets from the /var content:</div><div><br></div><div><a href="https://github.com/cgwalters/rpm-ostree/commit/f8ddf38aa2dce207399d5e485842168eb2540e5f">https://github.com/cgwalters/rpm-ostree/commit/f8ddf38aa2dce207399d5e485842168eb2540e5f</a></div><div><br></div><div>Basically we end up with a gigantic /usr/lib/tmpfiles.d/rpm-ostree-autovar.conf that has stuff like:</div><div><br></div><div>d /var/spool/mail 0775 0 12 - -</div><div>d /var/lib/dnsmasq 0755 0 0 - -</div><div>...</div><div><br></div><div>The problem with this is it all happens on boot, and it doesn't really scale.  I want the RPMs (and packages in general) to do this by default.</div><div><br></div><div>So what's the problem with patching the world to do mkdir() on bootup?</div><div><br></div><div>1) Lots of work</div><div>2) Loss of association between package data and directory.  While this is</div><div>    pretty minor, it *is* useful to be able to do rpm -qf /var/kerberos</div><div>    and see that it comes from the "krb5-libs" package.</div><div>3) SELinux labeling - any service that creates a directory like this will</div><div>    have to be sure it labels it correctly.  While the latest SELinux does have</div><div>    support for doing this automatically, it'd still be better if it was</div><div>    done at a more trusted level.</div><div><br></div><div>What I really want is an easy way to bind tmpfiles.d snippets to unit startup.</div><div>Something like:</div><div><br></div><div>StateDirectory=/var/kerberos 0755 0 0</div><div><br></div><div>(Why not full tmpfiles.d syntax?  Well I can't think of a good reason to make</div><div> a *file* on startup.  There are packages that ship plain files in /var but</div><div> I'd say they're broken.)</div><div><br></div><div>With this, it's easy to do without patching the service.  It retains the</div><div>association (if a bit indirect) between the service and its state directory,</div><div>because you can query ownership of the .service file.  And systemd ensures</div><div>SELinux labeling happens correctly.</div><div><br></div><div>Thoughts?  Should be a pretty easy patch.</div><div><br></div>