git.iko.soy/typeable/nixpkgs
on master help sign in
Revert "apparmor: fix and improve the service"

This reverts commit fb6d63f3fdd95a5468d43a0693c8ca7c1894363f. I really hope this finally fixes #99236: evaluation on Hydra. This time I really did check basically the same commit on Hydra: https://hydra.nixos.org/eval/1618011 Right now I don't have energy to find what exactly is wrong in the commit, and it doesn't seem important in comparison to nixos-unstable channel being stuck on a commit over one week old.

commit420f89ceb267b461eed5d025b6c3c0e57703cc5c authorVladimír Čunát <v@cunat.cz> dateWed 7 Oct 2020, 11:15 (6 years ago) parent3b0886c
20 files changed+167−794
maintainers/maintainer-list.nix+1−1 nixos/doc/manual/release-notes/rl-2009.xml−18 nixos/modules/config/fonts/fontconfig.nix−34 nixos/modules/config/malloc.nix−7 nixos/modules/module-list.nix+1 nixos/modules/security/apparmor-suid.nix+49 nixos/modules/security/apparmor.nix+51−190 nixos/modules/security/apparmor/includes.nix−301 nixos/modules/security/apparmor/profiles.nix−11 nixos/modules/security/pam.nix−55 nixos/modules/security/wrappers/default.nix−8 nixos/modules/services/torrent/transmission.nix+53−10 nixos/modules/tasks/network-interfaces.nix−15 nixos/modules/virtualisation/lxc.nix+4−8 nixos/modules/virtualisation/lxd.nix+4−8 pkgs/os-specific/linux/apparmor/default.nix+2−52 pkgs/os-specific/linux/apparmor/fix-rc.apparmor.functions.sh−32 pkgs/os-specific/linux/iputils/default.nix−22 pkgs/tools/networking/inetutils/default.nix+1−21 pkgs/top-level/all-packages.nix+1−1
maintainers/maintainer-list.nix+1−1
@@ -4251,7 +4251,7 @@
42514251 name = "Julien Dehos";
42524252 };
42534253 julm = {
4254− email = "julm+nixpkgs@sourcephile.fr";
4254+ email = "julm+nix@sourcephile.fr";
42554255 github = "ju1m";
42564256 githubId = 21160136;
42574257 name = "Julien Moutinho";
nixos/doc/manual/release-notes/rl-2009.xml−18
@@ -1009,24 +1009,6 @@ services.transmission.settings.rpc-bind-address = "0.0.0.0";
10091009 to get the previous behavior of listening on all network interfaces.
10101010 </para>
10111011 </listitem>
1012− <listitem>
1013− <para>
1014− The <literal>security.apparmor</literal> module,
1015− for the <link xlink:href="https://gitlab.com/apparmor/apparmor/-/wikis/Documentation">AppArmor</link>
1016− Mandatory Access Control system,
1017− has been substantialy improved along with related tools,
1018− so that module maintainers can now more easily write AppArmor profiles for NixOS.
1019− The most notable change on the user-side is the new option <xref linkend="opt-security.apparmor.policies"/>,
1020− replacing the previous <literal>profiles</literal> option
1021− to provide a way to disable a profile
1022− and to select whether to confine in enforce mode (default)
1023− or in complain mode (see <literal>journalctl -b --grep apparmor</literal>).
1024− Before enabling this module, either directly
1025− or by importing <literal>&lt;nixpkgs/nixos/modules/profiles/hardened.nix&gt;</literal>,
1026− please be sure to read the documentation of <link linkend="opt-security.apparmor.enable">security.apparmor.enable</link>,
1027− and especially the part about <xref linkend="opt-security.apparmor.killUnconfinedConfinables"/>.
1028− </para>
1029− </listitem>
10301012 <listitem>
10311013 <para>
10321014 With this release <literal>systemd-networkd</literal> (when enabled through <xref linkend="opt-networking.useNetworkd"/>)
nixos/modules/config/fonts/fontconfig.nix−34
@@ -448,40 +448,6 @@ in
448448 (mkIf cfg.enable {
449449 environment.systemPackages = [ pkgs.fontconfig ];
450450 environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/";
451− security.apparmor.includes."abstractions/fonts" = ''
452− # fonts.conf
453− r ${pkg.out}/etc/fonts/fonts.conf,
454−
455− # fontconfig default config files
456− r ${pkg.out}/etc/fonts/conf.d/*.conf,
457−
458− # 00-nixos-cache.conf
459− r ${cacheConf},
460−
461− # 10-nixos-rendering.conf
462− r ${renderConf},
463−
464− # 50-user.conf
465− ${optionalString cfg.includeUserConf ''
466− r ${pkg.out}/etc/fonts/conf.d.bak/50-user.conf,
467− ''}
468−
469− # local.conf (indirect priority 51)
470− ${optionalString (cfg.localConf != "") ''
471− r ${localConf},
472− ''}
473−
474− # 52-nixos-default-fonts.conf
475− r ${defaultFontsConf},
476−
477− # 53-no-bitmaps.conf
478− r ${rejectBitmaps},
479−
480− ${optionalString (!cfg.allowType1) ''
481− # 53-nixos-reject-type1.conf
482− r ${rejectType1},
483− ''}
484− '';
485451 })
486452 (mkIf cfg.enable {
487453 fonts.fontconfig.confPackages = [ confPkg ];
nixos/modules/config/malloc.nix−7
@@ -87,12 +87,5 @@ in
8787 environment.etc."ld-nix.so.preload".text = ''
8888 ${providerLibPath}
8989 '';
90− security.apparmor.includes = {
91− "abstractions/base" = ''
92− r /etc/ld-nix.so.preload,
93− r ${config.environment.etc."ld-nix.so.preload".source},
94− mr ${providerLibPath},
95− '';
96− };
9790 };
9891}
nixos/modules/module-list.nix+1
@@ -186,6 +186,7 @@
186186 ./rename.nix
187187 ./security/acme.nix
188188 ./security/apparmor.nix
189+ ./security/apparmor-suid.nix
189190 ./security/audit.nix
190191 ./security/auditd.nix
191192 ./security/ca.nix
nixos/modules/security/apparmor-suid.nixnew file+49
@@ -0,0 +1,49 @@
1+{ config, lib, pkgs, ... }:
2+let
3+ cfg = config.security.apparmor;
4+in
5+with lib;
6+{
7+ imports = [
8+ (mkRenamedOptionModule [ "security" "virtualization" "flushL1DataCache" ] [ "security" "virtualisation" "flushL1DataCache" ])
9+ ];
10+
11+ options.security.apparmor.confineSUIDApplications = mkOption {
12+ type = types.bool;
13+ default = true;
14+ description = ''
15+ Install AppArmor profiles for commonly-used SUID application
16+ to mitigate potential privilege escalation attacks due to bugs
17+ in such applications.
18+
19+ Currently available profiles: ping
20+ '';
21+ };
22+
23+ config = mkIf (cfg.confineSUIDApplications) {
24+ security.apparmor.profiles = [ (pkgs.writeText "ping" ''
25+ #include <tunables/global>
26+ /run/wrappers/bin/ping {
27+ #include <abstractions/base>
28+ #include <abstractions/consoles>
29+ #include <abstractions/nameservice>
30+
31+ capability net_raw,
32+ capability setuid,
33+ network inet raw,
34+
35+ ${pkgs.stdenv.cc.libc.out}/lib/*.so mr,
36+ ${pkgs.libcap.lib}/lib/libcap.so* mr,
37+ ${pkgs.attr.out}/lib/libattr.so* mr,
38+
39+ ${pkgs.iputils}/bin/ping mixr,
40+
41+ #/etc/modules.conf r,
42+
43+ ## Site-specific additions and overrides. See local/README for details.
44+ ##include <local/bin.ping>
45+ }
46+ '') ];
47+ };
48+
49+}
nixos/modules/security/apparmor.nix+51−190
@@ -1,198 +1,59 @@
11{ config, lib, pkgs, ... }:
22
33let
4− inherit (builtins) attrNames head map match readFile;
5− inherit (lib) types;
6− inherit (config.environment) etc;
4+ inherit (lib) mkIf mkOption types concatMapStrings;
75 cfg = config.security.apparmor;
8− mkDisableOption = name: lib.mkEnableOption name // {
9− default = true;
10− example = false;
11− };
12− enabledPolicies = lib.filterAttrs (n: p: p.enable) cfg.policies;
136in
147
158{
16− imports = [
17− (lib.mkRenamedOptionModule [ "security" "virtualization" "flushL1DataCache" ] [ "security" "virtualisation" "flushL1DataCache" ])
18− (lib.mkRemovedOptionModule [ "security" "apparmor" "confineSUIDApplications" ] "Please use the new options: `security.apparmor.policies.<policy>.enable'.")
19− (lib.mkRemovedOptionModule [ "security" "apparmor" "profiles" ] "Please use the new option: `security.apparmor.policies'.")
20− apparmor/includes.nix
21− apparmor/profiles.nix
22− ];
23−
24− options = {
25− security.apparmor = {
26− enable = lib.mkEnableOption ''the AppArmor Mandatory Access Control system.
27−
28− If you're enabling this module on a running system,
29− note that a reboot will be required to activate AppArmor in the kernel.
30−
31− Also, beware that enabling this module will by default
32− try to kill unconfined but confinable running processes,
33− in order to obtain a confinement matching what is declared in the NixOS configuration.
34− This will happen when upgrading to a NixOS revision
35− introducing an AppArmor profile for the executable of a running process.
36− This is because enabling an AppArmor profile for an executable
37− can only confine new or already confined processes of that executable,
38− but leaves already running processes unconfined.
39− Set <link linkend="opt-security.apparmor.killUnconfinedConfinables">killUnconfinedConfinables</link>
40− to <literal>false</literal> if you prefer to leave those processes running'';
41− policies = lib.mkOption {
42− description = ''
43− AppArmor policies.
44− '';
45− type = types.attrsOf (types.submodule ({ name, config, ... }: {
46− options = {
47− enable = mkDisableOption "loading of the profile into the kernel";
48− enforce = mkDisableOption "enforcing of the policy or only complain in the logs";
49− profile = lib.mkOption {
50− description = "The policy of the profile.";
51− type = types.lines;
52− apply = pkgs.writeText name;
53− };
54− };
55− }));
56− default = {};
57− };
58− includes = lib.mkOption {
59− type = types.attrsOf types.lines;
60− default = {};
61− description = ''
62− List of paths to be added to AppArmor's searched paths
63− when resolving <literal>include</literal> directives.
64− '';
65− apply = lib.mapAttrs pkgs.writeText;
66− };
67− packages = lib.mkOption {
68− type = types.listOf types.package;
69− default = [];
70− description = "List of packages to be added to AppArmor's include path";
71− };
72− enableCache = lib.mkEnableOption ''caching of AppArmor policies
73− in <literal>/var/cache/apparmor/</literal>.
74−
75− Beware that AppArmor policies almost always contain Nix store paths,
76− and thus produce at each change of these paths
77− a new cached version accumulating in the cache'';
78− killUnconfinedConfinables = mkDisableOption ''killing of processes
79− which have an AppArmor profile enabled
80− (in <link linkend="opt-security.apparmor.policies">policies</link>)
81− but are not confined (because AppArmor can only confine new processes).
82− Beware that due to a current limitation of AppArmor,
83− only profiles with exact paths (and no name) can enable such kills'';
84− };
85− };
86−
87− config = lib.mkIf cfg.enable {
88− assertions = map (policy:
89− { assertion = match ".*/.*" policy == null;
90− message = "`security.apparmor.policies.\"${policy}\"' must not contain a slash.";
91− # Because, for instance, aa-remove-unknown uses profiles_names_list() in rc.apparmor.functions
92− # which does not recurse into sub-directories.
93− }
94− ) (attrNames cfg.policies);
95−
96− environment.systemPackages = [ pkgs.apparmor-utils ];
97− environment.etc."apparmor.d".source = pkgs.linkFarm "apparmor.d" (
98− # It's important to put only enabledPolicies here and not all cfg.policies
99− # because aa-remove-unknown reads profiles from all /etc/apparmor.d/*
100− lib.mapAttrsToList (name: p: {inherit name; path=p.profile;}) enabledPolicies ++
101− lib.mapAttrsToList (name: path: {inherit name path;}) cfg.includes
102− );
103− environment.etc."apparmor/parser.conf".text = ''
104− ${if cfg.enableCache then "write-cache" else "skip-cache"}
105− cache-loc /var/cache/apparmor
106− Include /etc/apparmor.d
107− '' +
108− lib.concatMapStrings (p: "Include ${p}/etc/apparmor.d\n") cfg.packages;
109− # For aa-logprof
110− environment.etc."apparmor/apparmor.conf".text = ''
111− '';
112− # For aa-logprof
113− environment.etc."apparmor/severity.db".source = pkgs.apparmor-utils + "/etc/apparmor/severity.db";
114− environment.etc."apparmor/logprof.conf".text = ''
115− [settings]
116− # /etc/apparmor.d/ is read-only on NixOS
117− profiledir = /var/cache/apparmor/logprof
118− inactive_profiledir = /etc/apparmor.d/disable
119− # Use: journalctl -b --since today --grep audit: | aa-logprof
120− logfiles = /dev/stdin
121−
122− parser = ${pkgs.apparmor-parser}/bin/apparmor_parser
123− ldd = ${pkgs.glibc.bin}/bin/ldd
124− logger = ${pkgs.utillinux}/bin/logger
125−
126− # customize how file ownership permissions are presented
127− # 0 - off
128− # 1 - default of what ever mode the log reported
129− # 2 - force the new permissions to be user
130− # 3 - force all perms on the rule to be user
131− default_owner_prompt = 1
132−
133− custom_includes = /etc/apparmor.d ${lib.concatMapStringsSep " " (p: "${p}/etc/apparmor.d") cfg.packages}
134−
135− [qualifiers]
136− ${pkgs.runtimeShell} = icnu
137− ${pkgs.bashInteractive}/bin/sh = icnu
138− ${pkgs.bashInteractive}/bin/bash = icnu
139− '' + head (match "^.*\\[qualifiers](.*)" # Drop the original [settings] section.
140− (readFile "${pkgs.apparmor-utils}/etc/apparmor/logprof.conf"));
141−
142− boot.kernelParams = [ "apparmor=1" "security=apparmor" ];
143−
144− systemd.services.apparmor = {
145− after = [
146− "local-fs.target"
147− "systemd-journald-audit.socket"
148− ];
149− before = [ "sysinit.target" ];
150− wantedBy = [ "multi-user.target" ];
151− unitConfig = {
152− Description="Load AppArmor policies";
153− DefaultDependencies = "no";
154− ConditionSecurity = "apparmor";
155− };
156− # Reloading instead of restarting enables to load new AppArmor profiles
157− # without necessarily restarting all services which have Requires=apparmor.service
158− reloadIfChanged = true;
159− restartTriggers = [
160− etc."apparmor/parser.conf".source
161− etc."apparmor.d".source
162− ];
163− serviceConfig = let
164− killUnconfinedConfinables = pkgs.writeShellScript "apparmor-kill" ''
165− set -eu
166− ${pkgs.apparmor-utils}/bin/aa-status --json |
167− ${pkgs.jq}/bin/jq --raw-output '.processes | .[] | .[] | select (.status == "unconfined") | .pid' |
168− xargs --verbose --no-run-if-empty --delimiter='\n' \
169− kill
170− '';
171− commonOpts = p: "--verbose --show-cache ${lib.optionalString (!p.enforce) "--complain "}${p.profile}";
172− in {
173− Type = "oneshot";
174− RemainAfterExit = "yes";
175− ExecStartPre = "${pkgs.apparmor-utils}/bin/aa-teardown";
176− ExecStart = lib.mapAttrsToList (n: p: "${pkgs.apparmor-parser}/bin/apparmor_parser --add ${commonOpts p}") enabledPolicies;
177− ExecStartPost = lib.optional cfg.killUnconfinedConfinables killUnconfinedConfinables;
178− ExecReload =
179− # Add or replace into the kernel profiles in enabledPolicies
180− # (because AppArmor can do that without stopping the processes already confined).
181− lib.mapAttrsToList (n: p: "${pkgs.apparmor-parser}/bin/apparmor_parser --replace ${commonOpts p}") enabledPolicies ++
182− # Remove from the kernel any profile whose name is not
183− # one of the names within the content of the profiles in enabledPolicies
184− # (indirectly read from /etc/apparmor.d/*, without recursing into sub-directory).
185− # Note that this does not remove profiles dynamically generated by libvirt.
186− [ "${pkgs.apparmor-utils}/bin/aa-remove-unknown" ] ++
187− # Optionaly kill the processes which are unconfined but now have a profile loaded
188− # (because AppArmor can only start to confine new processes).
189− lib.optional cfg.killUnconfinedConfinables killUnconfinedConfinables;
190− ExecStop = "${pkgs.apparmor-utils}/bin/aa-teardown";
191− CacheDirectory = [ "apparmor" "apparmor/logprof" ];
192− CacheDirectoryMode = "0700";
193− };
194− };
195− };
196−
197− meta.maintainers = with lib.maintainers; [ julm ];
9+ options = {
10+ security.apparmor = {
11+ enable = mkOption {
12+ type = types.bool;
13+ default = false;
14+ description = "Enable the AppArmor Mandatory Access Control system.";
15+ };
16+ profiles = mkOption {
17+ type = types.listOf types.path;
18+ default = [];
19+ description = "List of files containing AppArmor profiles.";
20+ };
21+ packages = mkOption {
22+ type = types.listOf types.package;
23+ default = [];
24+ description = "List of packages to be added to apparmor's include path";
25+ };
26+ };
27+ };
28+
29+ config = mkIf cfg.enable {
30+ environment.systemPackages = [ pkgs.apparmor-utils ];
31+
32+ boot.kernelParams = [ "apparmor=1" "security=apparmor" ];
33+
34+ systemd.services.apparmor = let
35+ paths = concatMapStrings (s: " -I ${s}/etc/apparmor.d")
36+ ([ pkgs.apparmor-profiles ] ++ cfg.packages);
37+ in {
38+ after = [ "local-fs.target" ];
39+ before = [ "sysinit.target" ];
40+ wantedBy = [ "multi-user.target" ];
41+ unitConfig = {
42+ DefaultDependencies = "no";
43+ };
44+ serviceConfig = {
45+ Type = "oneshot";
46+ RemainAfterExit = "yes";
47+ ExecStart = map (p:
48+ ''${pkgs.apparmor-parser}/bin/apparmor_parser -rKv ${paths} "${p}"''
49+ ) cfg.profiles;
50+ ExecStop = map (p:
51+ ''${pkgs.apparmor-parser}/bin/apparmor_parser -Rv "${p}"''
52+ ) cfg.profiles;
53+ ExecReload = map (p:
54+ ''${pkgs.apparmor-parser}/bin/apparmor_parser --reload ${paths} "${p}"''
55+ ) cfg.profiles;
56+ };
57+ };
58+ };
19859}
nixos/modules/security/apparmor/includes.nixdeleted−301
@@ -1,301 +0,0 @@
1−{ config, lib, pkgs, ... }:
2−let
3− inherit (builtins) attrNames hasAttr isAttrs;
4− inherit (lib) getLib;
5− inherit (config.environment) etc;
6− etcRule = arg:
7− let go = {path ? null, mode ? "r", trail ? ""}:
8− lib.optionalString (hasAttr path etc)
9− "${mode} ${config.environment.etc.${path}.source}${trail},";
10− in if isAttrs arg
11− then go arg
12− else go {path=arg;};
13−in
14−{
15−# FIXME: most of the etcRule calls below have been
16−# written systematically by converting from apparmor-profiles's profiles
17−# without testing nor deep understanding of their uses,
18−# and thus may need more rules or can have less rules;
19−# this remains to be determined case by case,
20−# some may even be completely useless.
21−config.security.apparmor.includes = {
22− # This one is included by <tunables/global>
23− # which is usualy included before any profile.
24− "abstractions/tunables/alias" = ''
25− alias /bin -> /run/current-system/sw/bin,
26− alias /lib/modules -> /run/current-system/kernel/lib/modules,
27− alias /sbin -> /run/current-system/sw/sbin,
28− alias /usr -> /run/current-system/sw,
29− '';
30− "abstractions/audio" = ''
31− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/audio"
32− ${etcRule "asound.conf"}
33− ${etcRule "esound/esd.conf"}
34− ${etcRule "libao.conf"}
35− ${etcRule {path="pulse"; trail="/";}}
36− ${etcRule {path="pulse"; trail="/**";}}
37− ${etcRule {path="sound"; trail="/";}}
38− ${etcRule {path="sound"; trail="/**";}}
39− ${etcRule {path="alsa/conf.d"; trail="/";}}
40− ${etcRule {path="alsa/conf.d"; trail="/*";}}
41− ${etcRule "openal/alsoft.conf"}
42− ${etcRule "wildmidi/wildmidi.conf"}
43− '';
44− "abstractions/authentication" = ''
45− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/authentication"
46− # Defined in security.pam
47− include <abstractions/pam>
48− ${etcRule "nologin"}
49− ${etcRule "securetty"}
50− ${etcRule {path="security"; trail="/*";}}
51− ${etcRule "shadow"}
52− ${etcRule "gshadow"}
53− ${etcRule "pwdb.conf"}
54− ${etcRule "default/passwd"}
55− ${etcRule "login.defs"}
56− '';
57− "abstractions/base" = ''
58− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/base"
59− r ${pkgs.stdenv.cc.libc}/share/locale/**,
60− r ${pkgs.stdenv.cc.libc}/share/locale.alias,
61− ${lib.optionalString (pkgs.glibcLocales != null) "r ${pkgs.glibcLocales}/lib/locale/locale-archive,"}
62− ${etcRule "localtime"}
63− r ${pkgs.tzdata}/share/zoneinfo/**,
64− r ${pkgs.stdenv.cc.libc}/share/i18n/**,
65− '';
66− "abstractions/bash" = ''
67− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/bash"
68− # system-wide bash configuration
69− ${etcRule "profile.dos"}
70− ${etcRule "profile"}
71− ${etcRule "profile.d"}
72− ${etcRule {path="profile.d"; trail="/*";}}
73− ${etcRule "bashrc"}
74− ${etcRule "bash.bashrc"}
75− ${etcRule "bash.bashrc.local"}
76− ${etcRule "bash_completion"}
77− ${etcRule "bash_completion.d"}
78− ${etcRule {path="bash_completion.d"; trail="/*";}}
79− # bash relies on system-wide readline configuration
80− ${etcRule "inputrc"}
81− # bash inspects filesystems at startup
82− # and /etc/mtab is linked to /proc/mounts
83− @{PROC}/mounts
84−
85− # run out of /etc/bash.bashrc
86− ${etcRule "DIR_COLORS"}
87− '';
88− "abstractions/cups-client" = ''
89− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/cpus-client"
90− ${etcRule "cups/cups-client.conf"}
91− '';
92− "abstractions/consoles" = ''
93− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/consoles"
94− '';
95− "abstractions/dbus-session-strict" = ''
96− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/dbus-session-strict"
97− ${etcRule "machine-id"}
98− '';
99− "abstractions/dconf" = ''
100− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/dconf"
101− ${etcRule {path="dconf"; trail="/**";}}
102− '';
103− "abstractions/dri-common" = ''
104− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/dri-common"
105− ${etcRule "drirc"}
106− '';
107− # The config.fonts.fontconfig NixOS module adds many files to /etc/fonts/
108− # by symlinking them but without exporting them outside of its NixOS module,
109− # those are therefore added there to this "abstractions/fonts".
110− "abstractions/fonts" = ''
111− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/fonts"
112− ${etcRule {path="fonts"; trail="/**";}}
113− '';
114− "abstractions/gnome" = ''
115− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/gnome"
116− ${etcRule {path="gnome"; trail="/gtkrc*";}}
117− ${etcRule {path="gtk"; trail="/*";}}
118− ${etcRule {path="gtk-2.0"; trail="/*";}}
119− ${etcRule {path="gtk-3.0"; trail="/*";}}
120− ${etcRule "orbitrc"}
121− include <abstractions/fonts>
122− ${etcRule {path="pango"; trail="/*";}}
123− ${etcRule {path="/etc/gnome-vfs-2.0"; trail="/modules/";}}
124− ${etcRule {path="/etc/gnome-vfs-2.0"; trail="/modules/*";}}
125− ${etcRule "papersize"}
126− ${etcRule {path="cups"; trail="/lpoptions";}}
127− ${etcRule {path="gnome"; trail="/defaults.list";}}
128− ${etcRule {path="xdg"; trail="/{,*-}mimeapps.list";}}
129− ${etcRule "xdg/mimeapps.list"}
130− '';
131− "abstractions/kde" = ''
132− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/kde"
133− ${etcRule {path="qt3"; trail="/kstylerc";}}
134− ${etcRule {path="qt3"; trail="/qt_plugins_3.3rc";}}
135− ${etcRule {path="qt3"; trail="/qtrc";}}
136− ${etcRule "kderc"}
137− ${etcRule {path="kde3"; trail="/*";}}
138− ${etcRule "kde4rc"}
139− ${etcRule {path="xdg"; trail="/kdeglobals";}}
140− ${etcRule {path="xdg"; trail="/Trolltech.conf";}}
141− '';
142− "abstractions/kerberosclient" = ''
143− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/kerberosclient"
144− ${etcRule {path="krb5.keytab"; mode="rk";}}
145− ${etcRule "krb5.conf"}
146− ${etcRule "krb5.conf.d"}
147− ${etcRule {path="krb5.conf.d"; trail="/*";}}
148−
149− # config files found via strings on libs
150− ${etcRule "krb.conf"}
151− ${etcRule "krb.realms"}
152− ${etcRule "srvtab"}
153− '';
154− "abstractions/ldapclient" = ''
155− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/ldapclient"
156− ${etcRule "ldap.conf"}
157− ${etcRule "ldap.secret"}
158− ${etcRule {path="openldap"; trail="/*";}}
159− ${etcRule {path="openldap"; trail="/cacerts/*";}}
160− ${etcRule {path="sasl2"; trail="/*";}}
161− '';
162− "abstractions/likewise" = ''
163− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/likewise"
164− '';
165− "abstractions/mdns" = ''
166− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/mdns"
167− ${etcRule "nss_mdns.conf"}
168− '';
169− "abstractions/nameservice" = ''
170− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/nameservice"
171−
172− # Many programs wish to perform nameservice-like operations, such as
173− # looking up users by name or id, groups by name or id, hosts by name
174− # or IP, etc. These operations may be performed through files, dns,
175− # NIS, NIS+, LDAP, hesiod, wins, etc. Allow them all here.
176− ${etcRule "group"}
177− ${etcRule "host.conf"}
178− ${etcRule "hosts"}
179− ${etcRule "nsswitch.conf"}
180− ${etcRule "gai.conf"}
181− ${etcRule "passwd"}
182− ${etcRule "protocols"}
183−
184− # libtirpc (used for NIS/YP login) needs this
185− ${etcRule "netconfig"}
186−
187− ${etcRule "resolv.conf"}
188−
189− ${etcRule {path="samba"; trail="/lmhosts";}}
190− ${etcRule "services"}
191−
192− ${etcRule "default/nss"}
193−
194− # libnl-3-200 via libnss-gw-name
195− ${etcRule {path="libnl"; trail="/classid";}}
196− ${etcRule {path="libnl-3"; trail="/classid";}}
197−
198− mr ${getLib pkgs.nss}/lib/libnss_*.so*,
199− mr ${getLib pkgs.nss}/lib64/libnss_*.so*,
200− '';
201− "abstractions/nis" = ''
202− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/nis"
203− '';
204− "abstractions/nvidia" = ''
205− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/nvidia"
206− ${etcRule "vdpau_wrapper.cfg"}
207− '';
208− "abstractions/opencl-common" = ''
209− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/opencl-common"
210− ${etcRule {path="OpenCL"; trail="/**";}}
211− '';
212− "abstractions/opencl-mesa" = ''
213− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/opencl-mesa"
214− ${etcRule "default/drirc"}
215− '';
216− "abstractions/openssl" = ''
217− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/openssl"
218− ${etcRule {path="ssl"; trail="/openssl.cnf";}}
219− '';
220− "abstractions/p11-kit" = ''
221− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/p11-kit"
222− ${etcRule {path="pkcs11"; trail="/";}}
223− ${etcRule {path="pkcs11"; trail="/pkcs11.conf";}}
224− ${etcRule {path="pkcs11"; trail="/modules/";}}
225− ${etcRule {path="pkcs11"; trail="/modules/*";}}
226− '';
227− "abstractions/perl" = ''
228− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/perl"
229− ${etcRule {path="perl"; trail="/**";}}
230− '';
231− "abstractions/php" = ''
232− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/php"
233− ${etcRule {path="php"; trail="/**/";}}
234− ${etcRule {path="php5"; trail="/**/";}}
235− ${etcRule {path="php7"; trail="/**/";}}
236− ${etcRule {path="php"; trail="/**.ini";}}
237− ${etcRule {path="php5"; trail="/**.ini";}}
238− ${etcRule {path="php7"; trail="/**.ini";}}
239− '';
240− "abstractions/postfix-common" = ''
241− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/postfix-common"
242− ${etcRule "mailname"}
243− ${etcRule {path="postfix"; trail="/*.cf";}}
244− ${etcRule "postfix/main.cf"}
245− ${etcRule "postfix/master.cf"}
246− '';
247− "abstractions/python" = ''
248− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/python"
249− '';
250− "abstractions/qt5" = ''
251− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/qt5"
252− ${etcRule {path="xdg"; trail="/QtProject/qtlogging.ini";}}
253− ${etcRule {path="xdg/QtProject"; trail="/qtlogging.ini";}}
254− ${etcRule "xdg/QtProject/qtlogging.ini"}
255− '';
256− "abstractions/samba" = ''
257− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/samba"
258− ${etcRule {path="samba"; trail="/*";}}
259− '';
260− "abstractions/ssl_certs" = ''
261− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/ssl_certs"
262− ${etcRule "ssl/certs/ca-certificates.crt"}
263− ${etcRule "ssl/certs/ca-bundle.crt"}
264− ${etcRule "pki/tls/certs/ca-bundle.crt"}
265−
266− ${etcRule {path="ssl/trust"; trail="/";}}
267− ${etcRule {path="ssl/trust"; trail="/*";}}
268− ${etcRule {path="ssl/trust/anchors"; trail="/";}}
269− ${etcRule {path="ssl/trust/anchors"; trail="/**";}}
270− ${etcRule {path="pki/trust"; trail="/";}}
271− ${etcRule {path="pki/trust"; trail="/*";}}
272− ${etcRule {path="pki/trust/anchors"; trail="/";}}
273− ${etcRule {path="pki/trust/anchors"; trail="/**";}}
274−
275− # security.acme NixOS module
276− r /var/lib/acme/*/cert.pem,
277− r /var/lib/acme/*/chain.pem,
278− r /var/lib/acme/*/fullchain.pem,
279− '';
280− "abstractions/ssl_keys" = ''
281− # security.acme NixOS module
282− r /var/lib/acme/*/full.pem,
283− r /var/lib/acme/*/key.pem,
284− '';
285− "abstractions/vulkan" = ''
286− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/vulkan"
287− ${etcRule {path="vulkan/icd.d"; trail="/";}}
288− ${etcRule {path="vulkan/icd.d"; trail="/*.json";}}
289− '';
290− "abstractions/winbind" = ''
291− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/winbind"
292− ${etcRule {path="samba"; trail="/smb.conf";}}
293− ${etcRule {path="samba"; trail="/dhcp.conf";}}
294− '';
295− "abstractions/X" = ''
296− include "${pkgs.apparmor-profiles}/etc/apparmor.d/abstractions/X"
297− ${etcRule {path="X11/cursors"; trail="/";}}
298− ${etcRule {path="X11/cursors"; trail="/**";}}
299− '';
300−};
301−}
nixos/modules/security/apparmor/profiles.nixdeleted−11
@@ -1,11 +0,0 @@
1−{ config, lib, pkgs, ... }:
2−let apparmor = config.security.apparmor; in
3−{
4−config.security.apparmor.packages = [ pkgs.apparmor-profiles ];
5−config.security.apparmor.policies."bin.ping".profile = lib.mkIf apparmor.policies."bin.ping".enable ''
6− include "${pkgs.iputils.apparmor}/bin.ping"
7− include "${pkgs.inetutils.apparmor}/bin.ping"
8− # Note that including those two profiles in the same profile
9− # would not work if the second one were to re-include <tunables/global>.
10−'';
11−}
nixos/modules/security/pam.nix−55
@@ -834,61 +834,6 @@ in
834834 runuser-l = { rootOK = true; unixAuth = false; };
835835 };
836836
837− security.apparmor.includes."abstractions/pam" = let
838− isEnabled = test: fold or false (map test (attrValues config.security.pam.services));
839− in ''
840− ${lib.concatMapStringsSep "\n"
841− (name: "r ${config.environment.etc."pam.d/${name}".source},")
842− (attrNames config.security.pam.services)}
843− mr ${getLib pkgs.pam}/lib/security/pam_filter/*,
844− mr ${getLib pkgs.pam}/lib/security/pam_*.so,
845− r ${getLib pkgs.pam}/lib/security/,
846− ${optionalString use_ldap
847− "mr ${pam_ldap}/lib/security/pam_ldap.so,"}
848− ${optionalString config.services.sssd.enable
849− "mr ${pkgs.sssd}/lib/security/pam_sss.so,"}
850− ${optionalString config.krb5.enable ''
851− mr ${pam_krb5}/lib/security/pam_krb5.so,
852− mr ${pam_ccreds}/lib/security/pam_ccreds.so,
853− ''}
854− ${optionalString (isEnabled (cfg: cfg.googleOsLoginAccountVerification)) ''
855− mr ${pkgs.google-compute-engine-oslogin}/lib/pam_oslogin_login.so,
856− mr ${pkgs.google-compute-engine-oslogin}/lib/pam_oslogin_admin.so,
857− ''}
858− ${optionalString (isEnabled (cfg: cfg.googleOsLoginAuthentication))
859− "mr ${pkgs.google-compute-engine-oslogin}/lib/pam_oslogin_login.so,"}
860− ${optionalString (config.security.pam.enableSSHAgentAuth && isEnabled (cfg: cfg.sshAgentAuth))
861− "mr ${pkgs.pam_ssh_agent_auth}/libexec/pam_ssh_agent_auth.so,"}
862− ${optionalString (isEnabled (cfg: cfg.fprintAuth))
863− "mr ${pkgs.fprintd}/lib/security/pam_fprintd.so,"}
864− ${optionalString (isEnabled (cfg: cfg.u2fAuth))
865− "mr ${pkgs.pam_u2f}/lib/security/pam_u2f.so,"}
866− ${optionalString (isEnabled (cfg: cfg.usbAuth))
867− "mr ${pkgs.pam_usb}/lib/security/pam_usb.so,"}
868− ${optionalString (isEnabled (cfg: cfg.oathAuth))
869− "mr ${pkgs.oathToolkit}/lib/security/pam_oath.so,"}
870− ${optionalString (isEnabled (cfg: cfg.yubicoAuth))
871− "mr ${pkgs.yubico-pam}/lib/security/pam_yubico.so,"}
872− ${optionalString (isEnabled (cfg: cfg.duoSecurity.enable))
873− "mr ${pkgs.duo-unix}/lib/security/pam_duo.so,"}
874− ${optionalString (isEnabled (cfg: cfg.otpwAuth))
875− "mr ${pkgs.otpw}/lib/security/pam_otpw.so,"}
876− ${optionalString config.security.pam.enableEcryptfs
877− "mr ${pkgs.ecryptfs}/lib/security/pam_ecryptfs.so,"}
878− ${optionalString (isEnabled (cfg: cfg.pamMount))
879− "mr ${pkgs.pam_mount}/lib/security/pam_mount.so,"}
880− ${optionalString (isEnabled (cfg: cfg.enableGnomeKeyring))
881− "mr ${pkgs.gnome3.gnome-keyring}/lib/security/pam_gnome_keyring.so,"}
882− ${optionalString (isEnabled (cfg: cfg.startSession))
883− "mr ${pkgs.systemd}/lib/security/pam_systemd.so,"}
884− ${optionalString (isEnabled (cfg: cfg.enableAppArmor) && config.security.apparmor.enable)
885− "mr ${pkgs.apparmor-pam}/lib/security/pam_apparmor.so,"}
886− ${optionalString (isEnabled (cfg: cfg.enableKwallet))
887− "mr ${pkgs.plasma5.kwallet-pam}/lib/security/pam_kwallet5.so,"}
888− ${optionalString config.virtualisation.lxc.lxcfs.enable
889− "mr ${pkgs.lxc}/lib/security/pam_cgfs.so"}
890− '';
891−
892837 };
893838
894839}
nixos/modules/security/wrappers/default.nix−8
@@ -179,14 +179,6 @@ in
179179 export PATH="${wrapperDir}:$PATH"
180180 '';
181181
182− security.apparmor.includes."nixos/security.wrappers" = ''
183− include "${pkgs.apparmorRulesFromClosure {} [
184− securityWrapper
185− pkgs.stdenv.cc.cc
186− pkgs.stdenv.cc.libc
187− ]}"
188− '';
189−
190182 ###### setcap activation script
191183 system.activationScripts.wrappers =
192184 lib.stringAfter [ "specialfs" "users" ]
nixos/modules/services/torrent/transmission.nix+53−10
@@ -5,7 +5,7 @@ with lib;
55let
66 cfg = config.services.transmission;
77 inherit (config.environment) etc;
8− apparmor = config.security.apparmor;
8+ apparmor = config.security.apparmor.enable;
99 rootDir = "/run/transmission";
1010 homeDir = "/var/lib/transmission";
1111 settingsDir = ".config/transmission-daemon";
@@ -184,8 +184,8 @@ in
184184
185185 systemd.services.transmission = {
186186 description = "Transmission BitTorrent Service";
187− after = [ "network.target" ] ++ optional apparmor.enable "apparmor.service";
188− requires = optional apparmor.enable "apparmor.service";
187+ after = [ "network.target" ] ++ optional apparmor "apparmor.service";
188+ requires = optional apparmor "apparmor.service";
189189 wantedBy = [ "multi-user.target" ];
190190 environment.CURL_CA_BUNDLE = etc."ssl/certs/ca-certificates.crt".source;
191191
@@ -357,21 +357,61 @@ in
357357 })
358358 ];
359359
360− security.apparmor.policies."bin.transmission-daemon".profile = ''
360+ security.apparmor.profiles = mkIf apparmor [
361+ (pkgs.writeText "apparmor-transmission-daemon" ''
361362 include <tunables/global>
363+
362364 ${pkgs.transmission}/bin/transmission-daemon {
363365 include <abstractions/base>
364366 include <abstractions/nameservice>
365− include <abstractions/ssl_certs>
366− include "${pkgs.apparmorRulesFromClosure {} [pkgs.transmission]}"
367− include <local/bin.transmission-daemon>
367+
368+ # NOTE: https://github.com/NixOS/nixpkgs/pull/93457
369+ # will remove the need for these by fixing <abstractions/base>
370+ r ${etc."hosts".source},
371+ r /etc/ld-nix.so.preload,
372+ ${lib.optionalString (builtins.hasAttr "ld-nix.so.preload" etc) ''
373+ r ${etc."ld-nix.so.preload".source},
374+ ${concatMapStrings (p: optionalString (p != "") ("mr ${p},\n"))
375+ (splitString "\n" config.environment.etc."ld-nix.so.preload".text)}
376+ ''}
377+ r ${etc."ssl/certs/ca-certificates.crt".source},
378+ r ${pkgs.tzdata}/share/zoneinfo/**,
379+ r ${pkgs.stdenv.cc.libc}/share/i18n/**,
380+ r ${pkgs.stdenv.cc.libc}/share/locale/**,
381+
382+ mr ${getLib pkgs.stdenv.cc.cc}/lib/*.so*,
383+ mr ${getLib pkgs.stdenv.cc.libc}/lib/*.so*,
384+ mr ${getLib pkgs.attr}/lib/libattr*.so*,
385+ mr ${getLib pkgs.c-ares}/lib/libcares*.so*,
386+ mr ${getLib pkgs.curl}/lib/libcurl*.so*,
387+ mr ${getLib pkgs.keyutils}/lib/libkeyutils*.so*,
388+ mr ${getLib pkgs.libcap}/lib/libcap*.so*,
389+ mr ${getLib pkgs.libevent}/lib/libevent*.so*,
390+ mr ${getLib pkgs.libgcrypt}/lib/libgcrypt*.so*,
391+ mr ${getLib pkgs.libgpgerror}/lib/libgpg-error*.so*,
392+ mr ${getLib pkgs.libkrb5}/lib/lib*.so*,
393+ mr ${getLib pkgs.libssh2}/lib/libssh2*.so*,
394+ mr ${getLib pkgs.lz4}/lib/liblz4*.so*,
395+ mr ${getLib pkgs.nghttp2}/lib/libnghttp2*.so*,
396+ mr ${getLib pkgs.openssl}/lib/libcrypto*.so*,
397+ mr ${getLib pkgs.openssl}/lib/libssl*.so*,
398+ mr ${getLib pkgs.systemd}/lib/libsystemd*.so*,
399+ mr ${getLib pkgs.utillinuxMinimal.out}/lib/libblkid.so*,
400+ mr ${getLib pkgs.utillinuxMinimal.out}/lib/libmount.so*,
401+ mr ${getLib pkgs.utillinuxMinimal.out}/lib/libuuid.so*,
402+ mr ${getLib pkgs.xz}/lib/liblzma*.so*,
403+ mr ${getLib pkgs.zlib}/lib/libz*.so*,
368404
369405 r @{PROC}/sys/kernel/random/uuid,
370406 r @{PROC}/sys/vm/overcommit_memory,
371− r @{PROC}/@{pid}/environ,
407+ # @{pid} is not a kernel variable yet but a regexp
408+ #r @{PROC}/@{pid}/environ,
372409 r @{PROC}/@{pid}/mounts,
373410 rwk /tmp/tr_session_id_*,
411+
412+ r ${pkgs.openssl.out}/etc/**,
374413 r ${config.systemd.services.transmission.environment.CURL_CA_BUNDLE},
414+ r ${pkgs.transmission}/share/transmission/**,
375415
376416 owner rw ${cfg.home}/${settingsDir}/**,
377417 rw ${cfg.settings.download-dir}/**,
@@ -399,9 +439,12 @@ in
399439 # https://gitlab.com/apparmor/apparmor/-/wikis/AppArmorStacking#seccomp-and-no_new_privs
400440 px ${cfg.settings.script-torrent-done-filename} -> &@{dirs},
401441 ''}
442+
443+ # FIXME: enable customizing using https://github.com/NixOS/nixpkgs/pull/93457
444+ # include <local/transmission-daemon>
402445 }
403− '';
404− security.apparmor.includes."local/bin.transmission-daemon" = "";
446+ '')
447+ ];
405448 };
406449
407450 meta.maintainers = with lib.maintainers; [ julm ];
nixos/modules/tasks/network-interfaces.nix−15
@@ -1090,21 +1090,6 @@ in
10901090 } else {
10911091 ping.source = "${pkgs.iputils.out}/bin/ping";
10921092 };
1093− security.apparmor.policies."bin.ping".profile = lib.mkIf config.security.apparmor.policies."bin.ping".enable (lib.mkAfter ''
1094− /run/wrappers/bin/ping {
1095− include <abstractions/base>
1096− include <nixos/security.wrappers>
1097− rpx /run/wrappers/wrappers.*/ping,
1098− }
1099− /run/wrappers/wrappers.*/ping {
1100− include <abstractions/base>
1101− include <nixos/security.wrappers>
1102− r /run/wrappers/wrappers.*/ping.real,
1103− mrpx ${config.security.wrappers.ping.source},
1104− capability net_raw,
1105− capability setpcap,
1106− }
1107− '');
11081093
11091094 # Set the host and domain names in the activation script. Don't
11101095 # clear it if it's not configured in the NixOS configuration,
nixos/modules/virtualisation/lxc.nix+4−8
@@ -74,13 +74,9 @@ in
7474 systemd.tmpfiles.rules = [ "d /var/lib/lxc/rootfs 0755 root root -" ];
7575
7676 security.apparmor.packages = [ pkgs.lxc ];
77− security.apparmor.policies = {
78− "bin.lxc-start".profile = ''
79− include ${pkgs.lxc}/etc/apparmor.d/usr.bin.lxc-start
80− '';
81− "lxc-containers".profile = ''
82− include ${pkgs.lxc}/etc/apparmor.d/lxc-containers
83− '';
84− };
77+ security.apparmor.profiles = [
78+ "${pkgs.lxc}/etc/apparmor.d/lxc-containers"
79+ "${pkgs.lxc}/etc/apparmor.d/usr.bin.lxc-start"
80+ ];
8581 };
8682}
nixos/modules/virtualisation/lxd.nix+4−8
@@ -93,15 +93,11 @@ in
9393
9494 security.apparmor = {
9595 enable = true;
96+ profiles = [
97+ "${cfg.lxcPackage}/etc/apparmor.d/usr.bin.lxc-start"
98+ "${cfg.lxcPackage}/etc/apparmor.d/lxc-containers"
99+ ];
96100 packages = [ cfg.lxcPackage ];
97− policies = {
98− "bin.lxc-start".profile = ''
99− include ${cfg.lxcPackage}/etc/apparmor.d/usr.bin.lxc-start
100− '';
101− "lxc-containers".profile = ''
102− include ${cfg.lxcPackage}/etc/apparmor.d/lxc-containers
103− '';
104− };
105101 };
106102
107103 systemd.services.lxd = {
pkgs/os-specific/linux/apparmor/default.nix+2−52
@@ -10,13 +10,6 @@
1010, pam
1111, libnotify
1212, buildPackages
13−, coreutils
14−, gnugrep
15−, gnused
16−, kmod
17−, writeShellScript
18−, closureInfo
19−, runCommand
2013}:
2114
2215let
@@ -45,12 +38,6 @@ let
4538 sha256 = "0xw028iqp69j9mxv0kbwraplgkj5i5djdlgf0anpkc5cdbsf96r9";
4639 };
4740
48− aa-teardown = writeShellScript "aa-teardown" ''
49− PATH="${lib.makeBinPath [coreutils gnused gnugrep]}:$PATH"
50− . ${apparmor-parser}/lib/apparmor/rc.apparmor.functions
51− remove_profiles
52− '';
53−
5441 prePatchCommon = ''
5542 patch -p1 < ${gnumake43Patch}
5643 chmod a+x ./common/list_capabilities.sh ./common/list_af_names.sh
@@ -162,15 +149,6 @@ let
162149 # aa-notify checks its name and does not work named ".aa-notify-wrapped"
163150 mv $out/bin/aa-notify $out/bin/aa-notify-wrapped
164151 makeWrapper ${perl}/bin/perl $out/bin/aa-notify --set PERL5LIB ${libapparmor}/${perl.libPrefix} --add-flags $out/bin/aa-notify-wrapped
165−
166− substituteInPlace $out/bin/aa-remove-unknown \
167− --replace "/usr/bin/aa-status" "$out/bin/aa-status" \
168− --replace "/sbin/modprobe" "${kmod}/bin/modprobe" \
169− --replace "/lib/apparmor/rc.apparmor.functions" "${apparmor-parser}/lib/apparmor/rc.apparmor.functions"
170− wrapProgram $out/bin/aa-remove-unknown \
171− --prefix PATH : ${lib.makeBinPath [gawk]}
172−
173− ln -s ${aa-teardown} $out/bin/aa-teardown
174152 '';
175153
176154 inherit doCheck;
@@ -219,9 +197,6 @@ let
219197 substituteInPlace ./parser/Makefile --replace "/usr/include/linux/capability.h" "${linuxHeaders}/include/linux/capability.h"
220198 ## techdoc.pdf still doesn't build ...
221199 substituteInPlace ./parser/Makefile --replace "manpages htmlmanpages pdf" "manpages htmlmanpages"
222− substituteInPlace parser/rc.apparmor.functions \
223− --replace "/sbin/apparmor_parser" "$out/bin/apparmor_parser"
224− sed -i parser/rc.apparmor.functions -e '2i . ${./fix-rc.apparmor.functions.sh}'
225200 '';
226201 inherit patches;
227202 postPatch = "cd ./parser";
@@ -283,32 +258,8 @@ let
283258 meta = apparmor-meta "kernel patches";
284259 };
285260
286− # Generate generic AppArmor rules in a file,
287− # from the closure of given rootPaths.
288− # To be included in an AppArmor profile like so:
289− # include "$(apparmorRulesFromClosure {} [pkgs.hello]}"
290− apparmorRulesFromClosure =
291− { # The store path of the derivation is given in $path
292− additionalRules ? []
293− # TODO: factorize here some other common paths
294− # that may emerge from use cases.
295− , baseRules ? [
296− "r $path"
297− "r $path/etc/**"
298− "r $path/share/**"
299− # Note that not all libraries are prefixed with "lib",
300− # eg. glibc-2.30/lib/ld-2.30.so
301− "mr $path/lib/**.so*"
302− # eg. glibc-2.30/lib/gconv/gconv-modules
303− "r $path/lib/**"
304− ]
305− }: rootPaths: runCommand "apparmor-closure-rules" {} ''
306− touch $out
307− while read -r path
308− do printf >>$out "%s,\n" ${lib.concatMapStringsSep " " (x: "\"${x}\"") (baseRules ++ additionalRules)}
309− done <${closureInfo {inherit rootPaths;}}/store-paths
310− '';
311261in
262+
312263{
313264 inherit
314265 libapparmor
@@ -317,6 +268,5 @@ in
317268 apparmor-parser
318269 apparmor-pam
319270 apparmor-profiles
320− apparmor-kernel-patches
321− apparmorRulesFromClosure;
271+ apparmor-kernel-patches;
322272}
pkgs/os-specific/linux/apparmor/fix-rc.apparmor.functions.shdeleted−32
@@ -1,32 +0,0 @@
1−aa_action() {
2− STRING=$1
3− shift
4− $*
5− rc=$?
6− if [ $rc -eq 0 ] ; then
7− aa_log_success_msg $"$STRING "
8− else
9− aa_log_failure_msg $"$STRING "
10− fi
11− return $rc
12−}
13−
14−aa_log_success_msg() {
15− [ -n "$1" ] && echo -n $1
16− echo ": done."
17−}
18−
19−aa_log_warning_msg() {
20− [ -n "$1" ] && echo -n $1
21− echo ": Warning."
22−}
23−
24−aa_log_failure_msg() {
25− [ -n "$1" ] && echo -n $1
26− echo ": Failed."
27−}
28−
29−aa_log_skipped_msg() {
30− [ -n "$1" ] && echo -n $1
31− echo ": Skipped."
32−}
pkgs/os-specific/linux/iputils/default.nix−22
@@ -1,7 +1,6 @@
11{ stdenv, fetchFromGitHub
22, meson, ninja, pkgconfig, gettext, libxslt, docbook_xsl_ns
33, libcap, systemd, libidn2
4−, apparmorRulesFromClosure
54}:
65
76with stdenv.lib;
@@ -23,8 +22,6 @@ in stdenv.mkDerivation rec {
2322 sha256 = "1jhbcz75a4ij1myyyi110ma1d8d5hpm3scz9pyw7js6qym50xvh4";
2423 };
2524
26− outputs = ["out" "apparmor"];
27−
2825 mesonFlags = [
2926 "-DBUILD_RARPD=true"
3027 "-DBUILD_TRACEROUTE6=true"
@@ -38,25 +35,6 @@ in stdenv.mkDerivation rec {
3835 nativeBuildInputs = [ meson ninja pkgconfig gettext libxslt.bin docbook_xsl_ns ];
3936 buildInputs = [ libcap systemd ]
4037 ++ optional (!stdenv.hostPlatform.isMusl) libidn2;
41− postInstall = ''
42− install -D /dev/stdin $apparmor/bin.ping <<EOF
43− include <tunables/global>
44− $out/bin/ping {
45− include <abstractions/base>
46− include <abstractions/consoles>
47− include <abstractions/nameservice>
48− include "${apparmorRulesFromClosure {}
49− ([libcap] ++ optional (!stdenv.hostPlatform.isMusl) libidn2)}"
50− include <local/bin.ping>
51− capability net_raw,
52− network inet raw,
53− network inet6 raw,
54− mr $out/bin/ping,
55− r $out/share/locale/**,
56− r @{PROC}/@{pid}/environ,
57− }
58− EOF
59− '';
6038
6139 meta = {
6240 description = "A set of small useful utilities for Linux networking";
pkgs/tools/networking/inetutils/default.nix+1−21
@@ -1,6 +1,4 @@
1−{ stdenv, lib, fetchurl, ncurses, perl, help2man
2−, apparmorRulesFromClosure
3−}:
1+{ stdenv, lib, fetchurl, ncurses, perl, help2man }:
42
53stdenv.mkDerivation rec {
64 name = "inetutils-1.9.4";
@@ -10,8 +8,6 @@ stdenv.mkDerivation rec {
108 sha256 = "05n65k4ixl85dc6rxc51b1b732gnmm8xnqi424dy9f1nz7ppb3xy";
119 };
1210
13− outputs = ["out" "apparmor"];
14−
1511 patches = [
1612 ./whois-Update-Canadian-TLD-server.patch
1713 ./service-name.patch
@@ -45,22 +41,6 @@ stdenv.mkDerivation rec {
4541
4642 installFlags = [ "SUIDMODE=" ];
4743
48− postInstall = ''
49− install -D /dev/stdin $apparmor/bin.ping <<EOF
50− $out/bin/ping {
51− include <abstractions/base>
52− include <abstractions/consoles>
53− include <abstractions/nameservice>
54− include "${apparmorRulesFromClosure {} [stdenv.cc.libc]}"
55− include <local/bin.ping>
56− capability net_raw,
57− network inet raw,
58− network inet6 raw,
59− mr $out/bin/ping,
60− }
61− EOF
62− '';
63−
6444 meta = with lib; {
6545 description = "Collection of common network programs";
6646
pkgs/top-level/all-packages.nix+1−1
@@ -17357,7 +17357,7 @@ in
1735717357
1735817358 inherit (callPackages ../os-specific/linux/apparmor { python = python3; })
1735917359 libapparmor apparmor-utils apparmor-bin-utils apparmor-parser apparmor-pam
17360− apparmor-profiles apparmor-kernel-patches apparmorRulesFromClosure;
17360+ apparmor-profiles apparmor-kernel-patches;
1736117361
1736217362 atop = callPackage ../os-specific/linux/atop { };
1736317363