From f412df1f6bf9104e3444375946434fe3cd35de26 Mon Sep 17 00:00:00 2001 From: WilliButz Date: Fri, 6 Jul 2018 21:13:13 +0200 Subject: [PATCH] nixos/prometheus-postfix-exporter: set default group The postfix exporter needs to access postfix's `queue/public/` directory to read the `showq` socket inside. Instead of making the public directory world accessible, this sets the postfix exporter's group to `postdrop` by default, when the postfix service is enabled. --- .../modules/services/monitoring/prometheus/exporters.nix | 2 ++ .../services/monitoring/prometheus/exporters/postfix.nix | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index cc71451bf20..4d15fb12ff7 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -229,6 +229,8 @@ in })] ++ [(mkIf config.services.nginx.enable { systemd.services.prometheus-nginx-exporter.after = [ "nginx.service" ]; systemd.services.prometheus-nginx-exporter.requires = [ "nginx.service" ]; + })] ++ [(mkIf config.services.postfix.enable { + services.prometheus.exporters.postfix.group = mkDefault config.services.postfix.setgidGroup; })] ++ (mapAttrsToList (name: conf: mkExporterConf { inherit name; diff --git a/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix b/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix index 3b6ef1631f8..e818b6e37b3 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/postfix.nix @@ -8,6 +8,15 @@ in { port = 9154; extraOpts = { + group = mkOption { + type = types.str; + description = '' + Group under which the postfix exporter shall be run. + It should match the group that is allowed to access the + showq socket in the queue/public/ directory. + Defaults to services.postfix.setgidGroup when postfix is enabled. + ''; + }; telemetryPath = mkOption { type = types.str; default = "/metrics";