Context
I’m trying out if it’s possible/worth it/good to use DynamicUser = true for the nixos/crowdsec module.
The problem: cscli not useable from host
If you add DynamicUser = true to the systemd-service of crowdsec its state directory becomes a “private directory”:
> ls -l /var/lib | grep crowdsec
---
lrwxrwxrwx - root 30 Dez 17:42 crowdsec -> private/crowdsec
Which gives an interesting output using file:
> file /var/lib/crowdsec
---
/var/lib/crowdsec: broken symbolic link to private/crowdsec
Now, if you try to use cscli you’re getting this:
> cscli hub update # just an example usage
---
Error: while setting up trace directory: mkdir /var/lib/crowdsec: file exists
I couldn’t find any mkdir /var/lib/crowdsec call in the crowdsec package so I assume that this attempt to create the directory comes from the binary itself.
Questions
- Should I still try out to find a way to use
DynamicUser = true? (due to this RFC) - Do you have any suggestions on how to fix this?
Workarounds
You could run systemctl-run -pDynamicUser=true -pUser=crowdsec -pGroup=crowdsec -pStateDirectory=crowdsec --pty bash to get a shell where you work within the crowdsec-systemd-service context. There you’re able to use the cscli as usual.
You could say that a new wiki article can be created for crowdsec and that this should be mentioned there but… I don’t know if this is that convenient…
