#StackBounty: #systemd #sockets Generate a dir for unix sockets WITHOUT systemd

Bounty: 50

In normal Ubuntu I used to create a dir for Unix sockets as follows (say for project foo):

  1. Create a systemd script in: /usr/lib/tmpfiles.d/foo.conf
  2. Place the following code in the script:
    /run/foo 0770 <username> <groupname>
    

Then on the next reboot the dir /run/foo will be created with the required permissions. The reason I do this is because only root can write to /var/run which links to -> /run, and its common for many apps to drop priviledges and change user before creating the socket, and hence they fail to write to /var/run.

Now I am using WSL2, with Ubuntu 20.04, and systemd does not exist. One can jump through many hoops to get it to work but they are buggy.

How does one create a folder with desired permissions which gets cleared after a reboot before any of the installed apps (e.g. nginx/postgresql) attempt to create their sockets (and hence fail due to stale sockets from before the reboot)?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.