-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A bug with permissions running unit from unprivileged user #357
Comments
Hi @Izorkin I ran your example here (manually, without the systemd unit). I got:
Could you check running it manually?
|
Also, show the output of:
It would be good if you can show the output of this in the script as well:
|
Result umask shell Error start unitd with |
This is the expected behavior, right? Or maybe I misunderstand your question. What do you mean by |
Incorrectly translated into english. |
Ok, Got it. The problem is that capabilities are copied to child processes but the inheritable set (that can be cleared) is only used for I'll have a look if it needs to set any additional capability to file to make it work as root. If there's no way around, then we will have to drop it explicitly in Unit. This behavior doesn't happen with Thanks for the report. |
Hi @Izorkin Can you test the patch below?
Thanks. |
Hi @tiago4orion this patch does not fix the error. |
Sorry, recheked - correct work! |
Ok. I don't like this solution because dropping all capabilities effectively prevents some use cases (applications that need to do administrative jobs, like mount/umount or privileged-network stuff, eg.: like the ones requiring CAP_SYS_ADMIN). This Linux behavior is really odd, from
It only clears the capabilities after setuid if the process was previously root or any other thread uid is still root. @VBart We can make the LXC has a keep and drop set in the configuration: https://linuxcontainers.org/lxc/manpages/man5/lxc.container.conf.5.html#lbAX Docker has an what do you think? |
@tiago4orion Having two options to specify what to add and what to drop looks too complex. Also, it's hard to predict what the final capabilities list the process will eventually have. Why don't just specify the exact capabilities list and let Unit do the best to provide them? We need just one option/object similar to "namespaces". |
@tiago4orion running unit on root and rechecking capability
App process:
How to reset |
Hi @Izorkin Some questions: Is your app process using the If you are using Unit without any changes, then when running unitd as root it will drop all capabilities of the app if the app's user is different than root and app is not using credential namespaces. It would be useful if you show how you are running unit and say if the app config has anything special (like user = root). The patch I sent here before is not applied to Unit repo yet, because it makes some use cases impossible. I don't have an ETA for when it will be released, as it still needs some work and reviews. |
Hi @i4ki
Yes, checked with namespace.
Created PR in Nixos to remove patch and run Unit as root.
Latest systemd config
Next error.
Need unprivileged CLONE_NEWUSER ? |
Hi @Izorkin If running unitd as root, you should have no problem to use namespaces. If you do receive "permission denied" even if running as root, then maybe the problem is your About your other error related to "no space left on device", I recommend you to read the man page for the clone syscall and read the various cases where ENOSPC can return. It's most likely that you have some hardning in place that limits the number of nested namespaces in the system. |
Hi @i4ki anthraxx linux hardened + namespcase
anthraxx linux hardened + namespcase + isolation
non-root + patch + anthraxx linux hardened + namespcase
non-root + patch + anthraxx linux hardened + namespcase + isolation
Actual problem unit not started with mode "non-root + patch + anthraxx linux hardened + namespcase + isolation". Need activate |
If use unit without Unit configuration with isolation
without isolation
|
Hi @Izorkin The If you run unitd as root, the flag Be aware that this flag is only for the |
This must resolve issue? - anthraxx/linux-hardened#36 |
Hi @Izorkin, Yes, having a separate capability to enable CLONE_NEWUSER for specific processes would be much better. |
Steps to reproduce bug.
Systemd configuration:
Unit configuration:
Test script:
Result:
curl localhost:8373
ls -lah /tmp/test_file
If run from root:
cc @tiago4orion
The text was updated successfully, but these errors were encountered: