setcap-wrapper: Merging with upstream master and resolving conflicts
This commit is contained in:
@@ -129,11 +129,10 @@ in
|
||||
|
||||
certs = mkOption {
|
||||
default = { };
|
||||
type = types.loaOf types.optionSet;
|
||||
type = with types; loaOf (submodule certOpts);
|
||||
description = ''
|
||||
Attribute set of certificates to get signed and renewed.
|
||||
'';
|
||||
options = [ certOpts ];
|
||||
example = {
|
||||
"example.com" = {
|
||||
webroot = "/var/www/challenges/";
|
||||
@@ -166,7 +165,8 @@ in
|
||||
++ concatLists (mapAttrsToList (name: root: [ "-d" (if root == null then name else "${name}:${root}")]) data.extraDomains);
|
||||
acmeService = {
|
||||
description = "Renew ACME Certificate for ${cert}";
|
||||
after = [ "network.target" ];
|
||||
after = [ "network.target" "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
SuccessExitStatus = [ "0" "1" ];
|
||||
@@ -178,6 +178,7 @@ in
|
||||
path = [ pkgs.simp_le ];
|
||||
preStart = ''
|
||||
mkdir -p '${cfg.directory}'
|
||||
chown '${data.user}:${data.group}' '${cfg.directory}'
|
||||
if [ ! -d '${cpath}' ]; then
|
||||
mkdir '${cpath}'
|
||||
fi
|
||||
@@ -282,6 +283,7 @@ in
|
||||
timerConfig = {
|
||||
OnCalendar = cfg.renewInterval;
|
||||
Unit = "acme-${cert}.service";
|
||||
Persistent = "yes";
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
@@ -67,31 +67,30 @@ options for the <literal>security.acme</literal> module.</para>
|
||||
</section>
|
||||
|
||||
<section><title>Using ACME certificates in Nginx</title>
|
||||
<para>In practice ACME is mostly used for retrieval and renewal of
|
||||
certificates that will be used in a webserver like Nginx. A configuration for
|
||||
Nginx that uses the certificates from ACME for
|
||||
<literal>foo.example.com</literal> will look similar to:
|
||||
<para>NixOS supports fetching ACME certificates for you by setting
|
||||
<literal>enableACME = true;</literal> in a virtualHost config. We
|
||||
first create self-signed placeholder certificates in place of the
|
||||
real ACME certs. The placeholder certs are overwritten when the ACME
|
||||
certs arrive. For <literal>foo.example.com</literal> the config would
|
||||
look like.
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
services.nginx.httpConfig = ''
|
||||
server {
|
||||
server_name foo.example.com;
|
||||
listen 443 ssl;
|
||||
ssl_certificate ${config.security.acme.directory}/foo.example.com/fullchain.pem;
|
||||
ssl_certificate_key ${config.security.acme.directory}/foo.example.com/key.pem;
|
||||
root /var/www/foo.example.com/;
|
||||
}
|
||||
'';
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"foo.example.com" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/" = {
|
||||
root = "/var/www";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
<para>Now Nginx will try to use the certificates that will be retrieved by ACME.
|
||||
ACME needs Nginx (or any other webserver) to function and Nginx needs
|
||||
the certificates to actually start. For this reason the ACME module
|
||||
automatically generates self-signed certificates that will be used by Nginx to
|
||||
start. After that Nginx is used by ACME to retrieve the actual ACME
|
||||
certificates. <literal>security.acme.preliminarySelfsigned</literal> can be
|
||||
used to control whether to generate the self-signed certificates.
|
||||
</para>
|
||||
<para>At the moment you still have to restart Nginx after the ACME
|
||||
certs arrive.</para>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
@@ -18,22 +18,30 @@ in
|
||||
default = [];
|
||||
description = "List of files containing AppArmor profiles.";
|
||||
};
|
||||
packages = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
description = "List of packages to be added to apparmor's include path";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [ pkgs.apparmor-utils ];
|
||||
|
||||
systemd.services.apparmor = {
|
||||
systemd.services.apparmor = let
|
||||
paths = concatMapStrings (s: " -I ${s}/etc/apparmor.d")
|
||||
([ pkgs.apparmor-profiles ] ++ cfg.packages);
|
||||
in {
|
||||
wantedBy = [ "local-fs.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = "yes";
|
||||
ExecStart = concatMapStrings (p:
|
||||
''${pkgs.apparmor-parser}/bin/apparmor_parser -rKv -I ${pkgs.apparmor-profiles}/etc/apparmor.d "${p}" ; ''
|
||||
ExecStart = map (p:
|
||||
''${pkgs.apparmor-parser}/bin/apparmor_parser -rKv ${paths} "${p}"''
|
||||
) cfg.profiles;
|
||||
ExecStop = concatMapStrings (p:
|
||||
''${pkgs.apparmor-parser}/bin/apparmor_parser -Rv "${p}" ; ''
|
||||
ExecStop = map (p:
|
||||
''${pkgs.apparmor-parser}/bin/apparmor_parser -Rv "${p}"''
|
||||
) cfg.profiles;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -104,7 +104,11 @@ in {
|
||||
description = "Kernel Auditing";
|
||||
wantedBy = [ "basic.target" ];
|
||||
|
||||
unitConfig.ConditionVirtualization = "!container";
|
||||
unitConfig = {
|
||||
ConditionVirtualization = "!container";
|
||||
ConditionSecurity = [ "audit" ];
|
||||
};
|
||||
|
||||
|
||||
path = [ pkgs.audit ];
|
||||
|
||||
|
||||
@@ -4,10 +4,16 @@ with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.security.pki;
|
||||
|
||||
cacertPackage = pkgs.cacert.override {
|
||||
blacklist = cfg.caCertificateBlacklist;
|
||||
};
|
||||
|
||||
caCertificates = pkgs.runCommand "ca-certificates.crt"
|
||||
{ files =
|
||||
config.security.pki.certificateFiles ++
|
||||
[ (builtins.toFile "extra.crt" (concatStringsSep "\n" config.security.pki.certificates)) ];
|
||||
cfg.certificateFiles ++
|
||||
[ (builtins.toFile "extra.crt" (concatStringsSep "\n" cfg.certificates)) ];
|
||||
}
|
||||
''
|
||||
cat $files > $out
|
||||
@@ -52,11 +58,27 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
security.pki.caCertificateBlacklist = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
example = [
|
||||
"WoSign" "WoSign China"
|
||||
"CA WoSign ECC Root"
|
||||
"Certification Authority of WoSign G2"
|
||||
];
|
||||
description = ''
|
||||
A list of blacklisted CA certificate names that won't be imported from
|
||||
the Mozilla Trust Store into
|
||||
<filename>/etc/ssl/certs/ca-certificates.crt</filename>. Use the
|
||||
names from that file.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
security.pki.certificateFiles = [ "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" ];
|
||||
security.pki.certificateFiles = [ "${cacertPackage}/etc/ssl/certs/ca-bundle.crt" ];
|
||||
|
||||
# NixOS canonical location + Debian/Ubuntu/Arch/Gentoo compatibility.
|
||||
environment.etc."ssl/certs/ca-certificates.crt".source = caCertificates;
|
||||
|
||||
@@ -73,7 +73,7 @@ in
|
||||
};
|
||||
|
||||
failmode = mkOption {
|
||||
type = types.str;
|
||||
type = types.enum [ "safe" "enum" ];
|
||||
default = "safe";
|
||||
description = ''
|
||||
On service or configuration errors that prevent Duo
|
||||
@@ -115,7 +115,7 @@ in
|
||||
};
|
||||
|
||||
prompts = mkOption {
|
||||
type = types.int;
|
||||
type = types.enum [ 1 2 3 ];
|
||||
default = 3;
|
||||
description = ''
|
||||
If a user fails to authenticate with a second factor, Duo
|
||||
@@ -181,13 +181,7 @@ in
|
||||
|
||||
config = mkIf (cfg.ssh.enable || cfg.pam.enable) {
|
||||
assertions =
|
||||
[ { assertion = cfg.failmode == "safe" || cfg.failmode == "secure";
|
||||
message = "Invalid value for failmode (must be safe or secure).";
|
||||
}
|
||||
{ assertion = cfg.prompts == 1 || cfg.prompts == 2 || cfg.prompts == 3;
|
||||
message = "Invalid value for prompts (must be 1, 2, or 3).";
|
||||
}
|
||||
{ assertion = !cfg.pam.enable;
|
||||
[ { assertion = !cfg.pam.enable;
|
||||
message = "PAM support is currently not implemented.";
|
||||
}
|
||||
];
|
||||
|
||||
@@ -6,14 +6,6 @@ let
|
||||
cfg = config.security.grsecurity;
|
||||
grsecLockPath = "/proc/sys/kernel/grsecurity/grsec_lock";
|
||||
|
||||
# Ascertain whether ZFS is required for booting the system; grsecurity is
|
||||
# currently incompatible with ZFS, rendering the system unbootable.
|
||||
zfsNeededForBoot = filter
|
||||
(fs: (fs.neededForBoot
|
||||
|| elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ])
|
||||
&& fs.fsType == "zfs")
|
||||
config.system.build.fileSystems != [];
|
||||
|
||||
# Ascertain whether NixOS container support is required
|
||||
containerSupportRequired =
|
||||
config.boot.enableContainers && config.containers != {};
|
||||
@@ -27,7 +19,14 @@ in
|
||||
|
||||
options.security.grsecurity = {
|
||||
|
||||
enable = mkEnableOption "grsecurity/PaX";
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
example = true;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable grsecurity/PaX.
|
||||
'';
|
||||
};
|
||||
|
||||
lockTunables = mkOption {
|
||||
type = types.bool;
|
||||
@@ -58,19 +57,12 @@ in
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
# Allow the user to select a different package set, subject to the stated
|
||||
# required kernel config
|
||||
boot.kernelPackages = mkDefault pkgs.linuxPackages_grsec_nixos;
|
||||
boot.kernelPackages = mkForce pkgs.linuxPackages_grsec_nixos;
|
||||
|
||||
boot.kernelParams = optional cfg.disableEfiRuntimeServices "noefi";
|
||||
boot.kernelParams = [ "grsec_sysfs_restrict=0" ]
|
||||
++ optional cfg.disableEfiRuntimeServices "noefi";
|
||||
|
||||
system.requiredKernelConfig = with config.lib.kernelConfig;
|
||||
[ (isEnabled "GRKERNSEC")
|
||||
(isEnabled "PAX")
|
||||
(isYES "GRKERNSEC_SYSCTL")
|
||||
(isYES "GRKERNSEC_SYSCTL_DISTRO")
|
||||
(isNO "GRKERNSEC_NO_RBAC")
|
||||
];
|
||||
nixpkgs.config.grsecurity = true;
|
||||
|
||||
# Install PaX related utillities into the system profile.
|
||||
environment.systemPackages = with pkgs; [ gradm paxctl pax-utils ];
|
||||
@@ -118,26 +110,63 @@ in
|
||||
boot.kernel.sysctl = {
|
||||
# Read-only under grsecurity
|
||||
"kernel.kptr_restrict" = mkForce null;
|
||||
|
||||
# All grsec tunables default to off, those not enabled below are
|
||||
# *disabled*. We use mkDefault to allow expert users to override
|
||||
# our choices, but use mkForce where tunables would outright
|
||||
# conflict with other settings.
|
||||
|
||||
# Enable all chroot restrictions by default (overwritten as
|
||||
# necessary below)
|
||||
"kernel.grsecurity.chroot_caps" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_bad_rename" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_chmod" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_chroot" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_fchdir" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_mknod" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_mount" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_pivot" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_shmat" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_sysctl" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_deny_unix" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_enforce_chdir" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_findtask" = mkDefault 1;
|
||||
"kernel.grsecurity.chroot_restrict_nice" = mkDefault 1;
|
||||
|
||||
# Enable various grsec protections
|
||||
"kernel.grsecurity.consistent_setxid" = mkDefault 1;
|
||||
"kernel.grsecurity.deter_bruteforce" = mkDefault 1;
|
||||
"kernel.grsecurity.fifo_restrictions" = mkDefault 1;
|
||||
"kernel.grsecurity.harden_ipc" = mkDefault 1;
|
||||
"kernel.grsecurity.harden_ptrace" = mkDefault 1;
|
||||
"kernel.grsecurity.harden_tty" = mkDefault 1;
|
||||
"kernel.grsecurity.ip_blackhole" = mkDefault 1;
|
||||
"kernel.grsecurity.linking_restrictions" = mkDefault 1;
|
||||
"kernel.grsecurity.ptrace_readexec" = mkDefault 1;
|
||||
|
||||
# Enable auditing
|
||||
"kernel.grsecurity.audit_ptrace" = mkDefault 1;
|
||||
"kernel.grsecurity.forkfail_logging" = mkDefault 1;
|
||||
"kernel.grsecurity.rwxmap_logging" = mkDefault 1;
|
||||
"kernel.grsecurity.signal_logging" = mkDefault 1;
|
||||
"kernel.grsecurity.timechange_logging" = mkDefault 1;
|
||||
} // optionalAttrs config.nix.useSandbox {
|
||||
# chroot(2) restrictions that conflict with sandboxed Nix builds
|
||||
"kernel.grsecurity.chroot_caps" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_chroot" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_mount" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_pivot" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
|
||||
} // optionalAttrs containerSupportRequired {
|
||||
# chroot(2) restrictions that conflict with NixOS lightweight containers
|
||||
"kernel.grsecurity.chroot_caps" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_chmod" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_deny_mount" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_restrict_nice" = mkForce 0;
|
||||
"kernel.grsecurity.chroot_caps" = mkForce 0;
|
||||
# Disable privileged IO by default, unless X is enabled
|
||||
} // optionalAttrs (!config.services.xserver.enable) {
|
||||
"kernel.grsecurity.disable_priv_io" = mkDefault 1;
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{ assertion = !zfsNeededForBoot;
|
||||
message = "grsecurity is currently incompatible with ZFS";
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,6 +51,13 @@
|
||||
# nixos-rebuild boot
|
||||
# reboot
|
||||
</programlisting>
|
||||
<note><para>
|
||||
Enabling the grsecurity module overrides
|
||||
<option>boot.kernelPackages</option>, to reduce the risk of
|
||||
misconfiguration. <xref linkend="sec-grsec-custom-kernel" />
|
||||
describes how to use a custom kernel package set.
|
||||
</para></note>
|
||||
|
||||
For most users, further configuration should be unnecessary. All users
|
||||
are encouraged to look over <xref linkend="sec-grsec-security" /> before
|
||||
using the system, however. If you experience problems, please refer to
|
||||
@@ -144,9 +151,6 @@
|
||||
a TCP simultaneous OPEN on that port before the connection is actually
|
||||
established.</para></listitem>
|
||||
|
||||
<listitem><para><filename class="directory">/sys</filename> hardening:
|
||||
breaks systemd.</para></listitem>
|
||||
|
||||
<listitem><para>Trusted path execution: a desirable feature, but
|
||||
requires some more work to operate smoothly on NixOS.</para></listitem>
|
||||
</itemizedlist>
|
||||
@@ -201,33 +205,42 @@
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To use a custom kernel with upstream's recommended settings for server
|
||||
deployments:
|
||||
To build a custom kernel using upstream's recommended settings for server
|
||||
deployments, while still using the NixOS module:
|
||||
<programlisting>
|
||||
boot.kernelPackages =
|
||||
let
|
||||
kernel = pkgs.linux_grsec_nixos.override {
|
||||
extraConfig = ''
|
||||
GRKERNSEC y
|
||||
PAX y
|
||||
GRKERNSEC_CONFIG_AUTO y
|
||||
GRKERNSEC_CONFIG_SERVER y
|
||||
GRKERNSEC_CONFIG_SECURITY y
|
||||
'';
|
||||
nixpkgs.config.packageOverrides = super: {
|
||||
linux_grsec_nixos = super.linux_grsec_nixos.override {
|
||||
extraConfig = ''
|
||||
GRKERNSEC_CONFIG_AUTO y
|
||||
GRKERNSEC_CONFIG_SERVER y
|
||||
GRKERNSEC_CONFIG_SECURITY y
|
||||
'';
|
||||
};
|
||||
self = pkgs.linuxPackagesFor kernel self;
|
||||
in self;
|
||||
}
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The wikibook provides an exhaustive listing of
|
||||
<link xlink:href="https://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options">kernel configuration options</link>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The NixOS module makes several assumptions about the kernel and so may be
|
||||
incompatible with your customised kernel. Most of these assumptions are
|
||||
encoded as assertions — mismatches should ideally result in a build
|
||||
failure. Currently, the only way to work around incompatibilities is to
|
||||
eschew the NixOS module and do all configuration yourself.
|
||||
The NixOS module makes several assumptions about the kernel and so
|
||||
may be incompatible with your customised kernel. Currently, the only way
|
||||
to work around incompatibilities is to eschew the NixOS module.
|
||||
|
||||
If not using the NixOS module, a custom grsecurity package set can
|
||||
be specified inline instead, as in
|
||||
<programlisting>
|
||||
boot.kernelPackages =
|
||||
let
|
||||
kernel = pkgs.linux_grsec_nixos.override {
|
||||
extraConfig = /* as above */;
|
||||
};
|
||||
self = pkgs.linuxPackagesFor kernel self;
|
||||
in self;
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
@@ -275,6 +288,10 @@
|
||||
<option>security.grsecurity.disableEfiRuntimeServices</option> to override
|
||||
this behavior.</para></listitem>
|
||||
|
||||
<listitem><para>User initiated autoloading of modules (e.g., when
|
||||
using fuse or loop devices) is disallowed; either load requisite modules
|
||||
as root or add them to<option>boot.kernelModules</option>.</para></listitem>
|
||||
|
||||
<listitem><para>Virtualization: KVM is the preferred virtualization
|
||||
solution. Xen, Virtualbox, and VMWare are
|
||||
<emphasis>unsupported</emphasis> and most likely require a custom kernel.
|
||||
@@ -308,6 +325,19 @@
|
||||
</programlisting>
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
The gitlab service (<xref linkend="module-services-gitlab" />)
|
||||
requires a variant of the <literal>ruby</literal> interpreter
|
||||
built without `mprotect()` hardening, as in
|
||||
<programlisting>
|
||||
services.gitlab.packages.gitlab = pkgs.gitlab.override {
|
||||
ruby = pkgs.ruby.overrideAttrs (attrs: {
|
||||
postFixup = "paxmark m $out/bin/ruby";
|
||||
});
|
||||
};
|
||||
</programlisting>
|
||||
</para></listitem>
|
||||
|
||||
</itemizedlist>
|
||||
|
||||
</sect1>
|
||||
@@ -330,13 +360,19 @@
|
||||
|
||||
<listitem><para>
|
||||
<literal>pax_sanitize_slab={off|fast|full}</literal>: control kernel
|
||||
slab object sanitization
|
||||
slab object sanitization. Defaults to <literal>fast</literal>
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
<literal>pax_size_overflow_report_only</literal>: log size overflow
|
||||
violations but leave the violating task running
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
<literal>grsec_sysfs_restrict=[0|1]</literal>: toggle sysfs
|
||||
restrictions. The NixOS module sets this to <literal>0</literal>
|
||||
for systemd compatibility
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
|
||||
@@ -2,24 +2,26 @@
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
security.hideProcessInformation = mkEnableOption "" // { description = ''
|
||||
Restrict access to process information to the owning user. Enabling
|
||||
this option implies, among other things, that command-line arguments
|
||||
remain private. This option is recommended for most systems, unless
|
||||
there's a legitimate reason for allowing unprivileged users to inspect
|
||||
the process information of other users.
|
||||
meta = {
|
||||
maintainers = [ maintainers.joachifm ];
|
||||
doc = ./hidepid.xml;
|
||||
};
|
||||
|
||||
Members of the group "proc" are exempt from process information hiding.
|
||||
To allow a service to run without process information hiding, add "proc"
|
||||
to its supplementary groups via
|
||||
<option>systemd.services.<name?>.serviceConfig.SupplementaryGroups</option>.
|
||||
''; };
|
||||
options = {
|
||||
security.hideProcessInformation = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Restrict process information to the owning user.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.security.hideProcessInformation {
|
||||
users.groups.proc.gid = config.ids.gids.proc;
|
||||
users.groups.proc.members = [ "polkituser" ];
|
||||
|
||||
boot.specialFileSystems."/proc".options = [ "hidepid=2" "gid=${toString config.ids.gids.proc}" ];
|
||||
systemd.services.systemd-logind.serviceConfig.SupplementaryGroups = [ "proc" ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
version="5.0"
|
||||
xml:id="sec-hidepid">
|
||||
|
||||
<title>Hiding process information</title>
|
||||
|
||||
<para>
|
||||
Setting
|
||||
<programlisting>
|
||||
security.hideProcessInformation = true;
|
||||
</programlisting>
|
||||
ensures that access to process information is restricted to the
|
||||
owning user. This implies, among other things, that command-line
|
||||
arguments remain private. Unless your deployment relies on unprivileged
|
||||
users being able to inspect the process information of other users, this
|
||||
option should be safe to enable.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Members of the <literal>proc</literal> group are exempt from process
|
||||
information hiding.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
To allow a service <replaceable>foo</replaceable> to run without process information hiding, set
|
||||
<programlisting>
|
||||
systemd.services.<replaceable>foo</replaceable>.serviceConfig.SupplementaryGroups = [ "proc" ];
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
</chapter>
|
||||
@@ -105,6 +105,16 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
setEnvironment = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether the service should set the environment variables
|
||||
listed in <option>environment.sessionVariables</option>
|
||||
using <literal>pam_env.so</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
setLoginUid = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
@@ -223,6 +233,8 @@ let
|
||||
account sufficient pam_unix.so
|
||||
${optionalString use_ldap
|
||||
"account sufficient ${pam_ldap}/lib/security/pam_ldap.so"}
|
||||
${optionalString config.services.sssd.enable
|
||||
"account sufficient ${pkgs.sssd}/lib/security/pam_sss.so"}
|
||||
${optionalString config.krb5.enable
|
||||
"account sufficient ${pam_krb5}/lib/security/pam_krb5.so"}
|
||||
|
||||
@@ -263,6 +275,8 @@ let
|
||||
"auth sufficient ${pkgs.oathToolkit}/lib/security/pam_oath.so window=${toString oath.window} usersfile=${toString oath.usersFile} digits=${toString oath.digits}"}
|
||||
${optionalString use_ldap
|
||||
"auth sufficient ${pam_ldap}/lib/security/pam_ldap.so use_first_pass"}
|
||||
${optionalString config.services.sssd.enable
|
||||
"auth sufficient ${pkgs.sssd}/lib/security/pam_sss.so use_first_pass"}
|
||||
${optionalString config.krb5.enable ''
|
||||
auth [default=ignore success=1 service_err=reset] ${pam_krb5}/lib/security/pam_krb5.so use_first_pass
|
||||
auth [default=die success=done] ${pam_ccreds}/lib/security/pam_ccreds.so action=validate use_first_pass
|
||||
@@ -278,26 +292,32 @@ let
|
||||
"password optional ${pkgs.pam_mount}/lib/security/pam_mount.so"}
|
||||
${optionalString use_ldap
|
||||
"password sufficient ${pam_ldap}/lib/security/pam_ldap.so"}
|
||||
${optionalString config.services.sssd.enable
|
||||
"password sufficient ${pkgs.sssd}/lib/security/pam_sss.so use_authtok"}
|
||||
${optionalString config.krb5.enable
|
||||
"password sufficient ${pam_krb5}/lib/security/pam_krb5.so use_first_pass"}
|
||||
${optionalString config.services.samba.syncPasswordsByPam
|
||||
"password optional ${pkgs.samba}/lib/security/pam_smbpass.so nullok use_authtok try_first_pass"}
|
||||
|
||||
# Session management.
|
||||
session required pam_env.so envfile=${config.system.build.pamEnvironment}
|
||||
${optionalString cfg.setEnvironment ''
|
||||
session required pam_env.so envfile=${config.system.build.pamEnvironment}
|
||||
''}
|
||||
session required pam_unix.so
|
||||
${optionalString cfg.setLoginUid
|
||||
"session ${
|
||||
if config.boot.isContainer then "optional" else "required"
|
||||
} pam_loginuid.so"}
|
||||
${optionalString cfg.makeHomeDir
|
||||
"session required ${pkgs.pam}/lib/security/pam_mkhomedir.so silent skel=/etc/skel umask=0022"}
|
||||
"session required ${pkgs.pam}/lib/security/pam_mkhomedir.so silent skel=${config.security.pam.makeHomeDir.skelDirectory} umask=0022"}
|
||||
${optionalString cfg.updateWtmp
|
||||
"session required ${pkgs.pam}/lib/security/pam_lastlog.so silent"}
|
||||
${optionalString config.security.pam.enableEcryptfs
|
||||
"session optional ${pkgs.ecryptfs}/lib/security/pam_ecryptfs.so"}
|
||||
${optionalString use_ldap
|
||||
"session optional ${pam_ldap}/lib/security/pam_ldap.so"}
|
||||
${optionalString config.services.sssd.enable
|
||||
"session optional ${pkgs.sssd}/lib/security/pam_sss.so"}
|
||||
${optionalString config.krb5.enable
|
||||
"session optional ${pam_krb5}/lib/security/pam_krb5.so"}
|
||||
${optionalString cfg.otpwAuth
|
||||
@@ -374,8 +394,7 @@ in
|
||||
|
||||
security.pam.services = mkOption {
|
||||
default = [];
|
||||
type = types.loaOf types.optionSet;
|
||||
options = [ pamOpts ];
|
||||
type = with types; loaOf (submodule pamOpts);
|
||||
description =
|
||||
''
|
||||
This option defines the PAM services. A service typically
|
||||
@@ -386,6 +405,16 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
security.pam.makeHomeDir.skelDirectory = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/empty";
|
||||
example = "/etc/skel";
|
||||
description = ''
|
||||
Path to skeleton directory whose contents are copied to home
|
||||
directories newly created by <literal>pam_mkhomedir</literal>.
|
||||
'';
|
||||
};
|
||||
|
||||
security.pam.enableSSHAgentAuth = mkOption {
|
||||
default = false;
|
||||
description =
|
||||
@@ -436,6 +465,7 @@ in
|
||||
# Include the PAM modules in the system path mostly for the manpages.
|
||||
[ pkgs.pam ]
|
||||
++ optional config.users.ldap.enable pam_ldap
|
||||
++ optional config.services.sssd.enable pkgs.sssd
|
||||
++ optionals config.krb5.enable [pam_krb5 pam_ccreds]
|
||||
++ optionals config.security.pam.enableOTPW [ pkgs.otpw ]
|
||||
++ optionals config.security.pam.oath.enable [ pkgs.oathToolkit ]
|
||||
@@ -495,6 +525,13 @@ in
|
||||
vlock = {};
|
||||
xlock = {};
|
||||
xscreensaver = {};
|
||||
|
||||
runuser = { rootOK = true; unixAuth = false; setEnvironment = false; };
|
||||
|
||||
/* FIXME: should runuser -l start a systemd session? Currently
|
||||
it complains "Cannot create session: Already running in a
|
||||
session". */
|
||||
runuser-l = { rootOK = true; unixAuth = false; };
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -117,6 +117,7 @@ in
|
||||
|
||||
mkdir -p /run/setuid-wrapper-dirs
|
||||
wrapperDir=$(mktemp --directory --tmpdir=/run/setuid-wrapper-dirs setuid-wrappers.XXXXXXXXXX)
|
||||
chmod a+rx $wrapperDir
|
||||
|
||||
${concatMapStrings makeSetuidWrapper setuidPrograms}
|
||||
|
||||
@@ -131,7 +132,7 @@ in
|
||||
# Compatibility with old state, just remove the folder and symlink
|
||||
rm -f ${wrapperDir}/*
|
||||
# if it happens to be a tmpfs
|
||||
umount ${wrapperDir} || true
|
||||
${pkgs.utillinux}/bin/umount ${wrapperDir} || true
|
||||
rm -d ${wrapperDir}
|
||||
ln -d --symbolic $wrapperDir ${wrapperDir}
|
||||
else
|
||||
|
||||
@@ -18,7 +18,7 @@ with lib;
|
||||
config = mkIf config.security.rngd.enable {
|
||||
services.udev.extraRules = ''
|
||||
KERNEL=="random", TAG+="systemd"
|
||||
SUBSYSTEM=="cpu", ENV{MODALIAS}=="x86cpu:*feature:*009E*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
||||
SUBSYSTEM=="cpu", ENV{MODALIAS}=="cpu:type:x86,*feature:*009E*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
||||
KERNEL=="hw_random", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"
|
||||
${if config.services.tcsd.enable then "" else ''KERNEL=="tpm0", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rngd.service"''}
|
||||
'';
|
||||
|
||||
@@ -74,7 +74,7 @@ in
|
||||
Defaults env_keep+=SSH_AUTH_SOCK
|
||||
|
||||
# "root" is allowed to do anything.
|
||||
root ALL=(ALL) SETENV: ALL
|
||||
root ALL=(ALL:ALL) SETENV: ALL
|
||||
|
||||
# Users in the "wheel" group can do anything.
|
||||
%wheel ALL=(ALL:ALL) ${if cfg.wheelNeedsPassword then "" else "NOPASSWD: ALL, "}SETENV: ALL
|
||||
|
||||
Reference in New Issue
Block a user