-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
nixos/httpd: modernize module standards #85043
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
Conversation
It might be useful for users to document, what people should use instead of |
@aanderse planned add sandboxing?
|
Found startup error:
|
Breaks At least a few of those |
@Izorkin can you provide details from your configuration file please? |
Change to
|
@Izorkin thank you for the config. I put together a configuration that uses a self signed certificate instead of |
Thanks for the work @aanderse! Did you test your PR on your servers? I don’t see anything wrong here, but didn’t test it yet. What comes from the top of my head:
I agree that any "sandboxing" option from systemd could have big consequences as far as httpd is concerned, since it needs access to directories which don’t belong to him or are at many places in the system. That would force to have a big systemd configuration to list them all (not infeasible though). |
I am used custom phpPackage
With default phpPakage error:
Not working php mysqliSupport and mysqlndSupport This code not worked:
Error:
|
@immae great feedback. To address your points:
|
Need add:
|
@aanderse Considering that, I would suggest to have an additional configuration parameter keepRoot and a slight addition in systemd configuration:
This way, it’s easy for someone who needs it (in the situation given above) to keep his setup in a working state after your change, and still allow people who don’t need privileged process at all to be safe in this side. Does that seem like a good thing to you? |
@immae I've now tried out a few different common I called this branch |
Ah, if upstream considers it legacy then my suggestion is not relevant actually :) |
@Izorkin in your example what branch are you running off of? When you say |
Used master branch |
2350ecd
to
fb82b77
Compare
@Izorkin I'm unable to reproduce this. Can you specify a minimal |
Originally I was planning on leaving this unmerged for some time to allow for testing, but upon further contemplation I am thinking to merge this in the next couple days. The major change is as simple as If anyone has any major objections please speak up or in a few days time I'll be merging. @Izorkin I'm still looking to reproduce your error (which is |
@aanderse in latest master branch this error not reproduced. |
Group = cfg.group; | ||
Type = "forking"; | ||
PIDFile = "${runtimeDir}/httpd.pid"; | ||
Restart = "always"; | ||
RestartSec = "5s"; | ||
RuntimeDirectory = "httpd httpd/runtime"; | ||
RuntimeDirectoryMode = "0750"; | ||
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With only
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
capabilities:
CapInh: 0000000000000400
CapPrm: 0000000000000400
CapEff: 0000000000000400
CapBnd: 0000003fffffffff
CapAmb: 0000000000000400
With
AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ];
CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
CapInh: 0000000000000400
CapPrm: 0000000000000400
CapEff: 0000000000000400
CapBnd: 0000000000000400
CapAmb: 0000000000000400
May add CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ];
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the service
runs as wwwrun
then they should be no need for CapabilityBoundingSet
. If the service runs a root
(using wwwrun
for children processes) it seems likely the sysadmin likely has needs we can't anticipate and using CapabilityBoundingSet
might be overstepping. I really want to make it easy for a sysadmin to keep the current (and distro standard) behavior for httpd
if they need to.
@flokli any thoughts on that?
@GrahamcOfBorg test upnp wordpress mediawiki |
I noticed that Apache now starts as the wwwrun user, which means that SSL private keys now need to be readable by wwwrun. Isn't this less secure than the previous situation, where they only had to be readable by root? |
That depends on a large number of factors*. If you have an important wildcard then you want to seriously consider the implications and weigh the risk. If you are using a certificate for a single domain, especially if it is provisioned by Let's Encrypt, then maybe you're much better off with the default module. * Are you running code as the Ultimately you need to balance the number of privilege escalation vulnerabilities that To provide an example for both sides consider:
I was sure to make it very easy to switch between running the parent process as I hope this sufficiently addresses your concerns. Regardless, I'm happy to further discuss the implications and any concerns you continue to have. |
Motivation for this change
Under what scenario might the new defaults in this PR not be right for you?
services.httpd.enablePHP
- you should read upstreamhttpd
documentation and carefully decide if you want to haveservices.httpd.mpm
set toevent
andservices.httpd.virtualHosts.<name?>.httpd2
set totrue
services.httpd.enablePerl
- again, carefully read upstreamhttpd
documentation and carefully decide if you want to haveservices.httpd.mpm
set toevent
andservices.httpd.virtualHosts.<name?>.httpd2
set totrue
services.httpd.virtualHosts.<name?>.enableUserDir
and your permissions aren't loose enough you might want thehttpd
master process to run asroot
services.httpd.enablePHP
orservices.httpd.enablePerl
you should take special care with your ssl certificates as the same user executing yourperl
andphp
scripts will have at least read access to your ssl certificatesTo put the above points into context... it is 2020 and you probably shouldn't be using
enablePHP
,enablePerl
,enableUserDir
, or settingservices.httpd.mpm
toprefork
unless you are supporting legacy code which can't or won't be updated.Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)cc @FPtje @immae @redvers