···82828383- DocBook option documentation is no longer supported, all module documentation now uses markdown.
84848585+- `services.fail2ban.jails` can now be configured with attribute sets defining settings and filters instead of lines. The stringed options `daemonConfig` and `extraSettings` have respectively been replaced by `daemonSettings` and `jails.DEFAULT.settings` which use attribute sets.
8686+8587- `services.nginx` gained a `defaultListen` option at server-level with support for PROXY protocol listeners, also `proxyProtocol` is now exposed in `services.nginx.virtualHosts.<name>.listen` option. It is now possible to run PROXY listeners and non-PROXY listeners at a server-level, see [#213510](https://github.com/NixOS/nixpkgs/pull/213510/) for more details.
86888789- `services.prometheus.exporters` has a new exporter to monitor electrical power consumption based on PowercapRAPL sensor called [Scaphandre](https://github.com/hubblo-org/scaphandre), see [#239803](https://github.com/NixOS/nixpkgs/pull/239803) for more details.
+133-92
nixos/modules/services/security/fail2ban.nix
···33with lib;
4455let
66-76 cfg = config.services.fail2ban;
8799- fail2banConf = pkgs.writeText "fail2ban.local" cfg.daemonConfig;
88+ settingsFormat = pkgs.formats.keyValue { };
1091111- jailConf = pkgs.writeText "jail.local" ''
1212- [INCLUDES]
1010+ configFormat = pkgs.formats.ini {
1111+ mkKeyValue = generators.mkKeyValueDefault { } " = ";
1212+ };
13131414- before = paths-nixos.conf
1414+ mkJailConfig = name: attrs:
1515+ optionalAttrs (name != "DEFAULT") { inherit (attrs) enabled; } //
1616+ optionalAttrs (attrs.filter != null) { filter = if (builtins.isString filter) then filter else name; } //
1717+ attrs.settings;
1818+1919+ mkFilter = name: attrs: nameValuePair "fail2ban/filter.d/${name}.conf" {
2020+ source = configFormat.generate "filter.d/${name}.conf" attrs.filter;
2121+ };
15221616- ${concatStringsSep "\n" (attrValues (flip mapAttrs cfg.jails (name: def:
1717- optionalString (def != "")
1818- ''
1919- [${name}]
2020- ${def}
2121- '')))}
2222- '';
2323+ fail2banConf = configFormat.generate "fail2ban.local" cfg.daemonSettings;
2424+2525+ strJails = filterAttrs (_: builtins.isString) cfg.jails;
2626+ attrsJails = filterAttrs (_: builtins.isAttrs) cfg.jails;
2727+2828+ jailConf =
2929+ let
3030+ configFile = configFormat.generate "jail.local" (
3131+ { INCLUDES.before = "paths-nixos.conf"; } // (mapAttrs mkJailConfig attrsJails)
3232+ );
3333+ extraConfig = concatStringsSep "\n" (attrValues (mapAttrs
3434+ (name: def:
3535+ optionalString (def != "")
3636+ ''
3737+ [${name}]
3838+ ${def}
3939+ '')
4040+ strJails));
4141+4242+ in
4343+ pkgs.concatText "jail.local" [ configFile (pkgs.writeText "extra-jail.local" extraConfig) ];
23442445 pathsConf = pkgs.writeText "paths-nixos.conf" ''
2546 # NixOS
···32533354 [DEFAULT]
3455 '';
3535-3656in
37573858{
39596060+ imports = [
6161+ (mkRemovedOptionModule [ "services" "fail2ban" "daemonConfig" ] "The daemon is now configured through the attribute set `services.fail2ban.daemonSettings`.")
6262+ (mkRemovedOptionModule [ "services" "fail2ban" "extraSettings" ] "The extra default configuration can now be set using `services.fail2ban.jails.DEFAULT.settings`.")
6363+ ];
6464+4065 ###### interface
41664267 options = {
4343-4468 services.fail2ban = {
4569 enable = mkOption {
4670 default = false;
···6993 };
70947195 extraPackages = mkOption {
7272- default = [];
9696+ default = [ ];
7397 type = types.listOf types.package;
7498 example = lib.literalExpression "[ pkgs.ipset ]";
7599 description = lib.mdDoc ''
···180204 example = true;
181205 description = lib.mdDoc ''
182206 "bantime.overalljails" (if true) specifies the search of IP in the database will be executed
183183- cross over all jails, if false (default), only current jail of the ban IP will be searched
207207+ cross over all jails, if false (default), only current jail of the ban IP will be searched.
184208 '';
185209 };
186210···194218 '';
195219 };
196220197197- daemonConfig = mkOption {
198198- default = ''
199199- [Definition]
200200- logtarget = SYSLOG
201201- socket = /run/fail2ban/fail2ban.sock
202202- pidfile = /run/fail2ban/fail2ban.pid
203203- dbfile = /var/lib/fail2ban/fail2ban.sqlite3
204204- '';
205205- type = types.lines;
206206- description = lib.mdDoc ''
207207- The contents of Fail2ban's main configuration file. It's
208208- generally not necessary to change it.
209209- '';
210210- };
221221+ daemonSettings = mkOption {
222222+ inherit (configFormat) type;
211223212212- extraSettings = mkOption {
213213- type = with types; attrsOf (oneOf [ bool ints.positive str ]);
214214- default = {};
215215- description = lib.mdDoc ''
216216- Extra default configuration for all jails (i.e. `[DEFAULT]`). See
217217- <https://github.com/fail2ban/fail2ban/blob/master/config/jail.conf> for an overview.
218218- '';
219219- example = literalExpression ''
224224+ defaultText = literalExpression ''
220225 {
221221- findtime = "15m";
226226+ Definition = {
227227+ logtarget = "SYSLOG";
228228+ socket = "/run/fail2ban/fail2ban.sock";
229229+ pidfile = "/run/fail2ban/fail2ban.pid";
230230+ dbfile = "/var/lib/fail2ban/fail2ban.sqlite3";
231231+ };
222232 }
233233+ '';
234234+ description = lib.mdDoc ''
235235+ The contents of Fail2ban's main configuration file.
236236+ It's generally not necessary to change it.
223237 '';
224238 };
225239226240 jails = mkOption {
227241 default = { };
228242 example = literalExpression ''
229229- { apache-nohome-iptables = '''
230230- # Block an IP address if it accesses a non-existent
231231- # home directory more than 5 times in 10 minutes,
232232- # since that indicates that it's scanning.
233233- filter = apache-nohome
234234- action = iptables-multiport[name=HTTP, port="http,https"]
235235- logpath = /var/log/httpd/error_log*
236236- backend = auto
237237- findtime = 600
238238- bantime = 600
239239- maxretry = 5
240240- ''';
241241- dovecot = '''
242242- # block IPs which failed to log-in
243243- # aggressive mode add blocking for aborted connections
244244- enabled = true
245245- filter = dovecot[mode=aggressive]
246246- maxretry = 3
247247- ''';
248248- }
243243+ {
244244+ apache-nohome-iptables = {
245245+ settings = {
246246+ # Block an IP address if it accesses a non-existent
247247+ # home directory more than 5 times in 10 minutes,
248248+ # since that indicates that it's scanning.
249249+ filter = "apache-nohome";
250250+ action = '''iptables-multiport[name=HTTP, port="http,https"]''';
251251+ logpath = "/var/log/httpd/error_log*";
252252+ backend = "auto";
253253+ findtime = 600;
254254+ bantime = 600;
255255+ maxretry = 5;
256256+ };
257257+ };
258258+ dovecot = {
259259+ settings = {
260260+ # block IPs which failed to log-in
261261+ # aggressive mode add blocking for aborted connections
262262+ filter = "dovecot[mode=aggressive]";
263263+ maxretry = 3;
264264+ };
265265+ };
266266+ };
249267 '';
250250- type = types.attrsOf types.lines;
268268+ type = with types; attrsOf (either lines (submodule ({ name, ... }: {
269269+ options = {
270270+ enabled = mkEnableOption "this jail." // {
271271+ default = true;
272272+ readOnly = name == "DEFAULT";
273273+ };
274274+275275+ filter = mkOption {
276276+ type = nullOr (either str configFormat.type);
277277+278278+ default = null;
279279+ description = lib.mdDoc "Content of the filter used for this jail.";
280280+ };
281281+282282+ settings = mkOption {
283283+ inherit (settingsFormat) type;
284284+285285+ default = { };
286286+ description = lib.mdDoc "Additional settings for this jail.";
287287+ };
288288+ };
289289+ })));
251290 description = lib.mdDoc ''
252291 The configuration of each Fail2ban “jail”. A jail
253292 consists of an action (such as blocking a port using
···278317 config = mkIf cfg.enable {
279318 assertions = [
280319 {
281281- assertion = (cfg.bantime-increment.formula == null || cfg.bantime-increment.multipliers == null);
320320+ assertion = cfg.bantime-increment.formula == null || cfg.bantime-increment.multipliers == null;
282321 message = ''
283322 Options `services.fail2ban.bantime-increment.formula` and `services.fail2ban.bantime-increment.multipliers` cannot be both specified.
284323 '';
···300339 "fail2ban/paths-nixos.conf".source = pathsConf;
301340 "fail2ban/action.d".source = "${cfg.package}/etc/fail2ban/action.d/*.conf";
302341 "fail2ban/filter.d".source = "${cfg.package}/etc/fail2ban/filter.d/*.conf";
303303- };
342342+ } // (mapAttrs' mkFilter (filterAttrs (_: v: v.filter != null && !builtins.isString v.filter) attrsJails));
304343305344 systemd.packages = [ cfg.package ];
306345 systemd.services.fail2ban = {
···335374 };
336375 };
337376377377+ # Defaults for the daemon settings
378378+ services.fail2ban.daemonSettings.Definition = {
379379+ logtarget = mkDefault "SYSLOG";
380380+ socket = mkDefault "/run/fail2ban/fail2ban.sock";
381381+ pidfile = mkDefault "/run/fail2ban/fail2ban.pid";
382382+ dbfile = mkDefault "/var/lib/fail2ban/fail2ban.sqlite3";
383383+ };
384384+338385 # Add some reasonable default jails. The special "DEFAULT" jail
339386 # sets default values for all other jails.
340340- services.fail2ban.jails.DEFAULT = ''
341341- # Bantime increment options
342342- bantime.increment = ${boolToString cfg.bantime-increment.enable}
343343- ${optionalString (cfg.bantime-increment.rndtime != null) "bantime.rndtime = ${cfg.bantime-increment.rndtime}"}
344344- ${optionalString (cfg.bantime-increment.maxtime != null) "bantime.maxtime = ${cfg.bantime-increment.maxtime}"}
345345- ${optionalString (cfg.bantime-increment.factor != null) "bantime.factor = ${cfg.bantime-increment.factor}"}
346346- ${optionalString (cfg.bantime-increment.formula != null) "bantime.formula = ${cfg.bantime-increment.formula}"}
347347- ${optionalString (cfg.bantime-increment.multipliers != null) "bantime.multipliers = ${cfg.bantime-increment.multipliers}"}
348348- ${optionalString (cfg.bantime-increment.overalljails != null) "bantime.overalljails = ${boolToString cfg.bantime-increment.overalljails}"}
349349- # Miscellaneous options
350350- ignoreip = 127.0.0.1/8 ${optionalString config.networking.enableIPv6 "::1"} ${concatStringsSep " " cfg.ignoreIP}
351351- ${optionalString (cfg.bantime != null) ''
352352- bantime = ${cfg.bantime}
353353- ''}
354354- maxretry = ${toString cfg.maxretry}
355355- backend = systemd
356356- # Actions
357357- banaction = ${cfg.banaction}
358358- banaction_allports = ${cfg.banaction-allports}
359359- ${optionalString (cfg.extraSettings != {}) ''
360360- # Extra settings
361361- ${generators.toKeyValue {} cfg.extraSettings}
362362- ''}
363363- '';
364364- # Block SSH if there are too many failing connection attempts.
387387+ services.fail2ban.jails = mkMerge [
388388+ {
389389+ DEFAULT.settings = (optionalAttrs cfg.bantime-increment.enable
390390+ ({ "bantime.increment" = cfg.bantime-increment.enable; } // (mapAttrs'
391391+ (name: nameValuePair "bantime.${name}")
392392+ (filterAttrs (n: v: v != null && n != "enable") cfg.bantime-increment))
393393+ )
394394+ ) // {
395395+ # Miscellaneous options
396396+ inherit (cfg) banaction maxretry;
397397+ ignoreip = ''127.0.0.1/8 ${optionalString config.networking.enableIPv6 "::1"} ${concatStringsSep " " cfg.ignoreIP}'';
398398+ backend = "systemd";
399399+ # Actions
400400+ banaction_allports = cfg.banaction-allports;
401401+ };
402402+ }
403403+404404+ # Block SSH if there are too many failing connection attempts.
405405+ (mkIf config.services.openssh.enable {
406406+ sshd.settings.port = mkDefault (concatMapStringsSep "," builtins.toString config.services.openssh.ports);
407407+ })
408408+ ];
409409+365410 # Benefits from verbose sshd logging to observe failed login attempts,
366411 # so we set that here unless the user overrode it.
367367- services.openssh.settings.LogLevel = lib.mkDefault "VERBOSE";
368368- services.fail2ban.jails.sshd = mkDefault ''
369369- enabled = true
370370- port = ${concatMapStringsSep "," (p: toString p) config.services.openssh.ports}
371371- '';
412412+ services.openssh.settings.LogLevel = mkDefault "VERBOSE";
372413 };
373414}
···11-On glibc-2.36 this fails with
22-33- genauth.c:45:12: fatal error: bsd/stdlib.h: No such file or directory
44- 45 | # include <bsd/stdlib.h>
55- | ^~~~~~~~~~~~~~
66-77-This is because the file will be included if HAVE_ARC4RANDOM is true and `__linux__` is set.
88-However, this is wrong: arc4random is now defined in glibc-2.36 and thus stdlib.h must be included
99-even though HAVE_ARC4RANDOM is true.
1010-1111-diff --git a/xdm/genauth.c b/xdm/genauth.c
1212-index cd2ad61..74d0ae1 100644
1313---- a/xdm/genauth.c
1414-+++ b/xdm/genauth.c
1515-@@ -40,13 +40,7 @@ from The Open Group.
1616-1717- #include <errno.h>
1818-1919--#ifdef HAVE_ARC4RANDOM
2020--# ifdef __linux__
2121--# include <bsd/stdlib.h>
2222--# else
2323--# include <stdlib.h>
2424--# endif
2525--#endif
2626-+#include <stdlib.h>
2727-2828- #include <time.h>
2929- #define Time_t time_t
+3-3
pkgs/tools/admin/syft/default.nix
···2233buildGoModule rec {
44 pname = "syft";
55- version = "0.83.1";
55+ version = "0.84.0";
6677 src = fetchFromGitHub {
88 owner = "anchore";
99 repo = pname;
1010 rev = "v${version}";
1111- hash = "sha256-GZLkz2aadUiSD+v69vLq5BDgn0MSnHVkeGeAFLNDWgM=";
1111+ hash = "sha256-1/8M4z/ezyyZRG+amzErOGIv2kRZ/sfx7AAB7V7aPX8=";
1212 # populate values that require us to use git. By doing this in postFetch we
1313 # can delete .git afterwards and maintain better reproducibility of the src.
1414 leaveDotGit = true;
···2222 };
2323 # hash mismatch with darwin
2424 proxyVendor = true;
2525- vendorHash = "sha256-hv+0qLzGd31CTDGd3STszSUO2BOMRfppyewbJKzGDTg=";
2525+ vendorHash = "sha256-WDxHDf+F0QdM/kK2WrStjgzq6h4IPFdsZFbO5qpILp4=";
26262727 nativeBuildInputs = [ installShellFiles ];
2828