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
nixos/uwsgi: run with capabilities instead of root #106082
Conversation
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.
Not yet tested but changes look good.
Fixed conflict with PR #107403 and rebased. |
To exercise this change, I migrated the ihatemoney module to use it: it works but I had to move from Full diff diff --git a/nixos/modules/services/web-apps/ihatemoney/default.nix b/nixos/modules/services/web-apps/ihatemoney/default.nix
index 68769ac8c03..81647d352e7 100644
--- a/nixos/modules/services/web-apps/ihatemoney/default.nix
+++ b/nixos/modules/services/web-apps/ihatemoney/default.nix
@@ -44,7 +44,7 @@ let
in
{
options.services.ihatemoney = {
- enable = mkEnableOption "ihatemoney webapp. Note that this will set uwsgi to emperor mode running as root";
+ enable = mkEnableOption "ihatemoney webapp. Note that this will set uwsgi to emperor mode";
backend = mkOption {
type = types.enum [ "sqlite" "postgresql" ];
default = "sqlite";
@@ -116,16 +116,13 @@ in
services.uwsgi = {
enable = true;
plugins = [ "python3" ];
- # the vassal needs to be able to setuid
- user = "root";
- group = "root";
instance = {
type = "emperor";
vassals.ihatemoney = {
type = "normal";
strict = true;
- uid = user;
- gid = group;
+ immediate-uid = user;
+ immediate-gid = group;
# apparently flask uses threads: https://github.com/spiral-project/ihatemoney/commit/c7815e48781b6d3a457eaff1808d179402558f8c
enable-threads = true;
module = "wsgi:application"; Feel free to include this in the PR, otherwise I'll do a PR myself later) |
Thank you, that should be indeed mentioned in the release notes. I'll also include your patch. |
@symphorien patch included and manual updated. Thank you, again. |
@GrahamcOfBorg test uwsgi ihatemoney |
Motivation for this change
Being able to run uwsgi as emperor without root.
Things done
nixosTests.uwsgi
nixosTests.ihatemoney
uwsgi
,config.system.build.manual.manualHTML
)nix path-info -S
before and after)