-
Notifications
You must be signed in to change notification settings - Fork 268
Expand file tree
/
Copy pathapparmor_profiles.xml
More file actions
2154 lines (2030 loc) · 72.3 KB
/
apparmor_profiles.xml
File metadata and controls
2154 lines (2030 loc) · 72.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<!DOCTYPE chapter [
<!ENTITY % entities SYSTEM "generic-entities.ent">
%entities;
]>
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="cha-apparmor-profiles">
<!-- fs 2011-11-09 - see bnc #722915
("set capabilities" was dropped upstream)
<sect1 id="sec-apparmor-profiles-set-capabilities">
<title>Setting Capabilities per Profile</title>
<para>
Normally &aa; only restricts existing native Linux controls and does not
grant additional privileges. Therefore a program, having been granted
write access to a file via its profile, would not be able to actually
write to this file as long as the mode bits are set to read-only.
</para>
<para>
The only exception to this strict rule is the <literal>set
capability</literal> rule. This provides the ability to give non-root
users administrative privileges, as defined in the
<systemitem>capabilities(7)</systemitem> man page. Contrary to setting a
program to setuid or using file system capabilities (that apply to single
programs only), the set capability rule allows the user to apply
capabilities to multiple programs running under a specific profile (by
using ix transitions). For security reasons, set capability rules will
not be inherited (when a program leaves the profile, it loses the
elevated privilege).
</para>
<warning>
<title>Use set capabilities Rules with Extreme Caution</title>
<para>
Using the set capabilities rules allows to give processes &rootuser;
privileges. Therefore these rules should be used with extreme caution
and only in exceptional cases.
</para>
</warning>
<para>
To set a capability in a profile the keyword <quote>set</quote> is
prefixed to a capability rule. Setting a capability also implicitly adds
a capability rule allowing that capability.
</para>
<screen>set capability cap_chown,</screen>
<note>
<para>
Currently the tools can not be used to add rlimit rules to profiles. The
only way to add rlimit controls to a profile is to manually edit the
profile with a text editor. The tools will still work with profiles
containing rlimit rules and will not remove them, so it is safe to use
the tools to update profiles containing them.
</para>
</note>
</sect1>
-->
<title>Profile Components and Syntax</title>
<info>
<meta name="description">Learn how to build and manage profiles using SUSE's intuitive tools for confining applications, controlling system calls, capabilities, and file access</meta>
<dm:docmanager xmlns:dm="urn:x-suse:ns:docmanager">
<dm:bugtracker>
</dm:bugtracker>
</dm:docmanager>
<revhistory xml:id="rh-cha-apparmor-profiles">
<revision>
<date>2026-04-09</date>
<revdescription>
<para/>
</revdescription>
</revision>
</revhistory>
</info>
<para>
Building &aa; profiles to confine an application is very
straightforward and intuitive. &aa; ships with several tools that
assist in profile creation. It does not require you to do any programming
or script handling. The only task that is required of the administrator is
to determine a policy of strictest access and execute permissions for each
application that needs to be hardened.
</para>
<para>
Updates or modifications to the application profiles are only required if
the software configuration or the desired range of activities changes.
&aa; offers intuitive tools to handle profile updates and
modifications.
</para>
<para>
You are ready to build &aa; profiles after you select the programs to
profile. To do so, it is important to understand the components and syntax
of profiles. &aa; profiles contain several building blocks that help
build simple and reusable profile code:
</para>
<variablelist>
<varlistentry>
<term>Include Files</term>
<listitem>
<para>
Include statements are used to pull in parts of other &aa; profiles
to simplify the structure of new profiles.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Abstractions</term>
<listitem>
<para>
Abstractions are include statements grouped by common application
tasks.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Program Chunks</term>
<listitem>
<para>
Program chunks are include statements that contain chunks of profiles
that are specific to program suites.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Capability Entries</term>
<listitem>
<para>
Capability entries are profile entries for any of the POSIX.1e
<link xlink:href="http://en.wikipedia.org/wiki/POSIX#POSIX.1"/> Linux
capabilities allowing a fine-grained control over what a confined
process is allowed to do through system calls that require privileges.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Network Access Control Entries</term>
<listitem>
<para>
Network Access Control Entries mediate network access based on the
address type and family.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Local Variable Definitions</term>
<listitem>
<para>
Local variables define shortcuts for paths.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>File Access Control Entries</term>
<listitem>
<para>
File Access Control Entries specify the set of files an application can
access.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>rlimit Entries</term>
<listitem>
<para>
rlimit entries set and control an application's resource limits.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
For help determining the programs to profile, refer to
<xref linkend="sec-apparmor-concept-determine"/>.
To start building &aa; profiles with &yast;, proceed to
<xref linkend="cha-apparmor-yast"/>. To build profiles using the &aa;
command line interface, proceed to
<xref linkend="cha-apparmor-commandline"/>.
</para>
<sect1 xml:id="sec-apparmor-profiles-parts">
<title>Breaking an &aa; Profile into Its Parts</title>
<para>
The easiest way of explaining what a profile consists of and how to
create one is to show the details of a sample profile, in this case for a
hypothetical application called <command>/usr/bin/foo</command>:
</para>
<screen>#include <tunables/global><co xml:id="co-apparmor-profiles-vardef"/>
# a comment naming the application to confine
/usr/bin/foo<co xml:id="co-apparmor-profiles-path"/> {<co xml:id="co-apparmor-profiles-brack"/>
#include <abstractions/base><co xml:id="co-apparmor-profiles-incl"/>
capability setgid<co xml:id="co-apparmor-profiles-capent"/>,
network inet tcp<co xml:id="co-apparmor-profiles-netd"/>,
link /etc/sysconfig/foo -> /etc/foo.conf,<co xml:id="co-apparmor-profiles-lp"/>
/bin/mount ux,
/dev/{,u}<co xml:id="co-apparmor-profiles-ext"/>random r,
/etc/ld.so.cache r,
/etc/foo/* r,
/lib/ld-*.so* mr,
/lib/lib*.so* mr,
/proc/[0-9]** r,
/usr/lib/** mr,
/tmp/ r,<co xml:id="co-apparmor-profiles-pathent"/>
/tmp/foo.pid wr,
/tmp/foo.* lrw,
/@{HOME}<co xml:id="co-apparmor-profiles-variable"/>/.foo_file rw,
/@{HOME}/.foo_lock kw,
owner<co xml:id="co-apparmor-profiles-owner"/> /shared/foo/** rw,
/usr/bin/foobar Cx,<co xml:id="co-apparmor-profiles-cx"/>
/bin/** Px -> bin_generic,<co xml:id="co-apparmor-profiles-named"/>
# a comment about foo's local (children) profile for /usr/bin/foobar.
profile /usr/bin/foobar<co xml:id="co-apparmor-profiles-local"/> {
/bin/bash rmix,
/bin/cat rmix,
/bin/more rmix,
/var/log/foobar* rwl,
/etc/foobar r,
}
# foo's hat, bar.
^bar<co xml:id="co-apparmor-profiles-hat"/> {
/lib/ld-*.so* mr,
/usr/bin/bar px,
/var/spool/* rwl,
}
}
</screen>
<calloutlist>
<callout arearefs="co-apparmor-profiles-vardef">
<para>
This loads a file containing variable definitions.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-path">
<para>
The normalized path to the program that is confined.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-brack">
<para>
The curly braces (<literal>{}</literal>) serve as a container for
include statements, subprofiles, path entries, capability entries, and
network entries.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-incl">
<para>
This directive pulls in components of &aa; profiles to simplify
profiles.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-capent">
<para>
Capability entry statements enable each of the 29 POSIX.1e draft
capabilities.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-netd">
<para>
A directive determining the kind of network access allowed to the
application. For details, refer to
<xref linkend="sec-apparmor-profiles-nac"/>.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-lp">
<para>
A link pair rule specifying the source and the target of a link. See
<xref linkend="sec-apparmor-profiles-perm-link-pair"/> for more
information.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-ext">
<para>
The curly braces (<literal>{}</literal>) here allow for each of the
listed possibilities, one of which is the empty string.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-pathent">
<para>
A path entry specifying what areas of the file system the program can
access. The first part of a path entry specifies the absolute path of a
file (including regular expression globbing) and the second part
indicates permissible access modes (for example <literal>r</literal>
for read, <literal>w</literal> for write, and <literal>x</literal> for
execute). A whitespace of any kind (spaces or tabs) can precede the
path name, but must separate the path name and the mode specifier.
Spaces between the access mode and the trailing comma are optional.
Find a comprehensive overview of the available access modes in
<xref linkend="sec-apparmor-profiles-perm"/>.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-variable">
<para>
This variable expands to a value that can be changed without changing
the entire profile.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-owner">
<para>
An owner conditional rule, granting read and write permission on files
owned by the user. Refer to
<xref linkend="sec-apparmor-profiles-perm-owner"/> for more
information.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-cx">
<para>
This entry defines a transition to the local profile
<literal>/usr/bin/foobar</literal>. Find a comprehensive overview of
the available execute modes in
<xref linkend="sec-apparmor-profiles-exec"/>.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-named">
<para>
A named profile transition to the profile bin_generic located in the
global scope. See <xref linkend="sec-apparmor-profiles-exec-named"/>
for details.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-local">
<para>
The local profile <literal>/usr/bin/foobar</literal> is defined in this
section.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-hat">
<para>
This section references a <quote>hat</quote> subprofile of the
application. For more details on &aa;'s ChangeHat feature, refer to
<xref linkend="cha-apparmor-hat"/>.
</para>
</callout>
</calloutlist>
<para>
When a profile is created for a program, the program can access only the
files, modes, and POSIX capabilities specified in the profile. These
restrictions are in addition to the native Linux access controls.
</para>
<formalpara>
<title>Example:</title>
<para>
To gain the capability <systemitem>CAP_CHOWN</systemitem>, the
program must have both access to <systemitem>CAP_CHOWN</systemitem>
under conventional Linux access controls (typically, be a
&rootuser;-owned process) and have the capability
<systemitem>chown</systemitem> in its profile. Similarly, to be able
to write to the file <filename>/foo/bar</filename> the program must
have both the correct user ID and mode bits set in the files
attributes and have <literal>/foo/bar w</literal> in its profile.
</para>
</formalpara>
<para>
Attempts to violate &aa; rules are recorded in
<filename>/var/log/audit/audit.log</filename> if the
<systemitem class="resource">audit</systemitem> package is installed, or
in <filename>/var/log/messages</filename>, or only in
<systemitem>journalctl</systemitem> if no traditional syslog is
installed. Often &aa; rules prevent an attack from working
because necessary files are not accessible and, in all cases, &aa;
confinement restricts the damage that the attacker can do to the set of
files permitted by &aa;.
</para>
</sect1>
<sect1 xml:id="sec-apparmor-profiles-types">
<title>Profile Types</title>
<para>
&aa; knows four different types of profiles: standard profiles,
unattached profiles, local profiles and hats. Standard and unattached
profiles are stand-alone profiles, each stored in a file under
<filename>/etc/apparmor.d/</filename>. Local profiles and hats are
children profiles embedded inside of a parent profile used to provide
tighter or alternate confinement for a subtask of an application.
</para>
<sect2 xml:id="sec-apparmor-profiles-types-attached">
<title>Standard Profiles</title>
<para>
The default &aa; profile is attached to a program by its name, so a
profile name must match the path to the application it is to confine.
</para>
<screen>/usr/bin/foo {
...
}
</screen>
<para>
This profile will be automatically used whenever an unconfined process
executes <filename>/usr/bin/foo</filename>.
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-types-unattached">
<title>Unattached Profiles</title>
<para>
Unattached profiles do not reside in the file system namespace and
therefore are not automatically attached to an application. The name of
an unattached profile is preceded by the keyword
<literal>profile</literal>. You can freely choose a profile name, except
for the following limitations: the name must not begin with a
<literal>:</literal> or <literal>.</literal> character. If it contains a
whitespace, it must be quoted. If the name begins with a
<literal>/</literal>, the profile is considered to be a standard
profile, so the following two profiles are identical:
</para>
<screen>profile /usr/bin/foo {
...
}
/usr/bin/foo {
...
}</screen>
<para>
Unattached profiles are never used automatically, nor can they be
transitioned to through a <literal>Px</literal> rule. They need to be
attached to a program by either using a named profile transition (see
<xref linkend="sec-apparmor-profiles-exec-named"/>) or with the
<literal>change_profile</literal> rule (see
<xref linkend="sec-apparmor-profiles-types-change"/>).
</para>
<para>
Unattached profiles are useful for specialized profiles for system
utilities that generally should not be confined by a system-wide profile
(for example, <literal>/bin/bash</literal>). They can also be used to
set up roles or to confine a user.
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-types-local">
<title>Local Profiles</title>
<para>
Local profiles provide a convenient way to provide specialized
confinement for utility programs launched by a confined application.
They are specified like standard profiles, except that they are embedded
in a parent profile and begin with the <literal>profile</literal>
keyword:
</para>
<screen>/parent/profile {
...
profile /local/profile {
...
}
}</screen>
<para>
To transition to a local profile, either use a <literal>cx</literal>
rule (see <xref linkend="sec-apparmor-profiles-exec-cx"/>) or a named
profile transition (see
<xref linkend="sec-apparmor-profiles-exec-named"/>).
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-types-hat">
<title>Hats</title>
<para>
&aa; "hats" are a local profiles with some additional restrictions
and an implicit rule allowing for <literal>change_hat</literal> to be
used to transition to them. Refer to <xref linkend="cha-apparmor-hat"/>
for a detailed description.
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-types-change">
<title>Change rules</title>
<para>
&aa; provides <literal>change_hat</literal> and
<literal>change_profile</literal> rules that control domain
transitioning. <literal>change_hat</literal> are specified by defining
hats in a profile, while <literal>change_profile</literal> rules refer
to another profile and start with the keyword
<literal>change_profile</literal>:
</para>
<screen>change_profile -> /usr/bin/foobar,</screen>
<para>
Both <literal>change_hat</literal> and <literal>change_profile</literal>
provide for an application directed profile transition, without having
to launch a separate application. <literal>change_profile</literal>
provides a generic one way transition between any of the loaded
profiles. <literal>change_hat</literal> provides for a returnable parent
child transition where an application can switch from the parent profile
to the hat profile and if it provides the correct secret key return to
the parent profile at a later time.
</para>
<para>
<literal>change_profile</literal> is best used in situations where an
application goes through a trusted setup phase and then can lower its
privilege level. Any resources mapped or opened during the start-up
phase may still be accessible after the profile change, but the new
profile will restrict the opening of new resources, and will even limit
some resources opened before the switch. Specifically, memory
resources will still be available while capability and file resources
(as long as they are not memory mapped) can be limited.
</para>
<para>
<literal>change_hat</literal> is best used in situations where an
application runs a virtual machine or an interpreter that does not
provide direct access to the applications resources (for example
Apache's <literal>mod_php</literal>). Since
<literal>change_hat</literal> stores the return secret key in the
application's memory the phase of reduced privilege should not have
direct access to memory. It is also important that file access is
properly separated, since the hat can restrict accesses to a file handle
but does not close it. If an application does buffering and provides
access to the open files with buffering, the accesses to these files
might not be seen by the kernel and hence not restricted by the new
profile.
</para>
<warning>
<title>Safety of Domain Transitions</title>
<para>
The <literal>change_hat</literal> and <literal>change_profile</literal>
domain transitions are less secure than a domain transition done
through an exec because they do not affect a process's memory mappings,
nor do they close resources that have already been opened.
</para>
</warning>
</sect2>
</sect1>
<sect1 xml:id="sec-apparmor-profiles-includes">
<title>Include Statements</title>
<para>
Include statements are directives that pull in components of other
&aa; profiles to simplify profiles. Include files retrieve access
permissions for programs. By using an include, you can give the program
access to directory paths or files that are also required by other
programs. Using includes can reduce the size of a profile.
</para>
<para>
Include statements normally begin with a hash (<literal>#</literal>)
sign. This is confusing because the same hash sign is used for comments
inside profile files. Because of this, <literal>#include</literal> is
treated as an include only if there is no preceding #
(<literal>##include</literal> is a comment) and there is no whitespace
between <literal>#</literal> and <literal>include</literal> (<literal>#
include</literal> is a comment).
</para>
<para>
You can also use <literal>include</literal> without the leading
<literal>#</literal>.
</para>
<screen>include "/etc/apparmor.d/abstractions/foo"</screen>
<para>
is the same as using
</para>
<screen>#include "/etc/apparmor.d/abstractions/foo"</screen>
<note>
<title>No Trailing ','</title>
<para>
Note that because includes follow the C pre-processor syntax, they do
not have a trailing ',' like most &aa; rules.
</para>
</note>
<para>
By slight changes in syntax, you can modify the behavior of
<literal>include</literal>. If you use <literal>""</literal> around the
including path, you instruct the parser to do an absolute or relative
path lookup.
</para>
<screen>include "/etc/apparmor.d/abstractions/foo" # absolute path
include "abstractions/foo" # relative path to the directory of current file</screen>
<para>
Note that when using relative path includes, when the file is included,
it is considered the new current file for its includes. For example,
suppose you are in the <filename>/etc/apparmor.d/bar</filename> file,
then
</para>
<screen>include "abstractions/foo"</screen>
<para>
includes the file <filename>/etc/apparmor.d/abstractions/foo</filename>.
If then there is
</para>
<screen>include "example"</screen>
<para>
inside the <filename>/etc/apparmor.d/abstractions/foo</filename> file, it
includes <filename>/etc/apparmor.d/abstractions/example</filename>.
</para>
<para>
The use of <literal><></literal> specifies to try the include
path (specified by <option>-I</option>, defaults to the
<filename>/etc/apparmor.d</filename> directory) in an ordered way. So
assuming the include path is
</para>
<screen>-I /etc/apparmor.d/ -I /usr/share/apparmor/</screen>
<para>
then the include statement
</para>
<screen>include <abstractions/foo></screen>
<para>
will try <filename>/etc/apparmor.d/abstractions/foo</filename>, and if
that file does not exist, the next try is
<filename>/usr/share/apparmor/abstractions/foo</filename>.
</para>
<tip>
<para>
The default include path can be overridden manually by passing
<option>-I</option> to the <command>apparmor_parser</command>, or by
setting the include paths in
<filename>/etc/apparmor/parser.conf</filename>:
</para>
<screen>Include /usr/share/apparmor/
Include /etc/apparmor.d/</screen>
<para>
Multiple entries are allowed, and they are taken in the same order as
when they are when using <option>-I</option> or
<option>--Include</option> from the <command>apparmor_parser</command>
command line.
</para>
</tip>
<para>
If an include ends with '/', this is considered a directory include, and
all files within the directory are included.
</para>
<para>
To assist you in profiling your applications, &aa; provides three
classes of includes: abstractions, program chunks and tunables.
</para>
<sect2 xml:id="sec-apparmor-profiles-includes-abstractions">
<title>Abstractions</title>
<para>
Abstractions are includes that are grouped by common application tasks.
These tasks include access to authentication mechanisms, access to name
service routines, common graphics requirements, and system accounting.
Files listed in these abstractions are specific to the named task.
Programs that require one of these files usually also require
other files listed in the abstraction file (depending on the local
configuration and the specific requirements of the program). Find
abstractions in <filename>/etc/apparmor.d/abstractions</filename>.
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-includes-chunks">
<title>Program Chunks</title>
<para>
The program-chunks directory
(<filename>/etc/apparmor.d/program-chunks</filename>) contains some
chunks of profiles that are specific to program suites and not generally
useful outside of the suite, thus are never suggested for use in
profiles by the profile wizards (<command>aa-logprof</command> and
<command>aa-genprof</command>). Currently, program chunks are only
available for the postfix program suite.
</para>
</sect2>
<sect2 xml:id="sec-apparmor-profiles-includes-tunables">
<title>Tunables</title>
<para>
The tunables directory (<filename>/etc/apparmor.d/tunables</filename>)
contains global variable definitions. When used in a profile, these
variables expand to a value that can be changed without changing the
entire profile. Add all the tunables definitions that should be
available to every profile to
<filename>/etc/apparmor.d/tunables/global</filename>.
</para>
</sect2>
</sect1>
<sect1 xml:id="sec-apparmor-profiles-capabilities">
<title>Capability Entries (POSIX.1e)</title>
<para>
Capability rules are simply the word <literal>capability</literal>
followed by the name of the POSIX.1e capability as defined in the
<systemitem>capabilities(7)</systemitem> man page. You can list multiple
capabilities in a single rule, or grant all implemented capabilities with
the bare keyword <literal>capability</literal>.
</para>
<screen>
capability dac_override sys_admin, # multiple capabilities
capability, # grant all capabilities
</screen>
</sect1>
<sect1 xml:id="sec-apparmor-profiles-nac">
<title>Network Access Control</title>
<para>
&aa; allows mediation of network access based on the address type and
family. The following illustrates the network access rule syntax:
</para>
<screen>network [[<domain><co xml:id="co-apparmor-profiles-nac-dom"/>][<type<co xml:id="co-apparmor-profiles-nac-type"/>>][<protocol<co xml:id="co-apparmor-profiles-nac-proto"/>>]]</screen>
<calloutlist>
<callout arearefs="co-apparmor-profiles-nac-dom">
<para>
Supported domains: <literal>inet</literal>, <literal>ax25</literal>,
<literal>ipx</literal>, <literal>appletalk</literal>,
<literal>netrom</literal>, <literal>bridge</literal>,
<literal>x25</literal>, <literal>inet6</literal>,
<literal>rose</literal>, <literal>netbeui</literal>,
<literal>security</literal>, <literal>key</literal>,
<literal>packet</literal>, <literal>ash</literal>,
<literal>econet</literal>, <literal>atmsvc</literal>,
<literal>sna</literal>, <literal>irda</literal>,
<literal>pppox</literal>, <literal>wanpipe</literal>,
<literal>bluetooth</literal>, <literal>unix</literal>,
<literal>atmpvc</literal>,<literal>netlink</literal>,
<literal>llc</literal>, <literal>can</literal>,
<literal>tipc</literal>, <literal>iucv</literal>,
<literal>rxrpc</literal>, <literal>isdn</literal>,
<literal>phonet</literal>, <literal>ieee802154</literal>,
<literal>caif</literal>, <literal>alg</literal>,
<literal>nfc</literal>, <literal>vsock</literal>
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-type">
<para>
Supported types: <literal>stream</literal>, <literal>dgram</literal>,
<literal>seqpacket</literal>, <literal>rdm</literal>,
<literal>raw</literal>, <literal>packet</literal>
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-proto">
<para>
Supported protocols: <literal>tcp</literal>, <literal>udp</literal>,
<literal>icmp</literal>
</para>
</callout>
</calloutlist>
<para>
The &aa; tools support only family and type specification. The &aa;
module emits only <literal>network <replaceable>DOMAIN</replaceable>
<replaceable>TYPE</replaceable></literal> in <quote>ACCESS DENIED</quote>
messages. And only these are output by the profile generation tools, both
&yast; and command line.
</para>
<para>
The following examples illustrate possible network-related rules to be
used in &aa; profiles. Note that the syntax of the last two are not
currently supported by the &aa; tools.
</para>
<screen>network<co xml:id="co-apparmor-profiles-nac-nw"/>,
network inet<co xml:id="co-apparmor-profiles-nac-inet"/>,
network inet6<co xml:id="co-apparmor-profiles-nac-inet6"/>,
network inet stream<co xml:id="co-apparmor-profiles-nac-istream"/>,
network inet tcp<co xml:id="co-apparmor-profiles-nac-itcp"/>,
network tcp<co xml:id="co-apparmor-profiles-nac-tcp"/>,
</screen>
<calloutlist>
<callout arearefs="co-apparmor-profiles-nac-nw">
<para>
Allow all networking. No restrictions applied with regard to domain,
type, or protocol.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-inet">
<para>
Allow general use of IPv4 networking.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-inet6">
<para>
Allow general use of IPv6 networking.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-istream">
<para>
Allow the use of IPv4 TCP networking.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-itcp">
<para>
Allow the use of IPv4 TCP networking, paraphrasing the rule above.
</para>
</callout>
<callout arearefs="co-apparmor-profiles-nac-tcp">
<para>
Allow the use of both IPv4 and IPv6 TCP networking.
</para>
</callout>
</calloutlist>
</sect1>
<sect1 role="General" xml:id="sec-apparmor-profiles-glob">
<title>Profile Names, Flags, Paths, and Globbing</title>
<para>
A profile is usually attached to a program by specifying a full path to
the program's executable. For example in the case of a standard profile
(see <xref linkend="sec-apparmor-profiles-types-attached"/>), the profile
is defined by
</para>
<screen>/usr/bin/foo { ... }</screen>
<para>
The following sections describe several useful techniques that can be
applied when naming a profile or putting a profile in the context of
other existing ones, or specifying file paths.
</para>
<para>
&aa; explicitly distinguishes directory path names from file path
names. Use a trailing <literal>/</literal> for any directory path that
needs to be explicitly distinguished:
</para>
<variablelist>
<varlistentry>
<term><filename>/some/random/example/* r</filename>
</term>
<listitem>
<para>
Allow read access to files in the
<filename>/some/random/example</filename> directory.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>/some/random/example/ r</filename>
</term>
<listitem>
<para>
Allow read access to the directory only.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>/some/**/ r</filename>
</term>
<listitem>
<para>
Give read access to any directories below <filename>/some</filename>
(but not /some/ itself).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>/some/random/example/** r</filename>
</term>
<listitem>
<para>
Give read access to files and directories under
<filename>/some/random/example</filename> (but not
/some/random/example/ itself).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>/some/random/example/**[^/] r</filename>
</term>
<listitem>
<para>
Give read access to files under
<filename>/some/random/example</filename>. Explicitly exclude
directories (<literal>[^/]</literal>).
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
Globbing (or regular expression matching) is when you modify the
directory path using wild cards to include a group of files or
subdirectories. File resources can be specified with a globbing syntax
similar to that used by popular shells, such as csh, Bash, and zsh.
</para>
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry>
<para>
<literal>*</literal>
</para>
</entry>
<entry>
<para>
Substitutes for any number of any characters, except
<literal>/</literal>.
</para>
<para>
Example: An arbitrary number of file path elements.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>**</literal>
</para>
</entry>
<entry>
<para>
Substitutes for any number of characters, including
<literal>/</literal>.
</para>
<para>
Example: An arbitrary number of path elements, including entire
directories.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>?</literal>
</para>
</entry>
<entry>
<para>
Substitutes for any single character, except <literal>/</literal>.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>[abc]</literal>
</para>
</entry>
<entry>
<para>
Substitutes for the single character <literal>a</literal>,
<literal>b</literal>, or <literal>c</literal>.
</para>
<para>
Example: a rule that matches <literal>/home[01]/*/.plan</literal>
allows a program to access <filename>.plan</filename> files for
users in both <filename>/home0</filename> and
<filename>/home1</filename>.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>[a-c]</literal>
</para>
</entry>
<entry>
<para>
Substitutes for the single character <literal>a</literal>,
<literal>b</literal>, or <literal>c</literal>.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>{ab,cd}</literal>
</para>
</entry>
<entry>
<para>
Expands to one rule to match <literal>ab</literal> and one rule to
match <literal>cd</literal>.
</para>
<para>
Example: a rule that matches <literal>/{usr,www}/pages/**</literal>
grants access to Web pages in both <filename>/usr/pages</filename>
and <filename>/www/pages</filename>.
</para>
</entry>
</row>
<row>
<entry>
<para>
<literal>[^a]</literal>
</para>
</entry>
<entry>
<para>
Substitutes for any character except <literal>a</literal>.
</para>
</entry>