2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-05-13 15:13:06 +02:00
|
|
|
|
2014-04-15 13:50:39 +02:00
|
|
|
with lib;
|
|
|
|
|
2012-07-17 01:47:41 +02:00
|
|
|
let
|
|
|
|
cfg = config.security.apparmor;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
security.apparmor = {
|
|
|
|
enable = mkOption {
|
2013-10-28 16:14:15 +01:00
|
|
|
type = types.bool;
|
2012-07-17 01:47:41 +02:00
|
|
|
default = false;
|
2014-04-15 13:50:39 +02:00
|
|
|
description = "Enable the AppArmor Mandatory Access Control system.";
|
2012-07-17 01:47:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
profiles = mkOption {
|
2013-10-28 16:14:15 +01:00
|
|
|
type = types.listOf types.path;
|
2012-07-17 01:47:41 +02:00
|
|
|
default = [];
|
2014-04-15 13:50:39 +02:00
|
|
|
description = "List of files containing AppArmor profiles.";
|
2012-07-17 01:47:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-04-15 13:50:39 +02:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
assertions =
|
|
|
|
[ { assertion = config.boot.kernelPackages.kernel.features ? apparmor
|
|
|
|
&& config.boot.kernelPackages.kernel.features.apparmor;
|
|
|
|
message = "Your selected kernel does not have AppArmor support";
|
|
|
|
}
|
|
|
|
];
|
2013-05-10 15:07:56 +02:00
|
|
|
|
2013-05-11 07:40:45 +02:00
|
|
|
environment.systemPackages = [ pkgs.apparmor ];
|
|
|
|
systemd.services.apparmor = {
|
|
|
|
wantedBy = [ "local-fs.target" ];
|
2014-04-15 13:50:39 +02:00
|
|
|
path = [ pkgs.apparmor ];
|
2013-05-11 07:40:45 +02:00
|
|
|
|
|
|
|
serviceConfig = {
|
2013-05-13 15:13:06 +02:00
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
2013-05-28 18:15:16 +02:00
|
|
|
ExecStart = concatMapStrings (profile:
|
|
|
|
''${pkgs.apparmor}/sbin/apparmor_parser -rKv -I ${pkgs.apparmor}/etc/apparmor.d/ "${profile}" ; ''
|
|
|
|
) cfg.profiles;
|
|
|
|
ExecStop = concatMapStrings (profile:
|
2013-05-28 19:49:52 +02:00
|
|
|
''${pkgs.apparmor}/sbin/apparmor_parser -Rv -I ${pkgs.apparmor}/etc/apparmor.d/ "${profile}" ; ''
|
2013-05-28 18:15:16 +02:00
|
|
|
) cfg.profiles;
|
2012-07-17 01:47:41 +02:00
|
|
|
};
|
2013-05-11 07:40:45 +02:00
|
|
|
};
|
2012-07-17 01:47:41 +02:00
|
|
|
};
|
|
|
|
}
|