I have an application that creates a lot of unix sockets to interact with all the processes it spawns at run time. I thought /run/appname would be a good place for them to live, since from what I've understood, /run should be used for information from apps that's only valid during run-time of the app.
But the I discovered
$ mkdir /run/appname
mkdir: cannot create directory '/run/appname': Permission denied
So why can a normal user not create files in /run? What is it used for? Should I just keep to /tmp?
You should put them in a subdirectory of $XDG_RUNTIME_DIR
if the variable is set. See the XDG Basedir Standard: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
If it's not set, there are a few places to consider. Many distributions have systemd (or something) create /run/user/<user-id>
when a user logs in, so it might be the best place to start looking if $XDG_RUNTIME_DIR
is not set. If that fails I fall back to putting things in /tmp
. You might try to create a directory within /tmp named randomly or after the username/id with your application name, chown
it to the user of the app, set any appropriate permissions, then put sockets in there.