mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
Compare commits
144 Commits
check-if-s
...
v3.1.5
Author | SHA1 | Date | |
---|---|---|---|
|
3c5d40e84a | ||
|
eac7202808 | ||
|
3b61d42f79 | ||
|
f34d60b1e8 | ||
|
29b21b09d4 | ||
|
96395d9b82 | ||
|
9980ae76d8 | ||
|
dd136f4dd9 | ||
|
e5a3c03357 | ||
|
6831a8f440 | ||
|
ea5b52d3b2 | ||
|
3cdeb140a1 | ||
|
8c49449e46 | ||
|
a3685436eb | ||
|
2610fe4e80 | ||
|
c7f761b710 | ||
|
f00f296201 | ||
|
83772acf00 | ||
|
1d35eedef8 | ||
|
a597a612a7 | ||
|
64463c8686 | ||
|
7bd1c4d8ef | ||
|
c7bd872071 | ||
|
3d33fd440b | ||
|
e37cbd43c9 | ||
|
f91f33f2c6 | ||
|
51751aa687 | ||
|
89f1a84dfe | ||
|
d984b3edb6 | ||
|
2a7ddbc773 | ||
|
54bb7dccf0 | ||
|
aff29ef0ee | ||
|
26e85c17bd | ||
|
bdcd76a8ea | ||
|
e69cb50479 | ||
|
5a25bc6240 | ||
|
06e15a7789 | ||
|
d0e086e93a | ||
|
0e6b48cc78 | ||
|
c8eefe440c | ||
|
df3b9601de | ||
|
a9fa20a456 | ||
|
089064439d | ||
|
1759c1bd24 | ||
|
68de30cf76 | ||
|
925ccfe482 | ||
|
dc4b38acf0 | ||
|
9f25b5f6ff | ||
|
6e2eabd424 | ||
|
c8ce78e00c | ||
|
7526ba4b0a | ||
|
0eaf6d3649 | ||
|
e44e9187ae | ||
|
677051bd02 | ||
|
21ca572de6 | ||
|
6c240a473b | ||
|
eec9086ecf | ||
|
81d8af7c13 | ||
|
a9bea8a377 | ||
|
3aa895073a | ||
|
dcf7e9a0d5 | ||
|
57fec9624d | ||
|
aee9bf56c0 | ||
|
0295fadab3 | ||
|
5bc35342ed | ||
|
6cc9160246 | ||
|
5452053f5b | ||
|
da906cda8c | ||
|
a19754f52f | ||
|
379a486b87 | ||
|
5ad91d482d | ||
|
19bbc5dfc3 | ||
|
66cb0ed739 | ||
|
d179a704e7 | ||
|
4244737f65 | ||
|
e617f04681 | ||
|
9d826aae65 | ||
|
465c861b02 | ||
|
dc85d04805 | ||
|
a40923006c | ||
|
1fe80c0f85 | ||
|
8043dda3f6 | ||
|
e95080e140 | ||
|
45125cedd3 | ||
|
969a8f7618 | ||
|
770b8f1e88 | ||
|
3345250f72 | ||
|
51cf0848c7 | ||
|
e0c0a6a6a5 | ||
|
ea127f13cd | ||
|
480cb56553 | ||
|
075c69a4eb | ||
|
f9dbaa38ec | ||
|
7c7224004c | ||
|
db246ddbb5 | ||
|
a382452a54 | ||
|
f51049ea2e | ||
|
406b6398af | ||
|
bcffe7c92c | ||
|
86069dd934 | ||
|
2f9068e37c | ||
|
46a2be31a7 | ||
|
e8b60e46fe | ||
|
b1c2aeaa76 | ||
|
091c6ad59d | ||
|
854602c0d9 | ||
|
68e3f12c2c | ||
|
c57138f255 | ||
|
ea3fb60007 | ||
|
ef2e6c62e7 | ||
|
dc384c48a8 | ||
|
de3aa3c5f0 | ||
|
f590a66e50 | ||
|
813c831468 | ||
|
96f7121944 | ||
|
e4f88cc3a8 | ||
|
aff9bb8f81 | ||
|
62f99465e9 | ||
|
0375ea1257 | ||
|
c06ea77445 | ||
|
5a2fb8569c | ||
|
c9c5208f77 | ||
|
a555ccd9f4 | ||
|
1ff0c2c7d6 | ||
|
fda390983f | ||
|
b65fbf5fbd | ||
|
0afc2cbb84 | ||
|
1f3a817c11 | ||
|
c0815d0e0f | ||
|
c0b5d90848 | ||
|
e6cbdef4ab | ||
|
ea0dc96050 | ||
|
d442584a0a | ||
|
cf6606d380 | ||
|
85734c3bac | ||
|
47d68dac0f | ||
|
0c1eb3ec92 | ||
|
97bd86c7c6 | ||
|
0859b42ba2 | ||
|
e1011d646d | ||
|
db4939cf6a | ||
|
44c814e76c | ||
|
df97cf89bd | ||
|
8175d26cc3 |
@@ -77,7 +77,7 @@ test-utils:
|
||||
extends:
|
||||
- .ubuntu-before_script
|
||||
script:
|
||||
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter pyflakes3 python3-coverage python3-notify2 python3-psutil
|
||||
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter pyflakes3 python3-coverage python3-notify2 python3-psutil python3-setuptools
|
||||
# See apparmor/apparmor#221
|
||||
- make -C parser/tst gen_dbus
|
||||
- make -C parser/tst gen_xtrans
|
||||
@@ -104,6 +104,7 @@ test-profiles:
|
||||
script:
|
||||
- make -C profiles check-parser
|
||||
- make -C profiles check-abstractions.d
|
||||
- make -C profiles check-extras
|
||||
|
||||
shellcheck:
|
||||
stage: test
|
||||
|
@@ -454,6 +454,7 @@ static int detailed_output(FILE *json) {
|
||||
const char *process_statuses[] = {"enforce", "complain", "unconfined", "mixed", "kill"};
|
||||
int ret;
|
||||
size_t i;
|
||||
int need_finish = 0;
|
||||
|
||||
ret = get_profiles(&profiles, &nprofiles);
|
||||
if (ret != 0) {
|
||||
@@ -534,16 +535,20 @@ static int detailed_output(FILE *json) {
|
||||
} else {
|
||||
fprintf(json, "%s\"%s\": [{\"profile\": \"%s\", \"pid\": \"%s\", \"status\": \"%s\"}",
|
||||
// first element will be a unique executable
|
||||
i == 0 && j == 0 ? "" : "], ",
|
||||
j == 0 && !need_finish ? "" : "], ",
|
||||
filtered[j].exe, filtered[j].profile, filtered[j].pid, filtered[j].mode);
|
||||
}
|
||||
|
||||
need_finish = 1;
|
||||
}
|
||||
}
|
||||
free_processes(filtered, nfiltered);
|
||||
}
|
||||
if (json) {
|
||||
fprintf(json, "%s}}\n", nprocesses > 0 ? "]" : "");
|
||||
if (need_finish > 0) {
|
||||
fprintf(json, "]");
|
||||
}
|
||||
fprintf(json, "}}\n");
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@@ -1 +1 @@
|
||||
3.0.98
|
||||
3.1.5
|
||||
|
@@ -159,6 +159,8 @@ typedef struct
|
||||
char *fs_type;
|
||||
char *flags;
|
||||
char *src_name;
|
||||
|
||||
char *class;
|
||||
} aa_log_record;
|
||||
|
||||
/**
|
||||
|
@@ -11,9 +11,13 @@ INCLUDES = $(all_includes)
|
||||
# 3. If any interfaces have been added, removed, or changed since the last
|
||||
# update,
|
||||
# - increment AA_LIB_CURRENT
|
||||
# - by 1 if bugfix release
|
||||
# - by 5 on larger releases. This gives room to fix library interface
|
||||
# problems in the unlikely event where an interface has to break.
|
||||
# - set AA_LIB_REVISION to 0.
|
||||
# 4. If any interfaces have been added since the last public release, then
|
||||
# - increment AA_LIB_AGE.
|
||||
# - increment AA_LIB_AGE by the same amount that AA_LIB_CURRENT was
|
||||
# incremented.
|
||||
# 5. If any interfaces have been removed or changed since the last public
|
||||
# release, then
|
||||
# - set AA_LIB_AGE to 0.
|
||||
@@ -26,9 +30,12 @@ INCLUDES = $(all_includes)
|
||||
# For more information, see:
|
||||
# http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
|
||||
#
|
||||
AA_LIB_CURRENT = 9
|
||||
AA_LIB_REVISION = 2
|
||||
AA_LIB_AGE = 8
|
||||
# After changing the AA_LIB_* variables, also update EXPECTED_SO_NAME.
|
||||
|
||||
AA_LIB_CURRENT = 13
|
||||
AA_LIB_REVISION = 3
|
||||
AA_LIB_AGE = 12
|
||||
EXPECTED_SO_NAME = libapparmor.so.1.12.3
|
||||
|
||||
SUFFIXES = .pc.in .pc
|
||||
|
||||
@@ -77,4 +84,8 @@ tst_kernel_LDFLAGS = -pthread
|
||||
check_PROGRAMS = tst_aalogmisc tst_features tst_kernel
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
.PHONY: check-local
|
||||
check-local:
|
||||
test -f ./.libs/$(EXPECTED_SO_NAME) || { echo '*** unexpected .so name/number for libapparmor (expected $(EXPECTED_SO_NAME), the actual filename is shown below) ***' ; ls -l ./.libs/libapparmor.so.*.* ; exit 1; }
|
||||
|
||||
EXTRA_DIST = grammar.y scanner.l libapparmor.map libapparmor.pc
|
||||
|
@@ -159,7 +159,9 @@ aa_record_event_type lookup_aa_event(unsigned int type)
|
||||
%token TOK_KEY_NAMESPACE
|
||||
%token TOK_KEY_ERROR
|
||||
%token TOK_KEY_FSUID
|
||||
%token TOK_KEY_FSUID_UPPER
|
||||
%token TOK_KEY_OUID
|
||||
%token TOK_KEY_OUID_UPPER
|
||||
%token TOK_KEY_UID
|
||||
%token TOK_KEY_AUID
|
||||
%token TOK_KEY_SAUID
|
||||
@@ -185,6 +187,7 @@ aa_record_event_type lookup_aa_event(unsigned int type)
|
||||
%token TOK_KEY_FSTYPE
|
||||
%token TOK_KEY_FLAGS
|
||||
%token TOK_KEY_SRCNAME
|
||||
%token TOK_KEY_CLASS
|
||||
|
||||
%token TOK_SOCKLOGD_KERNEL
|
||||
%token TOK_SYSLOG_KERNEL
|
||||
@@ -351,6 +354,10 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
|
||||
{ ret_record->fsuid = $3;}
|
||||
| TOK_KEY_OUID TOK_EQUALS TOK_DIGITS
|
||||
{ ret_record->ouid = $3;}
|
||||
| TOK_KEY_FSUID_UPPER TOK_EQUALS TOK_QUOTED_STRING
|
||||
{ free($3);} /* Ignore - fsuid username */
|
||||
| TOK_KEY_OUID_UPPER TOK_EQUALS TOK_QUOTED_STRING
|
||||
{ free($3);} /* Ignore - ouid username */
|
||||
| TOK_KEY_SAUID TOK_EQUALS TOK_DIGITS
|
||||
{ /* Ignore - Source audit ID from user AVC messages */ }
|
||||
| TOK_KEY_HOSTNAME TOK_EQUALS safe_string
|
||||
@@ -425,6 +432,8 @@ key: TOK_KEY_OPERATION TOK_EQUALS TOK_QUOTED_STRING
|
||||
ret_record->event = AA_RECORD_INVALID;
|
||||
ret_record->info = $1;
|
||||
}
|
||||
| TOK_KEY_CLASS TOK_EQUALS TOK_QUOTED_STRING
|
||||
{ ret_record->class = $3; }
|
||||
;
|
||||
|
||||
apparmor_event:
|
||||
|
@@ -103,6 +103,8 @@ void free_record(aa_log_record *record)
|
||||
free(record->flags);
|
||||
if (record->src_name != NULL)
|
||||
free(record->src_name);
|
||||
if (record->class != NULL)
|
||||
free(record->class);
|
||||
|
||||
free(record);
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ void string_buf_append(unsigned int length, char *text)
|
||||
|
||||
%}
|
||||
|
||||
ws [ \t\r\n]
|
||||
ws [ \t\r\n\x1d]
|
||||
|
||||
equals "="
|
||||
digit [[:digit:]]
|
||||
@@ -121,6 +121,8 @@ key_namespace "namespace"
|
||||
key_mask "mask"
|
||||
key_denied_mask "denied_mask"
|
||||
key_requested_mask "requested_mask"
|
||||
key_denied "denied"
|
||||
key_requested "requested"
|
||||
key_attribute "attribute"
|
||||
key_task "task"
|
||||
key_parent "parent"
|
||||
@@ -138,7 +140,9 @@ key_sock_type "sock_type"
|
||||
key_protocol "protocol"
|
||||
key_error "error"
|
||||
key_fsuid "fsuid"
|
||||
key_fsuid_upper "FSUID"
|
||||
key_ouid "ouid"
|
||||
key_ouid_upper "OUID"
|
||||
key_uid "uid"
|
||||
key_auid "auid"
|
||||
key_sauid "sauid"
|
||||
@@ -161,11 +165,13 @@ key_dest "dest"
|
||||
key_path "path"
|
||||
key_interface "interface"
|
||||
key_member "member"
|
||||
key_method "method"
|
||||
key_signal "signal"
|
||||
key_peer "peer"
|
||||
key_fstype "fstype"
|
||||
key_flags "flags"
|
||||
key_srcname "srcname"
|
||||
key_class "class"
|
||||
audit "audit"
|
||||
|
||||
/* network addrs */
|
||||
@@ -307,6 +313,8 @@ yy_flex_debug = 0;
|
||||
{key_mask} { return(TOK_KEY_MASK); }
|
||||
{key_denied_mask} { return(TOK_KEY_DENIED_MASK); }
|
||||
{key_requested_mask} { return(TOK_KEY_REQUESTED_MASK); }
|
||||
{key_denied} { return(TOK_KEY_DENIED_MASK); }
|
||||
{key_requested} { return(TOK_KEY_REQUESTED_MASK); }
|
||||
{key_attribute} { BEGIN(sub_id); return(TOK_KEY_ATTRIBUTE); }
|
||||
{key_task} { return(TOK_KEY_TASK); }
|
||||
{key_parent} { return(TOK_KEY_PARENT); }
|
||||
@@ -324,7 +332,9 @@ yy_flex_debug = 0;
|
||||
{key_protocol} { return(TOK_KEY_PROTOCOL); }
|
||||
{key_error} { return(TOK_KEY_ERROR); }
|
||||
{key_fsuid} { return(TOK_KEY_FSUID); }
|
||||
{key_fsuid_upper} { return(TOK_KEY_FSUID_UPPER); }
|
||||
{key_ouid} { return(TOK_KEY_OUID); }
|
||||
{key_ouid_upper} { return(TOK_KEY_OUID_UPPER); }
|
||||
{key_uid} { return(TOK_KEY_UID); }
|
||||
{key_auid} { return(TOK_KEY_AUID); }
|
||||
{key_sauid} { return(TOK_KEY_SAUID); }
|
||||
@@ -346,11 +356,13 @@ yy_flex_debug = 0;
|
||||
{key_path} { return(TOK_KEY_PATH); }
|
||||
{key_interface} { return(TOK_KEY_INTERFACE); }
|
||||
{key_member} { return(TOK_KEY_MEMBER); }
|
||||
{key_method} { return(TOK_KEY_MEMBER); }
|
||||
{key_signal} { BEGIN(sub_id); return(TOK_KEY_SIGNAL); }
|
||||
{key_peer} { BEGIN(safe_string); return(TOK_KEY_PEER); }
|
||||
{key_fstype} { return(TOK_KEY_FSTYPE); }
|
||||
{key_flags} { BEGIN(safe_string); return(TOK_KEY_FLAGS); }
|
||||
{key_srcname} { BEGIN(safe_string); return(TOK_KEY_SRCNAME); }
|
||||
{key_class} { BEGIN(safe_string); return(TOK_KEY_CLASS); }
|
||||
|
||||
{socklogd_kernel} { BEGIN(dmesg_timestamp); return(TOK_SOCKLOGD_KERNEL); }
|
||||
{syslog_kernel} { BEGIN(dmesg_timestamp); return(TOK_SYSLOG_KERNEL); }
|
||||
|
@@ -1,6 +1 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
from LibAppArmor.LibAppArmor import *
|
||||
else:
|
||||
from .LibAppArmor import *
|
||||
from LibAppArmor.LibAppArmor import *
|
||||
|
@@ -10,8 +10,7 @@ test_python.py: test_python.py.in $(top_builddir)/config.status
|
||||
|
||||
CLEANFILES = test_python.py
|
||||
|
||||
# bah, how brittle is this?
|
||||
PYTHON_DIST_BUILD_PATH = '$(builddir)/../build/$$($(PYTHON) -c "import sysconfig; print(\"lib.%s-%s\" %(sysconfig.get_platform(), sysconfig.get_python_version()))")'
|
||||
PYTHON_DIST_BUILD_PATH = '$(builddir)/../build/$$($(PYTHON) buildpath.py)'
|
||||
|
||||
TESTS = test_python.py
|
||||
TESTS_ENVIRONMENT = \
|
||||
|
14
libraries/libapparmor/swig/python/test/buildpath.py
Normal file
14
libraries/libapparmor/swig/python/test/buildpath.py
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python3
|
||||
# the build path has changed in setuptools 62.1:
|
||||
# https://github.com/pypa/setuptools/commit/1c23f5e1e4b18b50081cbabb2dea22bf345f5894
|
||||
import sys
|
||||
import sysconfig
|
||||
|
||||
import setuptools
|
||||
|
||||
|
||||
if tuple(map(int, setuptools.__version__.split("."))) >= (62, 1):
|
||||
identifier = sys.implementation.cache_tag
|
||||
else:
|
||||
identifier = "%d.%d" % sys.version_info[:2]
|
||||
print("lib.%s-%s" % (sysconfig.get_platform(), identifier))
|
@@ -13,6 +13,7 @@
|
||||
import ctypes
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import LibAppArmor as libapparmor
|
||||
|
||||
TESTDIR = "../../../testsuite/test_multi"
|
||||
@@ -34,6 +35,7 @@ OUTPUT_MAP = {
|
||||
'Local port': 'net_local_port',
|
||||
'Foreign port': 'net_foreign_port',
|
||||
'Audit subid': 'audit_sub_id',
|
||||
'Class': '_class',
|
||||
}
|
||||
|
||||
# FIXME: pull this automatically out of LibAppArmor, but swig
|
||||
@@ -75,11 +77,11 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
|
||||
expected = self.parse_output_file(outfile)
|
||||
self.assertEqual(expected, record,
|
||||
"expected records did not match\n" +
|
||||
"expected = %s\nactual = %s" % (expected, record))
|
||||
"expected records did not match\n"
|
||||
"expected = %s\nactual = %s" % (expected, record))
|
||||
|
||||
def parse_output_file(self, outfile):
|
||||
'''parse testcase .out file and return dict'''
|
||||
"""parse testcase .out file and return dict"""
|
||||
|
||||
output = dict()
|
||||
with open(os.path.join(TESTDIR, outfile), 'r') as f:
|
||||
@@ -105,10 +107,10 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
return output
|
||||
|
||||
def create_record_dict(self, record):
|
||||
'''parse the swig created record and construct a dict from it'''
|
||||
"""parse the swig created record and construct a dict from it"""
|
||||
|
||||
new_record = dict()
|
||||
for key in [x for x in dir(record) if not (x.startswith('_') or x == 'this')]:
|
||||
for key in [x for x in dir(record) if not (x.startswith('__') or x == 'this')]:
|
||||
value = getattr(record, key)
|
||||
if key == "event" and value in EVENT_MAP:
|
||||
new_record[key] = EVENT_MAP[value]
|
||||
@@ -128,7 +130,7 @@ class AAPythonBindingsTests(unittest.TestCase):
|
||||
|
||||
|
||||
def find_testcases(testdir):
|
||||
'''dig testcases out of passed directory'''
|
||||
"""dig testcases out of passed directory"""
|
||||
|
||||
for f in os.listdir(testdir):
|
||||
if f.endswith(".in"):
|
||||
@@ -143,5 +145,6 @@ def main():
|
||||
setattr(AAPythonBindingsTests, 'test_%s' % (f), stub_test)
|
||||
return unittest.main(verbosity=2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -134,6 +134,8 @@ int print_results(aa_log_record *record)
|
||||
print_string("Flags", record->flags);
|
||||
print_string("Src name", record->src_name);
|
||||
|
||||
print_string("Class", record->class);
|
||||
|
||||
print_long("Epoch", record->epoch, 0);
|
||||
print_long("Audit subid", (long) record->audit_sub_id, 0);
|
||||
return(0);
|
||||
|
@@ -0,0 +1 @@
|
||||
type=AVC msg=audit(1661734785.992:270): apparmor="ALLOWED" operation="open" profile="/usr/bin/dolphin" name="/home/otis/.config/kdedefaults/kdeglobals" pid=3483 comm="dolphin" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0FSUID="otis" OUID="root"
|
@@ -0,0 +1,15 @@
|
||||
START
|
||||
File: 0x1d-uppercase-FSUID-OUID.in
|
||||
Event type: AA_RECORD_ALLOWED
|
||||
Audit ID: 1661734785.992:270
|
||||
Operation: open
|
||||
Mask: r
|
||||
Denied Mask: r
|
||||
fsuid: 1000
|
||||
ouid: 0
|
||||
Profile: /usr/bin/dolphin
|
||||
Name: /home/otis/.config/kdedefaults/kdeglobals
|
||||
Command: dolphin
|
||||
PID: 3483
|
||||
Epoch: 1661734785
|
||||
Audit subid: 270
|
@@ -0,0 +1,4 @@
|
||||
/usr/bin/dolphin {
|
||||
/home/otis/.config/kdedefaults/kdeglobals r,
|
||||
|
||||
}
|
1
libraries/libapparmor/testsuite/test_multi/file_xm.in
Normal file
1
libraries/libapparmor/testsuite/test_multi/file_xm.in
Normal file
@@ -0,0 +1 @@
|
||||
type=AVC msg=audit(1676978994.840:1493): apparmor="DENIED" operation="link" profile="cargo" name="/var/tmp/portage/dev-lang/rust-1.67.1/work/rustc-1.67.1-src/build/bootstrap/debug/libbootstrap.rlib" pid=12412 comm="cargo" requested_mask="xm" denied_mask="xm" fsuid=250 ouid=250 target="/var/tmp/portage/dev-lang/rust-1.67.1/work/rustc-1.67.1-src/build/bootstrap/debug/deps/libbootstrap-4542dd99e796257e.rlib"FSUID="portage" OUID="portage"
|
16
libraries/libapparmor/testsuite/test_multi/file_xm.out
Normal file
16
libraries/libapparmor/testsuite/test_multi/file_xm.out
Normal file
@@ -0,0 +1,16 @@
|
||||
START
|
||||
File: file_xm.in
|
||||
Event type: AA_RECORD_DENIED
|
||||
Audit ID: 1676978994.840:1493
|
||||
Operation: link
|
||||
Mask: xm
|
||||
Denied Mask: xm
|
||||
fsuid: 250
|
||||
ouid: 250
|
||||
Profile: cargo
|
||||
Name: /var/tmp/portage/dev-lang/rust-1.67.1/work/rustc-1.67.1-src/build/bootstrap/debug/libbootstrap.rlib
|
||||
Command: cargo
|
||||
Name2: /var/tmp/portage/dev-lang/rust-1.67.1/work/rustc-1.67.1-src/build/bootstrap/debug/deps/libbootstrap-4542dd99e796257e.rlib
|
||||
PID: 12412
|
||||
Epoch: 1676978994
|
||||
Audit subid: 1493
|
@@ -0,0 +1,4 @@
|
||||
profile cargo {
|
||||
owner /var/tmp/portage/dev-lang/rust-1.67.1/work/rustc-1.67.1-src/build/bootstrap/debug/libbootstrap.rlib m,
|
||||
|
||||
}
|
@@ -0,0 +1 @@
|
||||
Dec 15 17:32:17 kinetic kernel: [4835959.046111] audit: type=1107 audit(1671125537.724:209): pid=7308 uid=0 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call" bus="session" path="/org/freedesktop/DBus" interface="org.freedesktop.DBus" method="Hello" mask="send" label="/tmp/apparmor/tests/regression/apparmor/dbus_message" peer_label="unconfined" exe="/usr/local/bin/dbus-broker" sauid=0 hostname=? addr=? terminal=?'
|
@@ -0,0 +1,15 @@
|
||||
START
|
||||
File: testcase_dbus_11.in
|
||||
Event type: AA_RECORD_DENIED
|
||||
Audit ID: 1671125537.724:209
|
||||
Operation: dbus_method_call
|
||||
Denied Mask: send
|
||||
Profile: /tmp/apparmor/tests/regression/apparmor/dbus_message
|
||||
Peer profile: unconfined
|
||||
Command: /usr/local/bin/dbus-broker
|
||||
DBus bus: session
|
||||
DBus path: /org/freedesktop/DBus
|
||||
DBus interface: org.freedesktop.DBus
|
||||
DBus member: Hello
|
||||
Epoch: 1671125537
|
||||
Audit subid: 209
|
@@ -0,0 +1,4 @@
|
||||
/tmp/apparmor/tests/regression/apparmor/dbus_message {
|
||||
dbus send bus=session path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello peer=(label=unconfined),
|
||||
|
||||
}
|
@@ -60,7 +60,7 @@ WARNINGS = -Wall
|
||||
CXX_WARNINGS = ${WARNINGS} ${EXTRA_WARNINGS}
|
||||
CPP_WARNINGS =
|
||||
ifndef CFLAGS
|
||||
CFLAGS = -g -O2 -pipe -flto-partition=none
|
||||
CFLAGS = -g -O2 -pipe
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += -pg -D DEBUG
|
||||
@@ -70,6 +70,8 @@ CFLAGS = -g -pg -fprofile-arcs -ftest-coverage
|
||||
endif
|
||||
endif #CFLAGS
|
||||
|
||||
CFLAGS += -flto-partition=none
|
||||
|
||||
EXTRA_CXXFLAGS = ${CFLAGS} ${CPPFLAGS} ${CXX_WARNINGS} -std=gnu++0x
|
||||
EXTRA_CFLAGS = ${EXTRA_CXXFLAGS} ${CPP_WARNINGS}
|
||||
|
||||
@@ -384,11 +386,11 @@ DISTRO=$(shell if [ -f /etc/slackware-version ] ; then \
|
||||
elif [ -f /etc/debian_version ] ; then \
|
||||
echo debian ;\
|
||||
elif which rpm > /dev/null ; then \
|
||||
if [ "$(rpm --eval '0%{?suse_version}')" != "0" ] ; then \
|
||||
if [ "$$(rpm --eval '0%{?suse_version}')" != "0" ] ; then \
|
||||
echo suse ;\
|
||||
elif [ "$(rpm --eval '%{_host_vendor}')" = redhat ] ; then \
|
||||
elif [ "$$(rpm --eval '%{_host_vendor}')" = redhat ] ; then \
|
||||
echo rhel4 ;\
|
||||
elif [ "$(rpm --eval '0%{?fedora}')" != "0" ] ; then \
|
||||
elif [ "$$(rpm --eval '0%{?fedora}')" != "0" ] ; then \
|
||||
echo rhel4 ;\
|
||||
else \
|
||||
echo unknown ;\
|
||||
|
@@ -111,8 +111,7 @@ unix_rule::unix_rule(unsigned int type_p, bool audit_p, bool denied):
|
||||
|
||||
unix_rule::unix_rule(int mode_p, struct cond_entry *conds,
|
||||
struct cond_entry *peer_conds):
|
||||
af_rule("unix"), addr(NULL), peer_addr(NULL),
|
||||
audit(0), deny(0)
|
||||
af_rule("unix"), addr(NULL), peer_addr(NULL)
|
||||
{
|
||||
move_conditionals(conds);
|
||||
move_peer_conditionals(peer_conds);
|
||||
@@ -136,7 +135,7 @@ ostream &unix_rule::dump_local(ostream &os)
|
||||
{
|
||||
af_rule::dump_local(os);
|
||||
if (addr)
|
||||
os << "addr='" << addr << "'";
|
||||
os << " addr='" << addr << "'";
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -144,7 +143,7 @@ ostream &unix_rule::dump_peer(ostream &os)
|
||||
{
|
||||
af_rule::dump_peer(os);
|
||||
if (peer_addr)
|
||||
os << "addr='" << peer_addr << "'";
|
||||
os << " addr='" << peer_addr << "'";
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@@ -36,9 +36,6 @@ class unix_rule: public af_rule {
|
||||
public:
|
||||
char *addr;
|
||||
char *peer_addr;
|
||||
int mode;
|
||||
int audit;
|
||||
bool deny;
|
||||
|
||||
unix_rule(unsigned int type_p, bool audit_p, bool denied);
|
||||
unix_rule(int mode, struct cond_entry *conds,
|
||||
|
@@ -172,7 +172,7 @@ B<MOUNT FLAGS EXPRESSION> = ( I<MOUNT FLAGS LIST> | I<MOUNT EXPRESSION> )
|
||||
|
||||
B<MOUNT FLAGS LIST> = Comma separated list of I<MOUNT FLAGS>.
|
||||
|
||||
B<MOUNT FLAGS> = ( 'ro' | 'rw' | 'nosuid' | 'suid' | 'nodev' | 'dev' | 'noexec' | 'exec' | 'sync' | 'async' | 'remount' | 'mand' | 'nomand' | 'dirsync' | 'noatime' | 'atime' | 'nodiratime' | 'diratime' | 'bind' | 'rbind' | 'move' | 'verbose' | 'silent' | 'loud' | 'acl' | 'noacl' | 'unbindable' | 'runbindable' | 'private' | 'rprivate' | 'slave' | 'rslave' | 'shared' | 'rshared' | 'relatime' | 'norelatime' | 'iversion' | 'noiversion' | 'strictatime' | 'nouser' | 'user' )
|
||||
B<MOUNT FLAGS> = ( 'ro' | 'rw' | 'nosuid' | 'suid' | 'nodev' | 'dev' | 'noexec' | 'exec' | 'sync' | 'async' | 'remount' | 'mand' | 'nomand' | 'dirsync' | 'noatime' | 'atime' | 'nodiratime' | 'diratime' | 'bind' | 'rbind' | 'move' | 'verbose' | 'silent' | 'loud' | 'acl' | 'noacl' | 'unbindable' | 'runbindable' | 'private' | 'rprivate' | 'slave' | 'rslave' | 'shared' | 'rshared' | 'relatime' | 'norelatime' | 'iversion' | 'noiversion' | 'strictatime' | 'nostrictatime' | 'lazytime' | 'nolazytime' | 'nouser' | 'user' | 'symfollow' | 'nosymfollow' )
|
||||
|
||||
B<MOUNT EXPRESSION> = ( I<ALPHANUMERIC> | I<AARE> ) ...
|
||||
|
||||
|
@@ -193,9 +193,8 @@ void CHFA::insert_state(vector<pair<size_t, size_t> > &free_list,
|
||||
State *default_state = dfa.nonmatching;
|
||||
ssize_t base = 0;
|
||||
int resize;
|
||||
|
||||
StateTrans &trans = from->trans;
|
||||
ssize_t c = trans.begin()->first.c;
|
||||
ssize_t c;
|
||||
ssize_t prev = 0;
|
||||
ssize_t x = first_free;
|
||||
|
||||
@@ -204,6 +203,7 @@ void CHFA::insert_state(vector<pair<size_t, size_t> > &free_list,
|
||||
if (trans.empty())
|
||||
goto do_insert;
|
||||
|
||||
c = trans.begin()->first.c;
|
||||
repeat:
|
||||
resize = 0;
|
||||
/* get the first free entry that won't underflow */
|
||||
@@ -251,10 +251,18 @@ repeat:
|
||||
first_free = next;
|
||||
}
|
||||
|
||||
do_insert:
|
||||
/* these flags will only be set on states that have transitions */
|
||||
if (c < 0) {
|
||||
base |= MATCH_FLAG_OOB_TRANSITION;
|
||||
}
|
||||
do_insert:
|
||||
/* While a state without transitions could have the diff encode
|
||||
* flag set, it would be pointless resulting in just an extra
|
||||
* state transition in the encoding chain, and so it should be
|
||||
* considered an error
|
||||
* TODO: add check that state without transitions isn't being
|
||||
* given a diffencode flag
|
||||
*/
|
||||
if (from->flags & DiffEncodeFlag)
|
||||
base |= DiffEncodeBit32;
|
||||
default_base.push_back(make_pair(default_state, base));
|
||||
|
735
parser/mount.cc
735
parser/mount.cc
@@ -98,6 +98,9 @@
|
||||
* nomand
|
||||
* #define MS_DIRSYNC 128 Directory modifications are synchronous
|
||||
* dirsync
|
||||
* #define MS_NOSYMFOLLOW 256 Do not follow symlinks
|
||||
* symfollow
|
||||
* nosymfollow
|
||||
* #define MS_NOATIME 1024 Do not update access times
|
||||
* noatime
|
||||
* atime
|
||||
@@ -139,6 +142,9 @@
|
||||
* #define MS_STRICTATIME (1<<24) Always perform atime updates
|
||||
* strictatime
|
||||
* nostrictatime
|
||||
* #define MS_LAZYTIME (1<<25) Update the on-disk [acm]times lazily
|
||||
* lazytime
|
||||
* nolazytime
|
||||
* #define MS_NOSEC (1<<28)
|
||||
* #define MS_BORN (1<<29)
|
||||
* #define MS_ACTIVE (1<<30)
|
||||
@@ -246,6 +252,8 @@ static struct mnt_keyword_table mnt_opts_table[] = {
|
||||
{"mand", MS_MAND, 0},
|
||||
{"nomand", 0, MS_MAND},
|
||||
{"dirsync", MS_DIRSYNC, 0},
|
||||
{"symfollow", 0, MS_NOSYMFOLLOW},
|
||||
{"nosymfollow", MS_NOSYMFOLLOW, 0},
|
||||
{"atime", 0, MS_NOATIME},
|
||||
{"noatime", MS_NOATIME, 0},
|
||||
{"diratime", 0, MS_NODIRATIME},
|
||||
@@ -283,6 +291,9 @@ static struct mnt_keyword_table mnt_opts_table[] = {
|
||||
{"iversion", MS_IVERSION, 0},
|
||||
{"noiversion", 0, MS_IVERSION},
|
||||
{"strictatime", MS_STRICTATIME, 0},
|
||||
{"nostrictatime", 0, MS_STRICTATIME},
|
||||
{"lazytime", MS_LAZYTIME, 0},
|
||||
{"nolazytime", 0, MS_LAZYTIME},
|
||||
{"user", 0, (unsigned int) MS_NOUSER},
|
||||
{"nouser", (unsigned int) MS_NOUSER, 0},
|
||||
|
||||
@@ -298,6 +309,22 @@ static struct mnt_keyword_table mnt_conds_table[] = {
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
static ostream &dump_flags(ostream &os,
|
||||
pair <unsigned int, unsigned int> flags)
|
||||
{
|
||||
for (int i = 0; mnt_opts_table[i].keyword; i++) {
|
||||
if ((flags.first & mnt_opts_table[i].set) ||
|
||||
(flags.second & mnt_opts_table[i].clear))
|
||||
os << mnt_opts_table[i].keyword;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
ostream &operator<<(ostream &os, pair<unsigned int, unsigned int> flags)
|
||||
{
|
||||
return dump_flags(os, flags);
|
||||
}
|
||||
|
||||
static int find_mnt_keyword(struct mnt_keyword_table *table, const char *name)
|
||||
{
|
||||
int i;
|
||||
@@ -320,7 +347,7 @@ int is_valid_mnt_cond(const char *name, int src)
|
||||
|
||||
static unsigned int extract_flags(struct value_list **list, unsigned int *inv)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
unsigned int flags = 0, invflags = 0;
|
||||
*inv = 0;
|
||||
|
||||
struct value_list *entry, *tmp, *prev = NULL;
|
||||
@@ -329,11 +356,11 @@ static unsigned int extract_flags(struct value_list **list, unsigned int *inv)
|
||||
i = find_mnt_keyword(mnt_opts_table, entry->value);
|
||||
if (i != -1) {
|
||||
flags |= mnt_opts_table[i].set;
|
||||
*inv |= mnt_opts_table[i].clear;
|
||||
invflags |= mnt_opts_table[i].clear;
|
||||
PDEBUG(" extracting mount flag %s req: 0x%x inv: 0x%x"
|
||||
" => req: 0x%x inv: 0x%x\n",
|
||||
entry->value, mnt_opts_table[i].set,
|
||||
mnt_opts_table[i].clear, flags, *inv);
|
||||
mnt_opts_table[i].clear, flags, invflags);
|
||||
if (prev)
|
||||
prev->next = tmp;
|
||||
if (entry == *list)
|
||||
@@ -344,9 +371,27 @@ static unsigned int extract_flags(struct value_list **list, unsigned int *inv)
|
||||
prev = entry;
|
||||
}
|
||||
|
||||
if (inv)
|
||||
*inv = invflags;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static bool conflicting_flags(unsigned int flags, unsigned int inv)
|
||||
{
|
||||
if (flags & inv) {
|
||||
for (int i = 0; i < 31; i++) {
|
||||
unsigned int mask = 1 << i;
|
||||
if ((flags & inv) & mask) {
|
||||
cerr << "conflicting flag values = "
|
||||
<< flags << ", " << inv << "\n";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct value_list *extract_fstype(struct cond_entry **conds)
|
||||
{
|
||||
struct value_list *list = NULL;
|
||||
@@ -369,22 +414,19 @@ static struct value_list *extract_fstype(struct cond_entry **conds)
|
||||
return list;
|
||||
}
|
||||
|
||||
static struct value_list *extract_options(struct cond_entry **conds, int eq)
|
||||
static struct cond_entry *extract_options(struct cond_entry **conds, int eq)
|
||||
{
|
||||
struct value_list *list = NULL;
|
||||
|
||||
struct cond_entry *entry, *tmp, *prev = NULL;
|
||||
struct cond_entry *list = NULL, *entry, *tmp, *prev = NULL;
|
||||
|
||||
list_for_each_safe(*conds, entry, tmp) {
|
||||
if ((strcmp(entry->name, "options") == 0 ||
|
||||
strcmp(entry->name, "option") == 0) &&
|
||||
entry->eq == eq) {
|
||||
list_remove_at(*conds, prev, entry);
|
||||
PDEBUG(" extracting option %s\n", entry->name);
|
||||
list_append(entry->vals, list);
|
||||
list = entry->vals;
|
||||
entry->vals = NULL;
|
||||
free_cond_entry(entry);
|
||||
PDEBUG(" extracting %s %s\n", entry->name, entry->eq ?
|
||||
"=" : "in");
|
||||
list_append(entry, list);
|
||||
list = entry;
|
||||
} else
|
||||
prev = entry;
|
||||
}
|
||||
@@ -392,60 +434,129 @@ static struct value_list *extract_options(struct cond_entry **conds, int eq)
|
||||
return list;
|
||||
}
|
||||
|
||||
static void perror_conds(const char *rule, struct cond_entry *conds)
|
||||
{
|
||||
struct cond_entry *entry;
|
||||
|
||||
list_for_each(conds, entry) {
|
||||
PERROR( "unsupported %s condition '%s%s(...)'\n", rule, entry->name, entry->eq ? "=" : " in ");
|
||||
}
|
||||
}
|
||||
|
||||
static void perror_vals(const char *rule, struct value_list *vals)
|
||||
{
|
||||
struct value_list *entry;
|
||||
|
||||
list_for_each(vals, entry) {
|
||||
PERROR( "unsupported %s value '%s'\n", rule, entry->value);
|
||||
}
|
||||
}
|
||||
|
||||
static void process_one_option(struct cond_entry *&opts, unsigned int &flags,
|
||||
unsigned int &inv_flags)
|
||||
{
|
||||
struct cond_entry *entry;
|
||||
struct value_list *vals;
|
||||
|
||||
entry = list_pop(opts);
|
||||
vals = entry->vals;
|
||||
entry->vals = NULL;
|
||||
/* fail if there are any unknown optional flags */
|
||||
if (opts) {
|
||||
PERROR(" unsupported multiple 'mount options %s(...)'\n", entry->eq ? "=" : " in ");
|
||||
exit(1);
|
||||
}
|
||||
free_cond_entry(entry);
|
||||
|
||||
flags = extract_flags(&vals, &inv_flags);
|
||||
if (vals) {
|
||||
perror_vals("mount option", vals);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
mnt_rule::mnt_rule(struct cond_entry *src_conds, char *device_p,
|
||||
struct cond_entry *dst_conds unused, char *mnt_point_p,
|
||||
int allow_p):
|
||||
mnt_point(mnt_point_p), device(device_p), trans(NULL), opts(NULL),
|
||||
flags(0), inv_flags(0), audit(0), deny(0)
|
||||
flagsv(0), opt_flagsv(0), audit(0), deny(0)
|
||||
{
|
||||
/* FIXME: dst_conds are ignored atm */
|
||||
dev_type = extract_fstype(&src_conds);
|
||||
|
||||
if (src_conds) {
|
||||
struct value_list *list = extract_options(&src_conds, 0);
|
||||
/* move options in () to local list */
|
||||
struct cond_entry *opts_in = extract_options(&src_conds, 0);
|
||||
|
||||
opts = extract_options(&src_conds, 1);
|
||||
if (opts)
|
||||
flags = extract_flags(&opts, &inv_flags);
|
||||
if (opts_in) {
|
||||
unsigned int tmpflags = 0, tmpinv_flags = 0;
|
||||
struct cond_entry *entry;
|
||||
|
||||
if (list) {
|
||||
unsigned int tmpflags, tmpinv_flags = 0;
|
||||
|
||||
tmpflags = extract_flags(&list, &tmpinv_flags);
|
||||
/* these flags are optional so set both */
|
||||
tmpflags |= tmpinv_flags;
|
||||
tmpinv_flags |= tmpflags;
|
||||
|
||||
flags |= tmpflags;
|
||||
inv_flags |= tmpinv_flags;
|
||||
|
||||
if (opts)
|
||||
list_append(opts, list);
|
||||
else if (list)
|
||||
opts = list;
|
||||
while ((entry = list_pop(opts_in))) {
|
||||
process_one_option(entry, tmpflags,
|
||||
tmpinv_flags);
|
||||
/* optional flags if set/clear mean the same
|
||||
* thing and can be represented by a single
|
||||
* bitset, also there is no need to check for
|
||||
* conflicting flags when they are optional
|
||||
*/
|
||||
opt_flagsv.push_back(tmpflags | tmpinv_flags);
|
||||
}
|
||||
}
|
||||
|
||||
/* move options=() to opts list */
|
||||
struct cond_entry *opts_eq = extract_options(&src_conds, 1);
|
||||
if (opts_eq) {
|
||||
unsigned int tmpflags = 0, tmpinv_flags = 0;
|
||||
struct cond_entry *entry;
|
||||
|
||||
while ((entry = list_pop(opts_eq))) {
|
||||
process_one_option(entry, tmpflags,
|
||||
tmpinv_flags);
|
||||
/* throw away tmpinv_flags, only needed in
|
||||
* consistancy check
|
||||
*/
|
||||
if (allow_p & AA_DUMMY_REMOUNT)
|
||||
tmpflags |= MS_REMOUNT;
|
||||
|
||||
if (conflicting_flags(tmpflags, tmpinv_flags)) {
|
||||
PERROR("conflicting flags in the rule\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
flagsv.push_back(tmpflags);
|
||||
}
|
||||
}
|
||||
|
||||
if (src_conds) {
|
||||
perror_conds("mount", src_conds);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flagsv.size() + opt_flagsv.size())) {
|
||||
/* no flag options, and not remount, allow everything */
|
||||
if (allow_p & AA_DUMMY_REMOUNT) {
|
||||
flagsv.push_back(MS_REMOUNT);
|
||||
opt_flagsv.push_back(MS_REMOUNT_FLAGS & ~MS_REMOUNT);
|
||||
} else {
|
||||
flagsv.push_back(MS_ALL_FLAGS);
|
||||
opt_flagsv.push_back(MS_ALL_FLAGS);
|
||||
}
|
||||
} else if (!(flagsv.size())) {
|
||||
/* no flags but opts set */
|
||||
if (allow_p & AA_DUMMY_REMOUNT)
|
||||
flagsv.push_back(MS_REMOUNT);
|
||||
else
|
||||
flagsv.push_back(0);
|
||||
} else if (!(opt_flagsv.size())) {
|
||||
opt_flagsv.push_back(0);
|
||||
}
|
||||
|
||||
if (allow_p & AA_DUMMY_REMOUNT) {
|
||||
allow_p = AA_MAY_MOUNT;
|
||||
flags |= MS_REMOUNT;
|
||||
inv_flags = 0;
|
||||
} else if (!(flags | inv_flags)) {
|
||||
/* no flag options, and not remount, allow everything */
|
||||
flags = MS_ALL_FLAGS;
|
||||
inv_flags = MS_ALL_FLAGS;
|
||||
}
|
||||
|
||||
allow = allow_p;
|
||||
|
||||
if (src_conds) {
|
||||
PERROR(" unsupported mount conditions\n");
|
||||
exit(1);
|
||||
}
|
||||
if (opts) {
|
||||
PERROR(" unsupported mount options\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ostream &mnt_rule::dump(ostream &os)
|
||||
@@ -459,7 +570,11 @@ ostream &mnt_rule::dump(ostream &os)
|
||||
else
|
||||
os << "error: unknown mount perm";
|
||||
|
||||
os << " (0x" << hex << flags << " - 0x" << inv_flags << ") ";
|
||||
for (unsigned int i = 0; i < flagsv.size(); i++)
|
||||
os << " flags=(0x" << hex << flagsv[i] << ")";
|
||||
for (unsigned int i = 0; i < opt_flagsv.size(); i++)
|
||||
os << " flags in (0x" << hex << opt_flagsv[i] << ")";
|
||||
|
||||
if (dev_type) {
|
||||
os << " type=";
|
||||
print_value_list(dev_type);
|
||||
@@ -515,7 +630,7 @@ int mnt_rule::expand_variables(void)
|
||||
}
|
||||
|
||||
static int build_mnt_flags(char *buffer, int size, unsigned int flags,
|
||||
unsigned int inv_flags)
|
||||
unsigned int opt_flags)
|
||||
{
|
||||
char *p = buffer;
|
||||
int i, len = 0;
|
||||
@@ -528,7 +643,7 @@ static int build_mnt_flags(char *buffer, int size, unsigned int flags,
|
||||
return TRUE;
|
||||
}
|
||||
for (i = 0; i <= 31; ++i) {
|
||||
if ((flags & inv_flags) & (1 << i))
|
||||
if ((opt_flags) & (1 << i))
|
||||
len = snprintf(p, size, "(\\x%02x|)", i + 1);
|
||||
else if (flags & (1 << i))
|
||||
len = snprintf(p, size, "\\x%02x", i + 1);
|
||||
@@ -583,7 +698,9 @@ void mnt_rule::warn_once(const char *name)
|
||||
rule_t::warn_once(name, "mount rules not enforce");
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_re(Profile &prof)
|
||||
|
||||
int mnt_rule::gen_policy_remount(Profile &prof, int &count,
|
||||
unsigned int flags, unsigned int opt_flags)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
@@ -592,8 +709,322 @@ int mnt_rule::gen_policy_re(Profile &prof)
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
int tmpallow;
|
||||
|
||||
sprintf(class_mount_hdr, "\\x%02x", AA_CLASS_MOUNT);
|
||||
|
||||
/* remount can't be conditional on device and type */
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (mnt_point) {
|
||||
/* both device && mnt_point or just mnt_point */
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
} else {
|
||||
if (!convert_entry(mntbuf, device))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
}
|
||||
/* skip device */
|
||||
vec[1] = default_match_pattern;
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, flags & MS_REMOUNT_FLAGS,
|
||||
opt_flags & MS_REMOUNT_FLAGS))
|
||||
goto fail;
|
||||
|
||||
vec[3] = flagsbuf;
|
||||
|
||||
if (opts)
|
||||
tmpallow = AA_MATCH_CONT;
|
||||
else
|
||||
tmpallow = allow;
|
||||
|
||||
/* rule for match without required data || data MATCH_CONT */
|
||||
if (!prof.policy.rules->add_rule_vec(deny, tmpallow,
|
||||
audit | AA_AUDIT_MNT_DATA, 4,
|
||||
vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
if (opts) {
|
||||
/* rule with data match required */
|
||||
optsbuf.clear();
|
||||
if (!build_mnt_opts(optsbuf, opts))
|
||||
goto fail;
|
||||
vec[4] = optsbuf.c_str();
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow,
|
||||
audit | AA_AUDIT_MNT_DATA,
|
||||
5, vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
|
||||
return RULE_OK;
|
||||
|
||||
fail:
|
||||
return RULE_ERROR;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_bind_mount(Profile &prof, int &count,
|
||||
unsigned int flags, unsigned int opt_flags)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
std::string typebuf;
|
||||
char flagsbuf[PATH_MAX + 3];
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
|
||||
sprintf(class_mount_hdr, "\\x%02x", AA_CLASS_MOUNT);
|
||||
|
||||
/* bind mount rules can't be conditional on dev_type or data */
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, flags & MS_BIND_FLAGS,
|
||||
opt_flags & MS_BIND_FLAGS))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
return RULE_OK;
|
||||
|
||||
fail:
|
||||
return RULE_ERROR;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_change_mount_type(Profile &prof, int &count,
|
||||
unsigned int flags,
|
||||
unsigned int opt_flags)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
std::string typebuf;
|
||||
char flagsbuf[PATH_MAX + 3];
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
char *mountpoint = mnt_point;
|
||||
|
||||
sprintf(class_mount_hdr, "\\x%02x", AA_CLASS_MOUNT);
|
||||
|
||||
/* change type base rules can specify the mount point by using
|
||||
* the parser token position reserved to device. that's why if
|
||||
* the mount point is not specified, we use device in its
|
||||
* place. this is a deprecated behavior.
|
||||
*
|
||||
* change type base rules can not be conditional on device
|
||||
* (source), device type or data
|
||||
*/
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (flags && flags != MS_ALL_FLAGS && device && mnt_point) {
|
||||
PERROR("source and mount point cannot be used at the "
|
||||
"same time for propagation type flags");
|
||||
goto fail;
|
||||
} else if (device && !mnt_point) {
|
||||
pwarn(WARN_DEPRECATED, _("The use of source as mount point for "
|
||||
"propagation type flags is deprecated.\n"));
|
||||
mountpoint = device;
|
||||
}
|
||||
if (!convert_entry(mntbuf, mountpoint))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
/* skip device and type */
|
||||
vec[1] = default_match_pattern;
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, flags & MS_MAKE_FLAGS,
|
||||
opt_flags & MS_MAKE_FLAGS))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
return RULE_OK;
|
||||
|
||||
fail:
|
||||
return RULE_ERROR;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_move_mount(Profile &prof, int &count,
|
||||
unsigned int flags, unsigned int opt_flags)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
std::string typebuf;
|
||||
char flagsbuf[PATH_MAX + 3];
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
|
||||
sprintf(class_mount_hdr, "\\x%02x", AA_CLASS_MOUNT);
|
||||
|
||||
/* mount move rules can not be conditional on dev_type,
|
||||
* or data
|
||||
*/
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, flags & MS_MOVE_FLAGS,
|
||||
opt_flags & MS_MOVE_FLAGS))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
return RULE_OK;
|
||||
|
||||
fail:
|
||||
return RULE_ERROR;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_new_mount(Profile &prof, int &count,
|
||||
unsigned int flags, unsigned int opt_flags)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
std::string typebuf;
|
||||
char flagsbuf[PATH_MAX + 3];
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
int tmpallow;
|
||||
|
||||
sprintf(class_mount_hdr, "\\x%02x", AA_CLASS_MOUNT);
|
||||
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
typebuf.clear();
|
||||
if (!build_list_val_expr(typebuf, dev_type))
|
||||
goto fail;
|
||||
vec[2] = typebuf.c_str();
|
||||
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, flags & MS_NEW_FLAGS,
|
||||
opt_flags & MS_NEW_FLAGS))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
|
||||
if (opts)
|
||||
tmpallow = AA_MATCH_CONT;
|
||||
else
|
||||
tmpallow = allow;
|
||||
|
||||
/* rule for match without required data || data MATCH_CONT */
|
||||
if (!prof.policy.rules->add_rule_vec(deny, tmpallow,
|
||||
audit | AA_AUDIT_MNT_DATA, 4,
|
||||
vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
if (opts) {
|
||||
/* rule with data match required */
|
||||
optsbuf.clear();
|
||||
if (!build_mnt_opts(optsbuf, opts))
|
||||
goto fail;
|
||||
vec[4] = optsbuf.c_str();
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow,
|
||||
audit | AA_AUDIT_MNT_DATA,
|
||||
5, vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
|
||||
return RULE_OK;
|
||||
|
||||
fail:
|
||||
return RULE_ERROR;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_flag_rules(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags)
|
||||
{
|
||||
/*
|
||||
* XXX: added !flags to cover cases like:
|
||||
* mount options in (bind) /d -> /4,
|
||||
*/
|
||||
if ((allow & AA_MAY_MOUNT) && (!flags || flags == MS_ALL_FLAGS)) {
|
||||
/* no mount flags specified, generate multiple rules */
|
||||
if (!device && !dev_type &&
|
||||
gen_policy_remount(prof, count, flags, opt_flags) == RULE_ERROR)
|
||||
return RULE_ERROR;
|
||||
if (!dev_type && !opts &&
|
||||
gen_policy_bind_mount(prof, count, flags, opt_flags) == RULE_ERROR)
|
||||
return RULE_ERROR;
|
||||
if (!dev_type && !opts &&
|
||||
gen_policy_change_mount_type(prof, count, flags, opt_flags) == RULE_ERROR)
|
||||
return RULE_ERROR;
|
||||
if (!dev_type && !opts &&
|
||||
gen_policy_move_mount(prof, count, flags, opt_flags) == RULE_ERROR)
|
||||
return RULE_ERROR;
|
||||
|
||||
return gen_policy_new_mount(prof, count, flags, opt_flags);
|
||||
} else if ((allow & AA_MAY_MOUNT) && (flags & MS_REMOUNT)
|
||||
&& !device && !dev_type) {
|
||||
return gen_policy_remount(prof, count, flags, opt_flags);
|
||||
} else if ((allow & AA_MAY_MOUNT) && (flags & MS_BIND)
|
||||
&& !dev_type && !opts) {
|
||||
return gen_policy_bind_mount(prof, count, flags, opt_flags);
|
||||
} else if ((allow & AA_MAY_MOUNT) &&
|
||||
(flags & (MS_MAKE_CMDS))
|
||||
&& !dev_type && !opts) {
|
||||
return gen_policy_change_mount_type(prof, count, flags, opt_flags);
|
||||
} else if ((allow & AA_MAY_MOUNT) && (flags & MS_MOVE)
|
||||
&& !dev_type && !opts) {
|
||||
return gen_policy_move_mount(prof, count, flags, opt_flags);
|
||||
} else if ((allow & AA_MAY_MOUNT) &&
|
||||
((flags | opt_flags) & ~MS_CMDS)) {
|
||||
/* generic mount if flags are set that are not covered by
|
||||
* above commands
|
||||
*/
|
||||
return gen_policy_new_mount(prof, count, flags, opt_flags);
|
||||
} /* else must be RULE_OK for some rules */
|
||||
|
||||
return RULE_OK;
|
||||
}
|
||||
|
||||
int mnt_rule::gen_policy_re(Profile &prof)
|
||||
{
|
||||
std::string mntbuf;
|
||||
std::string devbuf;
|
||||
std::string typebuf;
|
||||
std::string optsbuf;
|
||||
char class_mount_hdr[64];
|
||||
const char *vec[5];
|
||||
int count = 0;
|
||||
unsigned int tmpflags, tmpinv_flags;
|
||||
|
||||
if (!features_supports_mount) {
|
||||
warn_once(prof.name);
|
||||
@@ -605,202 +1036,10 @@ int mnt_rule::gen_policy_re(Profile &prof)
|
||||
/* a single mount rule may result in multiple matching rules being
|
||||
* created in the backend to cover all the possible choices
|
||||
*/
|
||||
|
||||
if ((allow & AA_MAY_MOUNT) && (flags & MS_REMOUNT)
|
||||
&& !device && !dev_type) {
|
||||
int tmpallow;
|
||||
/* remount can't be conditional on device and type */
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (mnt_point) {
|
||||
/* both device && mnt_point or just mnt_point */
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
for (size_t i = 0; i < flagsv.size(); i++) {
|
||||
for (size_t j = 0; j < opt_flagsv.size(); j++) {
|
||||
if (gen_flag_rules(prof, count, flagsv[i], opt_flagsv[j]) == RULE_ERROR)
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
} else {
|
||||
if (!convert_entry(mntbuf, device))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
}
|
||||
/* skip device */
|
||||
vec[1] = default_match_pattern;
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
tmpflags = flags;
|
||||
tmpinv_flags = inv_flags;
|
||||
if (tmpflags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_REMOUNT_FLAGS;
|
||||
if (tmpinv_flags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_REMOUNT_FLAGS;
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, tmpflags, tmpinv_flags))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
|
||||
if (opts)
|
||||
tmpallow = AA_MATCH_CONT;
|
||||
else
|
||||
tmpallow = allow;
|
||||
|
||||
/* rule for match without required data || data MATCH_CONT */
|
||||
if (!prof.policy.rules->add_rule_vec(deny, tmpallow,
|
||||
audit | AA_AUDIT_MNT_DATA, 4,
|
||||
vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
if (opts) {
|
||||
/* rule with data match required */
|
||||
optsbuf.clear();
|
||||
if (!build_mnt_opts(optsbuf, opts))
|
||||
goto fail;
|
||||
vec[4] = optsbuf.c_str();
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow,
|
||||
audit | AA_AUDIT_MNT_DATA,
|
||||
5, vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if ((allow & AA_MAY_MOUNT) && (flags & MS_BIND)
|
||||
&& !dev_type && !opts) {
|
||||
/* bind mount rules can't be conditional on dev_type or data */
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
tmpflags = flags;
|
||||
tmpinv_flags = inv_flags;
|
||||
if (tmpflags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_BIND_FLAGS;
|
||||
if (tmpinv_flags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_BIND_FLAGS;
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, tmpflags, tmpinv_flags))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
if ((allow & AA_MAY_MOUNT) &&
|
||||
(flags & (MS_UNBINDABLE | MS_PRIVATE | MS_SLAVE | MS_SHARED))
|
||||
&& !device && !dev_type && !opts) {
|
||||
/* change type base rules can not be conditional on device,
|
||||
* device type or data
|
||||
*/
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
/* skip device and type */
|
||||
vec[1] = default_match_pattern;
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
tmpflags = flags;
|
||||
tmpinv_flags = inv_flags;
|
||||
if (tmpflags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_MAKE_FLAGS;
|
||||
if (tmpinv_flags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_MAKE_FLAGS;
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, tmpflags, tmpinv_flags))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
if ((allow & AA_MAY_MOUNT) && (flags & MS_MOVE)
|
||||
&& !dev_type && !opts) {
|
||||
/* mount move rules can not be conditional on dev_type,
|
||||
* or data
|
||||
*/
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
/* skip type */
|
||||
vec[2] = default_match_pattern;
|
||||
|
||||
tmpflags = flags;
|
||||
tmpinv_flags = inv_flags;
|
||||
if (tmpflags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_MOVE_FLAGS;
|
||||
if (tmpinv_flags != MS_ALL_FLAGS)
|
||||
tmpflags &= MS_MOVE_FLAGS;
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, tmpflags, tmpinv_flags))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow, audit, 4, vec,
|
||||
dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
if ((allow & AA_MAY_MOUNT) &&
|
||||
(flags | inv_flags) & ~MS_CMDS) {
|
||||
int tmpallow;
|
||||
/* generic mount if flags are set that are not covered by
|
||||
* above commands
|
||||
*/
|
||||
/* rule class single byte header */
|
||||
mntbuf.assign(class_mount_hdr);
|
||||
if (!convert_entry(mntbuf, mnt_point))
|
||||
goto fail;
|
||||
vec[0] = mntbuf.c_str();
|
||||
if (!clear_and_convert_entry(devbuf, device))
|
||||
goto fail;
|
||||
vec[1] = devbuf.c_str();
|
||||
typebuf.clear();
|
||||
if (!build_list_val_expr(typebuf, dev_type))
|
||||
goto fail;
|
||||
vec[2] = typebuf.c_str();
|
||||
|
||||
tmpflags = flags;
|
||||
tmpinv_flags = inv_flags;
|
||||
if (tmpflags != MS_ALL_FLAGS)
|
||||
tmpflags &= ~MS_CMDS;
|
||||
if (tmpinv_flags != MS_ALL_FLAGS)
|
||||
tmpinv_flags &= ~MS_CMDS;
|
||||
if (!build_mnt_flags(flagsbuf, PATH_MAX, tmpflags, tmpinv_flags))
|
||||
goto fail;
|
||||
vec[3] = flagsbuf;
|
||||
|
||||
if (opts)
|
||||
tmpallow = AA_MATCH_CONT;
|
||||
else
|
||||
tmpallow = allow;
|
||||
|
||||
/* rule for match without required data || data MATCH_CONT */
|
||||
if (!prof.policy.rules->add_rule_vec(deny, tmpallow,
|
||||
audit | AA_AUDIT_MNT_DATA, 4,
|
||||
vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
|
||||
if (opts) {
|
||||
/* rule with data match required */
|
||||
optsbuf.clear();
|
||||
if (!build_mnt_opts(optsbuf, opts))
|
||||
goto fail;
|
||||
vec[4] = optsbuf.c_str();
|
||||
if (!prof.policy.rules->add_rule_vec(deny, allow,
|
||||
audit | AA_AUDIT_MNT_DATA,
|
||||
5, vec, dfaflags, false))
|
||||
goto fail;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (allow & AA_MAY_UMOUNT) {
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#define __AA_MOUNT_H
|
||||
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
#include "parser.h"
|
||||
#include "rule.h"
|
||||
@@ -39,6 +40,8 @@
|
||||
#define MS_MAND (1 << 6)
|
||||
#define MS_NOMAND 0
|
||||
#define MS_DIRSYNC (1 << 7)
|
||||
#define MS_SYMFOLLOW 0
|
||||
#define MS_NOSYMFOLLOW (1 << 8)
|
||||
#define MS_NODIRSYNC 0
|
||||
#define MS_NOATIME (1 << 10)
|
||||
#define MS_ATIME 0
|
||||
@@ -61,6 +64,7 @@
|
||||
#define MS_IVERSION (1 << 23)
|
||||
#define MS_NOIVERSION 0
|
||||
#define MS_STRICTATIME (1 << 24)
|
||||
#define MS_LAZYTIME (1 << 25)
|
||||
#define MS_NOUSER (1 << 31)
|
||||
#define MS_USER 0
|
||||
|
||||
@@ -74,12 +78,14 @@
|
||||
|
||||
#define MS_ALL_FLAGS (MS_RDONLY | MS_NOSUID | MS_NODEV | MS_NOEXEC | \
|
||||
MS_SYNC | MS_REMOUNT | MS_MAND | MS_DIRSYNC | \
|
||||
MS_NOSYMFOLLOW | \
|
||||
MS_NOATIME | MS_NODIRATIME | MS_BIND | MS_RBIND | \
|
||||
MS_MOVE | MS_VERBOSE | MS_ACL | \
|
||||
MS_UNBINDABLE | MS_RUNBINDABLE | \
|
||||
MS_PRIVATE | MS_RPRIVATE | \
|
||||
MS_SLAVE | MS_RSLAVE | MS_SHARED | MS_RSHARED | \
|
||||
MS_RELATIME | MS_IVERSION | MS_STRICTATIME | MS_USER)
|
||||
MS_RELATIME | MS_IVERSION | MS_STRICTATIME | \
|
||||
MS_LAZYTIME | MS_USER)
|
||||
|
||||
/* set of flags we don't use but define (but not with the kernel values)
|
||||
* for MNT_FLAGS
|
||||
@@ -94,16 +100,15 @@
|
||||
MS_KERNMOUNT | MS_STRICTATIME)
|
||||
|
||||
#define MS_BIND_FLAGS (MS_BIND | MS_RBIND)
|
||||
#define MS_MAKE_FLAGS ((MS_UNBINDABLE | MS_RUNBINDABLE | \
|
||||
#define MS_MAKE_CMDS (MS_UNBINDABLE | MS_RUNBINDABLE | \
|
||||
MS_PRIVATE | MS_RPRIVATE | \
|
||||
MS_SLAVE | MS_RSLAVE | MS_SHARED | MS_RSHARED) | \
|
||||
(MS_ALL_FLAGS & ~(MNT_FLAGS)))
|
||||
MS_SLAVE | MS_RSLAVE | MS_SHARED | MS_RSHARED)
|
||||
#define MS_MAKE_FLAGS (MS_ALL_FLAGS & ~(MNT_FLAGS))
|
||||
#define MS_MOVE_FLAGS (MS_MOVE)
|
||||
|
||||
#define MS_CMDS (MS_MOVE | MS_REMOUNT | MS_BIND | MS_RBIND | \
|
||||
MS_UNBINDABLE | MS_RUNBINDABLE | MS_PRIVATE | MS_RPRIVATE | \
|
||||
MS_SLAVE | MS_RSLAVE | MS_SHARED | MS_RSHARED)
|
||||
#define MS_CMDS (MS_MOVE | MS_REMOUNT | MS_BIND | MS_RBIND | MS_MAKE_CMDS)
|
||||
#define MS_REMOUNT_FLAGS (MS_ALL_FLAGS & ~(MS_CMDS & ~MS_REMOUNT & ~MS_BIND & ~MS_RBIND))
|
||||
#define MS_NEW_FLAGS (MS_ALL_FLAGS & ~MS_CMDS)
|
||||
|
||||
#define MNT_SRC_OPT 1
|
||||
#define MNT_DST_OPT 2
|
||||
@@ -121,6 +126,19 @@
|
||||
|
||||
|
||||
class mnt_rule: public rule_t {
|
||||
int gen_policy_remount(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
int gen_policy_bind_mount(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
int gen_policy_change_mount_type(Profile &prof, int &count,
|
||||
unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
int gen_policy_move_mount(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
int gen_policy_new_mount(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
int gen_flag_rules(Profile &prof, int &count, unsigned int flags,
|
||||
unsigned int opt_flags);
|
||||
public:
|
||||
char *mnt_point;
|
||||
char *device;
|
||||
@@ -128,7 +146,7 @@ public:
|
||||
struct value_list *dev_type;
|
||||
struct value_list *opts;
|
||||
|
||||
unsigned int flags, inv_flags;
|
||||
std::vector<unsigned int> flagsv, opt_flagsv;
|
||||
|
||||
int allow, audit;
|
||||
int deny;
|
||||
|
@@ -66,10 +66,12 @@ extern int parser_token;
|
||||
#define WARN_FORMAT 0x400
|
||||
#define WARN_MISSING 0x800
|
||||
#define WARN_OVERRIDE 0x1000
|
||||
#define WARN_INCLUDE 0x2000
|
||||
|
||||
#define WARN_DEV (WARN_RULE_NOT_ENFORCED | WARN_RULE_DOWNGRADED | WARN_ABI | \
|
||||
WARN_DEPRECATED | WARN_DANGEROUS | WARN_UNEXPECTED | \
|
||||
WARN_FORMAT | WARN_MISSING | WARN_OVERRIDE | WARN_DEBUG_CACHE)
|
||||
WARN_FORMAT | WARN_MISSING | WARN_OVERRIDE | \
|
||||
WARN_DEBUG_CACHE | WARN_INCLUDE)
|
||||
|
||||
#define DEFAULT_WARNINGS (WARN_CONFIG | WARN_CACHE | WARN_JOBS | \
|
||||
WARN_UNEXPECTED | WARN_OVERRIDE)
|
||||
@@ -77,7 +79,8 @@ extern int parser_token;
|
||||
#define WARN_ALL (WARN_RULE_NOT_ENFORCED | WARN_RULE_DOWNGRADED | WARN_ABI | \
|
||||
WARN_DEPRECATED | WARN_CONFIG | WARN_CACHE | \
|
||||
WARN_DEBUG_CACHE | WARN_JOBS | WARN_DANGEROUS | \
|
||||
WARN_UNEXPECTED | WARN_FORMAT | WARN_MISSING | WARN_OVERRIDE)
|
||||
WARN_UNEXPECTED | WARN_FORMAT | WARN_MISSING | \
|
||||
WARN_OVERRIDE | WARN_INCLUDE)
|
||||
|
||||
extern dfaflags_t warnflags;
|
||||
extern dfaflags_t werrflags;
|
||||
@@ -229,6 +232,7 @@ do { \
|
||||
#endif
|
||||
|
||||
|
||||
#define list_first(LIST) (LIST)
|
||||
#define list_for_each(LIST, ENTRY) \
|
||||
for ((ENTRY) = (LIST); (ENTRY); (ENTRY) = (ENTRY)->next)
|
||||
#define list_for_each_safe(LIST, ENTRY, TMP) \
|
||||
@@ -262,6 +266,16 @@ do { \
|
||||
prev; \
|
||||
})
|
||||
|
||||
#define list_pop(LIST) \
|
||||
({ \
|
||||
typeof(LIST) _entry = (LIST); \
|
||||
if (LIST) { \
|
||||
(LIST) = (LIST)->next; \
|
||||
_entry->next = NULL; \
|
||||
} \
|
||||
_entry; \
|
||||
})
|
||||
|
||||
#define list_remove_at(LIST, PREV, ENTRY) \
|
||||
if (PREV) \
|
||||
(PREV)->next = (ENTRY)->next; \
|
||||
|
@@ -165,6 +165,7 @@ FILE *search_path(char *filename, char **fullpath, bool *skip)
|
||||
if (g_includecache->find(buf)) {
|
||||
/* hit do not want to re-include */
|
||||
*skip = true;
|
||||
free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@@ -167,10 +167,10 @@ void include_filename(char *filename, int search, bool if_exists)
|
||||
include_file = search_path(filename, &fullpath, &cached);
|
||||
if (!include_file && cached) {
|
||||
goto skip;
|
||||
} else if (preprocess_only) {
|
||||
fprintf(yyout, "\n\n##included <%s>\n", filename);
|
||||
} else if (!include_file && preprocess_only) {
|
||||
fprintf(yyout, "\n\n##failed include <%s>\n", filename);
|
||||
} else if (preprocess_only) {
|
||||
fprintf(yyout, "\n\n##included <%s>\n", filename);
|
||||
}
|
||||
|
||||
} else if (g_includecache->find(filename)) {
|
||||
@@ -613,6 +613,7 @@ GT >
|
||||
/* Don't use PUSH() macro here as we don't want #include echoed out.
|
||||
* It needs to be handled specially
|
||||
*/
|
||||
pwarn(WARN_INCLUDE, _("deprecated use of '#include'\n"));
|
||||
yy_push_state(INCLUDE_EXISTS);
|
||||
}
|
||||
|
||||
@@ -627,6 +628,7 @@ include{WS}+if{WS}+exists/{WS} {
|
||||
/* Don't use PUSH() macro here as we don't want #include echoed out.
|
||||
* It needs to be handled specially
|
||||
*/
|
||||
pwarn(WARN_INCLUDE, _("deprecated use of '#include'\n"));
|
||||
yy_push_state(INCLUDE);
|
||||
}
|
||||
|
||||
|
@@ -269,6 +269,7 @@ optflag_table_t warnflag_table[] = {
|
||||
{ 1, "missing", "warn when missing qualifier and a default is used", WARN_MISSING },
|
||||
{ 1, "override", "warn when overriding", WARN_OVERRIDE },
|
||||
{ 1, "dev", "turn on warnings that are useful for profile development", WARN_DEV },
|
||||
{ 1, "pound-include", "warn when #include is used", WARN_INCLUDE },
|
||||
{ 1, "all", "turn on all warnings", WARN_ALL},
|
||||
{ 0, NULL, NULL, 0 },
|
||||
};
|
||||
@@ -1145,7 +1146,7 @@ int process_profile(int option, aa_kernel_interface *kernel_interface,
|
||||
retval = process_binary(option, kernel_interface,
|
||||
cachename);
|
||||
if (!retval || skip_bad_cache_rebuild)
|
||||
return retval;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1208,7 +1209,8 @@ int process_profile(int option, aa_kernel_interface *kernel_interface,
|
||||
}
|
||||
}
|
||||
out:
|
||||
|
||||
/* cleanup */
|
||||
reset_parser(profilename);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1695,6 +1697,7 @@ int main(int argc, char *argv[])
|
||||
if (ofile)
|
||||
fclose(ofile);
|
||||
aa_policy_cache_unref(policy_cache);
|
||||
aa_kernel_interface_unref(kernel_interface);
|
||||
|
||||
return last_error;
|
||||
}
|
||||
|
@@ -486,13 +486,18 @@ static int process_profile_name_xmatch(Profile *prof)
|
||||
&prof->xmatch_len);
|
||||
if (ptype == ePatternBasic)
|
||||
prof->xmatch_len = strlen(name);
|
||||
if (!prof->attachment)
|
||||
free(name);
|
||||
|
||||
if (ptype == ePatternInvalid) {
|
||||
PERROR(_("%s: Invalid profile name '%s' - bad regular expression\n"), progname, name);
|
||||
if (!prof->attachment)
|
||||
free(name);
|
||||
return FALSE;
|
||||
} else if (ptype == ePatternBasic && !(prof->altnames || prof->attachment || prof->xattrs.list)) {
|
||||
}
|
||||
|
||||
if (!prof->attachment)
|
||||
free(name);
|
||||
|
||||
if (ptype == ePatternBasic && !(prof->altnames || prof->attachment || prof->xattrs.list)) {
|
||||
/* no regex so do not set xmatch */
|
||||
prof->xmatch = NULL;
|
||||
prof->xmatch_len = 0;
|
||||
|
@@ -1773,7 +1773,7 @@ static int abi_features_base(struct aa_features **features, char *filename, bool
|
||||
{
|
||||
autofclose FILE *f = NULL;
|
||||
struct stat my_stat;
|
||||
char *fullpath = NULL;
|
||||
autofree char *fullpath = NULL;
|
||||
bool cached;
|
||||
|
||||
if (search) {
|
||||
|
@@ -15,13 +15,11 @@
|
||||
# - check cache not used if parser in $PATH is newer
|
||||
# - check cache used for force-complain, disable symlink, etc.
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import time
|
||||
import tempfile
|
||||
import unittest
|
||||
from argparse import ArgumentParser
|
||||
|
||||
import testlib
|
||||
|
||||
@@ -51,7 +49,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
||||
do_cleanup = True
|
||||
|
||||
def setUp(self):
|
||||
'''setup for each test'''
|
||||
"""setup for each test"""
|
||||
global config
|
||||
|
||||
# REPORT ALL THE OUTPUT
|
||||
@@ -89,7 +87,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
||||
self.cache_file = os.path.join(self.cache_dir, PROFILE)
|
||||
|
||||
def tearDown(self):
|
||||
'''teardown for each test'''
|
||||
"""teardown for each test"""
|
||||
|
||||
if not self.do_cleanup:
|
||||
print("\n===> Skipping cleanup, leaving testfiles behind in '%s'" % (self.tmp_dir))
|
||||
@@ -115,7 +113,7 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
||||
return cache_dir
|
||||
|
||||
def assert_path_exists(self, path, expected=True):
|
||||
if expected is True:
|
||||
if expected:
|
||||
self.assertTrue(os.path.exists(path),
|
||||
'test did not create file %s, when it was expected to do so' % path)
|
||||
else:
|
||||
@@ -138,20 +136,19 @@ class AAParserCachingCommon(testlib.AATestTemplate):
|
||||
with open(features_path) as f:
|
||||
features = f.read()
|
||||
if expected:
|
||||
self.assertEqual(expected_output, features,
|
||||
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
self.assertEqual(
|
||||
expected_output, features,
|
||||
"features contents differ, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
else:
|
||||
self.assertNotEqual(expected_output, features,
|
||||
"features contents equal, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
self.assertNotEqual(
|
||||
expected_output, features,
|
||||
"features contents equal, expected:\n%s\nresult:\n%s" % (expected_output, features))
|
||||
|
||||
|
||||
class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserBasicCachingTests, self).setUp()
|
||||
|
||||
def test_no_cache_by_default(self):
|
||||
'''test profiles are not cached by default'''
|
||||
"""test profiles are not cached by default"""
|
||||
|
||||
cmd = list(self.cmd_prefix)
|
||||
cmd.extend(('-q', '-r', self.profile))
|
||||
@@ -159,7 +156,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE), expected=False)
|
||||
|
||||
def test_no_cache_w_skip_cache(self):
|
||||
'''test profiles are not cached with --skip-cache'''
|
||||
"""test profiles are not cached with --skip-cache"""
|
||||
|
||||
cmd = list(self.cmd_prefix)
|
||||
cmd.extend(('-q', '--write-cache', '--skip-cache', '-r', self.profile))
|
||||
@@ -167,7 +164,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE), expected=False)
|
||||
|
||||
def test_cache_when_requested(self):
|
||||
'''test profiles are cached when requested'''
|
||||
"""test profiles are cached when requested"""
|
||||
|
||||
cmd = list(self.cmd_prefix)
|
||||
cmd.extend(('-q', '--write-cache', '-r', self.profile))
|
||||
@@ -175,7 +172,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(os.path.join(self.cache_dir, PROFILE))
|
||||
|
||||
def test_write_features_when_caching(self):
|
||||
'''test features file is written when caching'''
|
||||
"""test features file is written when caching"""
|
||||
|
||||
cmd = list(self.cmd_prefix)
|
||||
cmd.extend(('-q', '--write-cache', '-r', self.profile))
|
||||
@@ -184,7 +181,7 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(os.path.join(self.cache_dir, '.features'))
|
||||
|
||||
def test_features_match_when_caching(self):
|
||||
'''test features file is written when caching'''
|
||||
"""test features file is written when caching"""
|
||||
|
||||
self.require_apparmorfs()
|
||||
|
||||
@@ -198,10 +195,10 @@ class AAParserBasicCachingTests(AAParserCachingCommon):
|
||||
|
||||
|
||||
class AAParserAltCacheBasicTests(AAParserBasicCachingTests):
|
||||
'''Same tests as above, but with an alternate cache location specified on the command line'''
|
||||
"""Same tests as above, but with an alternate cache location specified on the command line"""
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserAltCacheBasicTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
alt_cache_loc = tempfile.mkdtemp(prefix='aa-alt-cache', dir=self.tmp_dir)
|
||||
os.chmod(alt_cache_loc, 0o755)
|
||||
@@ -211,34 +208,34 @@ class AAParserAltCacheBasicTests(AAParserBasicCachingTests):
|
||||
self.cache_dir = self.get_cache_dir()
|
||||
|
||||
def tearDown(self):
|
||||
if len(os.listdir(self.unused_cache_loc)) > 0:
|
||||
self.fail('original cache dir \'%s\' not empty' % self.unused_cache_loc)
|
||||
super(AAParserAltCacheBasicTests, self).tearDown()
|
||||
if os.listdir(self.unused_cache_loc):
|
||||
self.fail("original cache dir '%s' not empty" % self.unused_cache_loc)
|
||||
super().tearDown()
|
||||
|
||||
|
||||
class AAParserCreateCacheBasicTestsCacheExists(AAParserBasicCachingTests):
|
||||
'''Same tests as above, but with create cache option on the command line and the cache already exists'''
|
||||
"""Same tests as above, but with create cache option on the command line and the cache already exists"""
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserCreateCacheBasicTestsCacheExists, self).setUp()
|
||||
super().setUp()
|
||||
self.cmd_prefix.append('--create-cache-dir')
|
||||
|
||||
|
||||
class AAParserCreateCacheBasicTestsCacheNotExist(AAParserBasicCachingTests):
|
||||
'''Same tests as above, but with create cache option on the command line and cache dir removed'''
|
||||
"""Same tests as above, but with create cache option on the command line and cache dir removed"""
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserCreateCacheBasicTestsCacheNotExist, self).setUp()
|
||||
super().setUp()
|
||||
shutil.rmtree(self.cache_dir)
|
||||
self.cmd_prefix.append('--create-cache-dir')
|
||||
|
||||
|
||||
class AAParserCreateCacheAltCacheTestsCacheNotExist(AAParserBasicCachingTests):
|
||||
'''Same tests as above, but with create cache option on the command line,
|
||||
alt cache specified, and cache dir removed'''
|
||||
"""Same tests as above, but with create cache option on the command line,
|
||||
alt cache specified, and cache dir removed"""
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserCreateCacheAltCacheTestsCacheNotExist, self).setUp()
|
||||
super().setUp()
|
||||
shutil.rmtree(self.cache_dir)
|
||||
self.cmd_prefix.append('--create-cache-dir')
|
||||
|
||||
@@ -246,7 +243,7 @@ class AAParserCreateCacheAltCacheTestsCacheNotExist(AAParserBasicCachingTests):
|
||||
class AAParserCachingTests(AAParserCachingCommon):
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserCachingTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
r = testlib.filesystem_time_resolution()
|
||||
self.mtime_res = r[1]
|
||||
@@ -258,27 +255,13 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.run_cmd_check(cmd)
|
||||
self.assert_path_exists(self.cache_file)
|
||||
|
||||
def _assertTimeStampEquals(self, time1, time2):
|
||||
'''Compare two timestamps to ensure equality'''
|
||||
|
||||
# python 3.2 and earlier don't support writing timestamps with
|
||||
# nanosecond resolution, only microsecond. When comparing
|
||||
# timestamps in such an environment, loosen the equality bounds
|
||||
# to compensate
|
||||
# Reference: https://bugs.python.org/issue12904
|
||||
(major, minor, _) = platform.python_version_tuple()
|
||||
if (int(major) < 3) or ((int(major) == 3) and (int(minor) <= 2)):
|
||||
self.assertAlmostEquals(time1, time2, places=5)
|
||||
else:
|
||||
self.assertEqual(time1, time2)
|
||||
|
||||
def _set_mtime(self, path, mtime):
|
||||
atime = os.stat(path).st_atime
|
||||
os.utime(path, (atime, mtime))
|
||||
self._assertTimeStampEquals(os.stat(path).st_mtime, mtime)
|
||||
self.assertEqual(os.stat(path).st_mtime, mtime)
|
||||
|
||||
def test_cache_loaded_when_exists(self):
|
||||
'''test cache is loaded when it exists, is newer than profile, and features match'''
|
||||
"""test cache is loaded when it exists, is newer than profile, and features match"""
|
||||
|
||||
self._generate_cache_file()
|
||||
|
||||
@@ -287,7 +270,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.run_cmd_check(cmd, expected_string='Cached reload succeeded')
|
||||
|
||||
def test_cache_not_loaded_when_skip_arg(self):
|
||||
'''test cache is not loaded when --skip-cache is passed'''
|
||||
"""test cache is not loaded when --skip-cache is passed"""
|
||||
|
||||
self._generate_cache_file()
|
||||
|
||||
@@ -296,7 +279,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
|
||||
|
||||
def test_cache_not_loaded_when_skip_read_arg(self):
|
||||
'''test cache is not loaded when --skip-read-cache is passed'''
|
||||
"""test cache is not loaded when --skip-read-cache is passed"""
|
||||
|
||||
self._generate_cache_file()
|
||||
|
||||
@@ -305,7 +288,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
|
||||
|
||||
def test_cache_not_loaded_when_features_differ(self):
|
||||
'''test cache is not loaded when features file differs'''
|
||||
"""test cache is not loaded when features file differs"""
|
||||
|
||||
self._generate_cache_file()
|
||||
|
||||
@@ -316,7 +299,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.run_cmd_check(cmd, expected_string='Replacement succeeded for')
|
||||
|
||||
def test_cache_writing_does_not_overwrite_features_when_features_differ(self):
|
||||
'''test cache writing does not overwrite the features files when it differs and --skip-bad-cache is given'''
|
||||
"""test cache writing does not overwrite the features files when it differs and --skip-bad-cache is given"""
|
||||
|
||||
self.require_apparmorfs()
|
||||
|
||||
@@ -330,7 +313,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.compare_features_file(features_file, expected=False)
|
||||
|
||||
def test_cache_writing_skipped_when_features_differ(self):
|
||||
'''test cache writing is skipped when features file differs'''
|
||||
"""test cache writing is skipped when features file differs"""
|
||||
|
||||
testlib.write_file(self.cache_dir, '.features', 'monkey\n')
|
||||
|
||||
@@ -340,14 +323,14 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(self.cache_file, expected=False)
|
||||
|
||||
def test_cache_writing_collision_of_features(self):
|
||||
'''test cache writing collision of features'''
|
||||
"""test cache writing collision of features"""
|
||||
# cache dir with different features causes a collision resulting
|
||||
# in a new cache dir
|
||||
self.require_apparmorfs()
|
||||
|
||||
features_file = testlib.write_file(self.cache_dir, '.features', 'monkey\n')
|
||||
new_file = self.get_cache_dir()
|
||||
new_features_file = new_file + '/.features';
|
||||
new_features_file = new_file + '/.features'
|
||||
|
||||
cmd = list(self.cmd_prefix)
|
||||
cmd.extend(('-v', '--write-cache', '-r', self.profile))
|
||||
@@ -357,7 +340,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.compare_features_file(new_features_file)
|
||||
|
||||
def test_cache_writing_updates_cache_file(self):
|
||||
'''test cache writing updates cache file'''
|
||||
"""test cache writing updates cache file"""
|
||||
|
||||
cache_file = testlib.write_file(self.cache_dir, PROFILE, 'monkey\n')
|
||||
orig_stat = os.stat(cache_file)
|
||||
@@ -374,7 +357,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(os.stat(self.profile).st_mtime, stat.st_mtime)
|
||||
|
||||
def test_cache_writing_clears_all_files(self):
|
||||
'''test cache writing clears all cache files'''
|
||||
"""test cache writing clears all cache files"""
|
||||
|
||||
check_file = testlib.write_file(self.cache_dir, 'monkey', 'monkey\n')
|
||||
|
||||
@@ -384,7 +367,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(check_file, expected=False)
|
||||
|
||||
def test_profile_mtime_preserved(self):
|
||||
'''test profile mtime is preserved when it is newest'''
|
||||
"""test profile mtime is preserved when it is newest"""
|
||||
expected = 1
|
||||
self._set_mtime(self.abstraction, 0)
|
||||
self._set_mtime(self.profile, expected)
|
||||
@@ -392,7 +375,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
|
||||
|
||||
def test_abstraction_mtime_preserved(self):
|
||||
'''test abstraction mtime is preserved when it is newest'''
|
||||
"""test abstraction mtime is preserved when it is newest"""
|
||||
expected = 1000
|
||||
self._set_mtime(self.profile, 0)
|
||||
self._set_mtime(self.abstraction, expected)
|
||||
@@ -400,7 +383,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
|
||||
|
||||
def test_equal_mtimes_preserved(self):
|
||||
'''test equal profile and abstraction mtimes are preserved'''
|
||||
"""test equal profile and abstraction mtimes are preserved"""
|
||||
expected = 10000 + self.mtime_res
|
||||
self._set_mtime(self.profile, expected)
|
||||
self._set_mtime(self.abstraction, expected)
|
||||
@@ -408,7 +391,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(expected, os.stat(self.cache_file).st_mtime)
|
||||
|
||||
def test_profile_newer_skips_cache(self):
|
||||
'''test cache is skipped if profile is newer'''
|
||||
"""test cache is skipped if profile is newer"""
|
||||
|
||||
self._generate_cache_file()
|
||||
profile_mtime = os.stat(self.cache_file).st_mtime + self.mtime_res
|
||||
@@ -426,7 +409,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
|
||||
|
||||
def test_abstraction_newer_skips_cache(self):
|
||||
'''test cache is skipped if abstraction is newer'''
|
||||
"""test cache is skipped if abstraction is newer"""
|
||||
|
||||
self._generate_cache_file()
|
||||
abstraction_mtime = os.stat(self.cache_file).st_mtime + self.mtime_res
|
||||
@@ -444,7 +427,7 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assertEqual(orig_stat.st_mtime, stat.st_mtime)
|
||||
|
||||
def test_profile_newer_rewrites_cache(self):
|
||||
'''test cache is rewritten if profile is newer'''
|
||||
"""test cache is rewritten if profile is newer"""
|
||||
|
||||
self._generate_cache_file()
|
||||
profile_mtime = os.stat(self.cache_file).st_mtime + self.mtime_res
|
||||
@@ -458,10 +441,10 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
|
||||
stat = os.stat(self.cache_file)
|
||||
self.assertNotEqual(orig_stat.st_ino, stat.st_ino)
|
||||
self._assertTimeStampEquals(profile_mtime, stat.st_mtime)
|
||||
self.assertEqual(profile_mtime, stat.st_mtime)
|
||||
|
||||
def test_abstraction_newer_rewrites_cache(self):
|
||||
'''test cache is rewritten if abstraction is newer'''
|
||||
"""test cache is rewritten if abstraction is newer"""
|
||||
|
||||
self._generate_cache_file()
|
||||
abstraction_mtime = os.stat(self.cache_file).st_mtime + self.mtime_res
|
||||
@@ -475,10 +458,10 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
|
||||
stat = os.stat(self.cache_file)
|
||||
self.assertNotEqual(orig_stat.st_ino, stat.st_ino)
|
||||
self._assertTimeStampEquals(abstraction_mtime, stat.st_mtime)
|
||||
self.assertEqual(abstraction_mtime, stat.st_mtime)
|
||||
|
||||
def test_parser_newer_uses_cache(self):
|
||||
'''test cache is not skipped if parser is newer'''
|
||||
"""test cache is not skipped if parser is newer"""
|
||||
|
||||
self._generate_cache_file()
|
||||
|
||||
@@ -504,24 +487,24 @@ class AAParserCachingTests(AAParserCachingCommon):
|
||||
self.assert_path_exists(cache_file, expected=False)
|
||||
|
||||
def test_cache_purge_removes_features_file(self):
|
||||
'''test cache --purge-cache removes .features file'''
|
||||
"""test cache --purge-cache removes .features file"""
|
||||
self._purge_cache_test('.features')
|
||||
|
||||
def test_cache_purge_removes_cache_file(self):
|
||||
'''test cache --purge-cache removes profile cache file'''
|
||||
"""test cache --purge-cache removes profile cache file"""
|
||||
self._purge_cache_test(PROFILE)
|
||||
|
||||
def test_cache_purge_removes_other_cache_files(self):
|
||||
'''test cache --purge-cache removes other cache files'''
|
||||
"""test cache --purge-cache removes other cache files"""
|
||||
self._purge_cache_test('monkey')
|
||||
|
||||
|
||||
class AAParserAltCacheTests(AAParserCachingTests):
|
||||
'''Same tests as above, but with an alternate cache location specified on the command line'''
|
||||
"""Same tests as above, but with an alternate cache location specified on the command line"""
|
||||
check_orig_cache = True
|
||||
|
||||
def setUp(self):
|
||||
super(AAParserAltCacheTests, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
alt_cache_loc = tempfile.mkdtemp(prefix='aa-alt-cache', dir=self.tmp_dir)
|
||||
os.chmod(alt_cache_loc, 0o755)
|
||||
@@ -532,12 +515,12 @@ class AAParserAltCacheTests(AAParserCachingTests):
|
||||
self.cache_file = os.path.join(self.cache_dir, PROFILE)
|
||||
|
||||
def tearDown(self):
|
||||
if self.check_orig_cache and len(os.listdir(self.orig_cache_dir)) > 0:
|
||||
self.fail('original cache dir \'%s\' not empty' % self.orig_cache_dir)
|
||||
super(AAParserAltCacheTests, self).tearDown()
|
||||
if self.check_orig_cache and os.listdir(self.orig_cache_dir):
|
||||
self.fail("original cache dir '%s' not empty" % self.orig_cache_dir)
|
||||
super().tearDown()
|
||||
|
||||
def test_cache_purge_leaves_original_cache_alone(self):
|
||||
'''test cache purging only touches alt cache'''
|
||||
"""test cache purging only touches alt cache"""
|
||||
|
||||
# skip tearDown check to ensure non-alt cache is empty
|
||||
self.check_orig_cache = False
|
||||
@@ -583,6 +566,7 @@ def main():
|
||||
|
||||
return rc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
rc = main()
|
||||
exit(rc)
|
||||
|
@@ -31,8 +31,9 @@ do_tst() {
|
||||
shift 2
|
||||
#global tmpdir
|
||||
|
||||
${APPARMOR_PARSER} "$@" > "$tmpdir/out" 2>/dev/null
|
||||
${APPARMOR_PARSER} "$@" > "$tmpdir/out.unsorted" 2>/dev/null
|
||||
rc=$?
|
||||
LC_ALL=C sort "$tmpdir/out.unsorted" > "$tmpdir/out"
|
||||
if [ $rc -ne 0 ] && [ "$expected" != "fail" ] ; then
|
||||
echo "failed: expected \"$expected\" but parser returned error"
|
||||
return 1
|
||||
|
@@ -1,3 +1,3 @@
|
||||
good_target
|
||||
a_profile
|
||||
b_profile
|
||||
good_target
|
||||
|
@@ -13,14 +13,15 @@
|
||||
#
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
import unittest
|
||||
import subprocess
|
||||
import unittest
|
||||
from argparse import ArgumentParser
|
||||
|
||||
import testlib
|
||||
|
||||
config = None
|
||||
|
||||
|
||||
class AAErrorTests(testlib.AATestTemplate):
|
||||
def setUp(self):
|
||||
self.maxDiff = None
|
||||
|
@@ -18,7 +18,8 @@
|
||||
|
||||
from testlib import write_file
|
||||
|
||||
def get_rule (quantifier, perms, session, name, path, interface, member, peer):
|
||||
|
||||
def get_rule(quantifier, perms, session, name, path, interface, member, peer):
|
||||
|
||||
result = ' '
|
||||
|
||||
@@ -30,6 +31,7 @@ def get_rule (quantifier, perms, session, name, path, interface, member, peer):
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def gen_file(test, xres, quantifier, perms, session, name, path, interface, member, peer):
|
||||
global count
|
||||
|
||||
@@ -46,7 +48,8 @@ def gen_file(test, xres, quantifier, perms, session, name, path, interface, memb
|
||||
|
||||
count += 1
|
||||
|
||||
def gen_files (test, xres, quantifiers, perms, sessions, names, paths, interfaces, members, peers):
|
||||
|
||||
def gen_files(test, xres, quantifiers, perms, sessions, names, paths, interfaces, members, peers):
|
||||
for quantifier in quantifiers:
|
||||
for perm in perms:
|
||||
for session in sessions:
|
||||
@@ -57,7 +60,8 @@ def gen_files (test, xres, quantifiers, perms, sessions, names, paths, interface
|
||||
for peer in peers:
|
||||
gen_file(test, xres, quantifier, perm, session, name, path, interface, member, peer)
|
||||
|
||||
count=0
|
||||
|
||||
count = 0
|
||||
|
||||
quantifier = ('', 'deny', 'audit')
|
||||
session = ('', 'bus=session', 'bus=system', 'bus=accessibility')
|
||||
@@ -109,12 +113,12 @@ gen_files('service-rules', 'PASS', quantifier, ['bind'], session,
|
||||
gen_files('eavesdrop-rules', 'PASS', quantifier, ['eavesdrop'], session,
|
||||
empty_tup, empty_tup, empty_tup, empty_tup, empty_tup)
|
||||
gen_file('sloppy-formatting', 'PASS', '', '(send , receive )', 'bus=session',
|
||||
'', 'path ="/foo/bar"', 'interface = com.foo', ' member=bar',
|
||||
'peer =( label= /usr/bin/app name ="com.foo")')
|
||||
'', 'path ="/foo/bar"', 'interface = com.foo', ' member=bar',
|
||||
'peer =( label= /usr/bin/app name ="com.foo")')
|
||||
gen_file('sloppy-formatting', 'PASS', '', 'bind', 'bus =session',
|
||||
'name= com.foo', '', '', '', '')
|
||||
'name= com.foo', '', '', '', '')
|
||||
gen_file('sloppy-formatting', 'PASS', '', 'eavesdrop', 'bus = system',
|
||||
'', '', '', '', '')
|
||||
'', '', '', '', '')
|
||||
|
||||
# Don't use the empty element from each array since all empty conditionals would PASS but we want all FAILs
|
||||
msg_perms.remove('')
|
||||
|
@@ -27,7 +27,7 @@ trans_modifiers = {
|
||||
|
||||
targets = ("", "target", "target2")
|
||||
# null_target uses "_" instead of "" because "" gets skipped in some for loops. Replace with "" when actually using the value.
|
||||
null_target = ("_")
|
||||
null_target = ("_",)
|
||||
|
||||
named_trans = {
|
||||
"p": targets,
|
||||
@@ -60,6 +60,7 @@ qualifiers = ("", "owner")
|
||||
|
||||
count = 0
|
||||
|
||||
|
||||
def gen_list():
|
||||
output = []
|
||||
for trans in trans_types:
|
||||
@@ -71,8 +72,9 @@ def gen_list():
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def test_gen_list():
|
||||
''' test if gen_list returns the expected output '''
|
||||
"""test if gen_list returns the expected output"""
|
||||
|
||||
expected = "pix pux px Pix Pux Px cix cux cx Cix Cux Cx ux ix".split()
|
||||
actual = gen_list()
|
||||
@@ -80,6 +82,7 @@ def test_gen_list():
|
||||
if actual != expected:
|
||||
raise Exception("gen_list produced unexpected result, expected %s, got %s" % (expected, actual))
|
||||
|
||||
|
||||
def build_rule(leading, qual, name, perm, target):
|
||||
rule = ''
|
||||
|
||||
@@ -88,14 +91,15 @@ def build_rule(leading, qual, name, perm, target):
|
||||
else:
|
||||
rule += "\t%s %s %s" % (qual, name, perm)
|
||||
|
||||
if target != "":
|
||||
if target:
|
||||
rule += " -> %s" % target
|
||||
|
||||
rule += ",\n"
|
||||
|
||||
return rule
|
||||
|
||||
def gen_file (name, xres, leading1, qual1, rule1, perm1, target1, leading2, qual2, rule2, perm2, target2):
|
||||
|
||||
def gen_file(name, xres, leading1, qual1, rule1, perm1, target1, leading2, qual2, rule2, perm2, target2):
|
||||
global count
|
||||
count += 1
|
||||
|
||||
@@ -144,23 +148,27 @@ def gen_files(name, rule1, rule2, default):
|
||||
|
||||
gen_file(file, xres, 0, q, rule1, i, t, 0, r, rule2, j, u)
|
||||
|
||||
|
||||
def gen_conflicting_x():
|
||||
gen_files("conflict", "/bin/cat", "/bin/cat", "FAIL")
|
||||
|
||||
|
||||
def gen_overlap_re_exact():
|
||||
gen_files("exact", "/bin/cat", "/bin/*", "PASS")
|
||||
|
||||
|
||||
# we currently don't support this, once supported change to "PASS"
|
||||
def gen_dominate_re_re():
|
||||
gen_files("dominate", "/bin/*", "/bin/**", "FAIL")
|
||||
|
||||
|
||||
def gen_ambiguous_re_re():
|
||||
gen_files("ambiguous", "/bin/a*", "/bin/*b", "FAIL")
|
||||
|
||||
|
||||
# test that rules that lead with permissions don't conflict with
|
||||
# the same rule using trailing permissions.
|
||||
def gen_leading_perms (name, rule1, rule2):
|
||||
def gen_leading_perms(name, rule1, rule2):
|
||||
perms = gen_list()
|
||||
|
||||
for i in perms:
|
||||
@@ -171,6 +179,7 @@ def gen_leading_perms (name, rule1, rule2):
|
||||
file = prefix_leading + '/' + name + '-' + q + i + t + ".sd"
|
||||
gen_file(file, "PASS", 0, q, rule1, i, t, 1, q, rule2, i, t)
|
||||
|
||||
|
||||
# test for rules with leading safe or unsafe keywords.
|
||||
# check they are equivalent to their counterpart,
|
||||
# or if $invert that they properly conflict with their counterpart
|
||||
@@ -216,4 +225,4 @@ gen_safe_perms("overlap", "PASS", "inv", "/*", "/bin/cat")
|
||||
gen_safe_perms("dominate", "FAIL", "inv", "/**", "/*")
|
||||
gen_safe_perms("ambiguous", "FAIL", "inv", "/a*", "/*b")
|
||||
|
||||
print ("Generated %s xtransition interaction tests" % count)
|
||||
print("Generated %s xtransition interaction tests" % count)
|
||||
|
@@ -10,12 +10,14 @@
|
||||
#
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
from testlib import read_features_dir
|
||||
from argparse import ArgumentParser
|
||||
import os
|
||||
from argparse import ArgumentParser
|
||||
from sys import stderr, exit
|
||||
|
||||
DEFAULT_FEATURES_DIR='/sys/kernel/security/apparmor/features'
|
||||
from testlib import read_features_dir
|
||||
|
||||
DEFAULT_FEATURES_DIR = '/sys/kernel/security/apparmor/features'
|
||||
|
||||
|
||||
def main():
|
||||
p = ArgumentParser()
|
||||
@@ -33,5 +35,6 @@ def main():
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
|
7
parser/tst/simple_tests/mount/bad_1.sd
Normal file
7
parser/tst/simple_tests/mount/bad_1.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule with incompatible options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw, ro) -> /foo,
|
||||
}
|
7
parser/tst/simple_tests/mount/bad_2.sd
Normal file
7
parser/tst/simple_tests/mount/bad_2.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule with incompatible options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw ro) -> /foo,
|
||||
}
|
7
parser/tst/simple_tests/mount/bad_3.sd
Normal file
7
parser/tst/simple_tests/mount/bad_3.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule with incompatible options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw ro) fstype=procfs -> /foo,
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
#=Description basic mount rule
|
||||
#=EXRESULT PASS
|
||||
#=Description basic mount rule with incompatible options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw ro) fstype=(procfs) none -> /foo,
|
7
parser/tst/simple_tests/mount/bad_opt_29.sd
Normal file
7
parser/tst/simple_tests/mount/bad_opt_29.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting = options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(strictatime, nostrictatime) -> /foo,
|
||||
}
|
7
parser/tst/simple_tests/mount/bad_opt_30.sd
Normal file
7
parser/tst/simple_tests/mount/bad_opt_30.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting = options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(lazytime, nolazytime) -> /foo,
|
||||
}
|
7
parser/tst/simple_tests/mount/bad_opt_31.sd
Normal file
7
parser/tst/simple_tests/mount/bad_opt_31.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting = options
|
||||
#=EXRESULT FAIL
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(symfollow, nosymfollow) -> /foo,
|
||||
}
|
@@ -3,5 +3,5 @@
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw, ro) -> /foo,
|
||||
mount options=(rw nosuid) -> /foo,
|
||||
}
|
||||
|
@@ -1,7 +0,0 @@
|
||||
#
|
||||
#=Description basic mount rule
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw ro) -> /foo,
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
#
|
||||
#=Description basic mount rule
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options=(rw ro) fstype=procfs -> /foo,
|
||||
}
|
8
parser/tst/simple_tests/mount/ok_opt_56.sd
Normal file
8
parser/tst/simple_tests/mount/ok_opt_56.sd
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
#=Description basic rules to test the "nostrictatime" mount option
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=nostrictatime /a -> /1,
|
||||
mount options=(nostrictatime) /b -> /2,
|
||||
mount options in (nostrictatime) /d -> /4,
|
||||
}
|
8
parser/tst/simple_tests/mount/ok_opt_57.sd
Normal file
8
parser/tst/simple_tests/mount/ok_opt_57.sd
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
#=Description basic rules to test the "lazytime" mount option
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=lazytime /a -> /1,
|
||||
mount options=(lazytime) /b -> /2,
|
||||
mount options in (lazytime) /d -> /4,
|
||||
}
|
8
parser/tst/simple_tests/mount/ok_opt_58.sd
Normal file
8
parser/tst/simple_tests/mount/ok_opt_58.sd
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
#=Description basic rules to test the "nolazytime" mount option
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=nolazytime /a -> /1,
|
||||
mount options=(nolazytime) /b -> /2,
|
||||
mount options in (nolazytime) /d -> /4,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_59.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_59.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic rules to test the "strictatime" mount option in combination
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=(rw,strictatime) /c -> /3,
|
||||
mount options in (ro,strictatime) /e -> /5,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_60.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_60.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic rules to test the "nostrictatime" mount option in combination
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=(rw,nostrictatime) /c -> /3,
|
||||
mount options in (ro,nostrictatime) /e -> /5,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_61.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_61.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic rules to test the "lazytime" mount option in combination
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=(rw,lazytime) /c -> /3,
|
||||
mount options in (ro,lazytime) /e -> /5,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_62.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_62.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic rules to test the "nolazytime" mount option in combination
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=(rw,nolazytime) /c -> /3,
|
||||
mount options in (ro,nolazytime) /e -> /5,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_63.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_63.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting options with in
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options in (strictatime, nostrictatime) -> /foo,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_64.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_64.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting options with in
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options in (lazytime, nolazytime) -> /foo,
|
||||
}
|
8
parser/tst/simple_tests/mount/ok_opt_65.sd
Normal file
8
parser/tst/simple_tests/mount/ok_opt_65.sd
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
#=Description basic rules to test the "nosymfollow" mount option
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=nosymfollow /a -> /1,
|
||||
mount options=(nosymfollow) /b -> /2,
|
||||
mount options in (nosymfollow) /d -> /4,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_66.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_66.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic rules to test the "symfollow" mount option in combination
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=(rw,symfollow) /c -> /3,
|
||||
mount options in (ro,symfollow) /e -> /5,
|
||||
}
|
7
parser/tst/simple_tests/mount/ok_opt_67.sd
Normal file
7
parser/tst/simple_tests/mount/ok_opt_67.sd
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
#=Description basic mount rule conflicting options with in
|
||||
#=EXRESULT PASS
|
||||
#
|
||||
/usr/bin/foo {
|
||||
mount options in (symfollow, nosymfollow) -> /foo,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_68.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_68.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "unbindable" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=unbindable /1,
|
||||
mount options=(unbindable) /2,
|
||||
mount options=(rw,unbindable) /3,
|
||||
mount options in (unbindable) /4,
|
||||
mount options in (ro,unbindable) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_69.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_69.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "runbindable" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=runbindable /1,
|
||||
mount options=(runbindable) /2,
|
||||
mount options=(rw,runbindable) /3,
|
||||
mount options in (runbindable) /4,
|
||||
mount options in (ro,runbindable) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_70.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_70.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "rprivate" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=rprivate /1,
|
||||
mount options=(rprivate) /2,
|
||||
mount options=(rw,rprivate) /3,
|
||||
mount options in (rprivate) /4,
|
||||
mount options in (ro,rprivate) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_71.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_71.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "private" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=private /1,
|
||||
mount options=(private) /2,
|
||||
mount options=(rw,private) /3,
|
||||
mount options in (private) /4,
|
||||
mount options in (ro,private) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_72.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_72.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "slave" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=slave /1,
|
||||
mount options=(slave) /2,
|
||||
mount options=(rw,slave) /3,
|
||||
mount options in (slave) /4,
|
||||
mount options in (ro,slave) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_73.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_73.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "rslave" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=rslave /1,
|
||||
mount options=(rslave) /2,
|
||||
mount options=(rw,rslave) /3,
|
||||
mount options in (rslave) /4,
|
||||
mount options in (ro,rslave) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_74.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_74.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "shared" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=shared /1,
|
||||
mount options=(shared) /2,
|
||||
mount options=(rw,shared) /3,
|
||||
mount options in (shared) /4,
|
||||
mount options in (ro,shared) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_75.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_75.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "rshared" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=rshared /1,
|
||||
mount options=(rshared) /2,
|
||||
mount options=(rw,rshared) /3,
|
||||
mount options in (rshared) /4,
|
||||
mount options in (ro,rshared) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_76.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_76.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-unbindable" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-unbindable /1,
|
||||
mount options=(make-unbindable) /2,
|
||||
mount options=(rw,make-unbindable) /3,
|
||||
mount options in (make-unbindable) /4,
|
||||
mount options in (ro,make-unbindable) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_77.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_77.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-runbindable" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-runbindable /1,
|
||||
mount options=(make-runbindable) /2,
|
||||
mount options=(rw,make-runbindable) /3,
|
||||
mount options in (make-runbindable) /4,
|
||||
mount options in (ro,make-runbindable) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_78.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_78.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-private" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-private /1,
|
||||
mount options=(make-private) /2,
|
||||
mount options=(rw,make-private) /3,
|
||||
mount options in (make-private) /4,
|
||||
mount options in (ro,make-private) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_79.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_79.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-rprivate" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-rprivate /1,
|
||||
mount options=(make-rprivate) /2,
|
||||
mount options=(rw,make-rprivate) /3,
|
||||
mount options in (make-rprivate) /4,
|
||||
mount options in (ro,make-rprivate) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_80.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_80.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-slave" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-slave /1,
|
||||
mount options=(make-slave) /2,
|
||||
mount options=(rw,make-slave) /3,
|
||||
mount options in (make-slave) /4,
|
||||
mount options in (ro,make-slave) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_81.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_81.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-shared" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-shared /1,
|
||||
mount options=(make-shared) /2,
|
||||
mount options=(rw,make-shared) /3,
|
||||
mount options in (make-shared) /4,
|
||||
mount options in (ro,make-shared) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_82.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_82.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-rslave" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-rslave /1,
|
||||
mount options=(make-rslave) /2,
|
||||
mount options=(rw,make-rslave) /3,
|
||||
mount options in (make-rslave) /4,
|
||||
mount options in (ro,make-rslave) /5,
|
||||
}
|
10
parser/tst/simple_tests/mount/ok_opt_83.sd
Normal file
10
parser/tst/simple_tests/mount/ok_opt_83.sd
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
#=Description basic rules to test the "make-rshared" mount option passing mount point as source (should emit a deprecation warning)
|
||||
#=EXRESULT PASS
|
||||
/usr/bin/foo {
|
||||
mount options=make-rshared /1,
|
||||
mount options=(make-rshared) /2,
|
||||
mount options=(rw,make-rshared) /3,
|
||||
mount options in (make-rshared) /4,
|
||||
mount options in (ro,make-rshared) /5,
|
||||
}
|
@@ -41,9 +41,9 @@ class AANoCleanupMetaClass(type):
|
||||
|
||||
@classmethod
|
||||
def keep_on_fail(cls, unittest_func):
|
||||
'''wrapping function for unittest testcases to detect failure
|
||||
"""wrapping function for unittest testcases to detect failure
|
||||
and leave behind test files in tearDown(); to be used as
|
||||
a decorator'''
|
||||
a decorator"""
|
||||
|
||||
def new_unittest_func(self):
|
||||
try:
|
||||
@@ -58,17 +58,17 @@ class AANoCleanupMetaClass(type):
|
||||
|
||||
|
||||
class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
'''Stub class for use by test scripts'''
|
||||
"""Stub class for use by test scripts"""
|
||||
debug = False
|
||||
do_cleanup = True
|
||||
|
||||
def run_cmd_check(self, command, input=None, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120, expected_rc=0, expected_string=None):
|
||||
'''Wrapper around run_cmd that checks the rc code against
|
||||
"""Wrapper around run_cmd that checks the rc code against
|
||||
expected_rc and for expected strings in the output if
|
||||
passed. The valgrind tests generally don't care what the
|
||||
rc is as long as it's not a specific set of return codes,
|
||||
so can't push the check directly into run_cmd().'''
|
||||
so can't push the check directly into run_cmd()."""
|
||||
rc, report = self.run_cmd(command, input, stderr, stdout, stdin, timeout)
|
||||
self.assertEqual(rc, expected_rc, "Got return code %d, expected %d\nCommand run: %s\nOutput: %s" % (rc, expected_rc, (' '.join(command)), report))
|
||||
if expected_string:
|
||||
@@ -77,11 +77,11 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
|
||||
def run_cmd(self, command, input=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120):
|
||||
'''Try to execute given command (array) and return its stdout, or
|
||||
return a textual error if it failed.'''
|
||||
"""Try to execute given command (array) and return its stdout, or
|
||||
return a textual error if it failed."""
|
||||
|
||||
if self.debug:
|
||||
print('\n===> Running command: \'%s\'' % (' '.join(command)))
|
||||
print("\n===> Running command: '%s'" % (' '.join(command)))
|
||||
|
||||
(rc, out, outerr) = self._run_cmd(command, input, stderr, stdout, stdin, timeout)
|
||||
report = out + outerr
|
||||
@@ -90,7 +90,7 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
|
||||
def _run_cmd(self, command, input=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120):
|
||||
'''Try to execute given command (array) and return its rc, stdout, and stderr as a tuple'''
|
||||
"""Try to execute given command (array) and return its rc, stdout, and stderr as a tuple"""
|
||||
|
||||
try:
|
||||
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr,
|
||||
@@ -121,7 +121,6 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
# Timeout handler using alarm() from John P. Speno's Pythonic Avocado
|
||||
class TimeoutFunctionException(Exception):
|
||||
"""Exception to raise on a timeout"""
|
||||
pass
|
||||
|
||||
|
||||
class TimeoutFunction:
|
||||
@@ -144,7 +143,7 @@ class TimeoutFunction:
|
||||
|
||||
|
||||
def filesystem_time_resolution():
|
||||
'''detect whether the filesystem stores subsecond timestamps'''
|
||||
"""detect whether the filesystem stores subsecond timestamps"""
|
||||
|
||||
default_diff = 0.1
|
||||
result = (True, default_diff)
|
||||
@@ -199,7 +198,7 @@ def touch(path):
|
||||
|
||||
|
||||
def write_file(directory, file, contents):
|
||||
'''construct path, write contents to it, and return the constructed path'''
|
||||
"""construct path, write contents to it, and return the constructed path"""
|
||||
path = os.path.join(directory, file)
|
||||
with open(path, 'w+') as f:
|
||||
f.write(contents)
|
||||
|
@@ -13,11 +13,12 @@
|
||||
# TODO
|
||||
# - finish adding suppressions for valgrind false positives
|
||||
|
||||
from argparse import ArgumentParser # requires python 2.7 or newer
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from argparse import ArgumentParser
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
import testlib
|
||||
|
||||
DEFAULT_TESTDIR = "./simple_tests/vars"
|
||||
@@ -50,12 +51,14 @@ class AAParserValgrindTests(testlib.AATestTemplate):
|
||||
command.extend(parser_args)
|
||||
command.append(testname)
|
||||
rc, output = self.run_cmd(command, timeout=120)
|
||||
self.assertNotIn(rc, failure_rc,
|
||||
"valgrind returned error code %d, gave the following output\n%s\ncommand run: %s" % (rc, output, " ".join(command)))
|
||||
self.assertNotIn(
|
||||
rc, failure_rc,
|
||||
"valgrind returned error code %d, gave the following output\n%s\ncommand run: %s"
|
||||
% (rc, output, " ".join(command)))
|
||||
|
||||
|
||||
def find_testcases(testdir):
|
||||
'''dig testcases out of passed directory'''
|
||||
"""dig testcases out of passed directory"""
|
||||
|
||||
for (fdir, direntries, files) in os.walk(testdir):
|
||||
for f in files:
|
||||
@@ -64,13 +67,10 @@ def find_testcases(testdir):
|
||||
|
||||
|
||||
def create_suppressions():
|
||||
'''generate valgrind suppressions file'''
|
||||
|
||||
handle, name = tempfile.mkstemp(suffix='.suppressions', prefix='aa-parser-valgrind')
|
||||
os.close(handle)
|
||||
with open(name, "w+") as handle:
|
||||
handle.write(VALGRIND_SUPPRESSIONS)
|
||||
return name
|
||||
"""generate valgrind suppressions file"""
|
||||
with NamedTemporaryFile("w+", suffix='.suppressions', prefix='aa-parser-valgrind', delete=False) as temp_file:
|
||||
temp_file.write(VALGRIND_SUPPRESSIONS)
|
||||
return temp_file.name
|
||||
|
||||
|
||||
def main():
|
||||
@@ -125,6 +125,7 @@ def main():
|
||||
|
||||
return rc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
rc = main()
|
||||
exit(rc)
|
||||
|
@@ -41,7 +41,7 @@ ifdef USE_SYSTEM
|
||||
LOGPROF?=aa-logprof
|
||||
else
|
||||
# PYTHON_DIST_BUILD_PATH based on libapparmor/swig/python/test/Makefile.am
|
||||
PYTHON_DIST_BUILD_PATH = ../libraries/libapparmor/swig/python/build/$$($(PYTHON) -c "import sysconfig; print(\"lib.%s-%s\" %(sysconfig.get_platform(), sysconfig.get_python_version()))")
|
||||
PYTHON_DIST_BUILD_PATH = ../libraries/libapparmor/swig/python/build/$$($(PYTHON) ../libraries/libapparmor/swig/python/test/buildpath.py)
|
||||
LIBAPPARMOR_PATH=../libraries/libapparmor/src/.libs/
|
||||
LD_LIBRARY_PATH=$(LIBAPPARMOR_PATH):$(PYTHON_DIST_BUILD_PATH)
|
||||
PYTHONPATH=../utils/:$(PYTHON_DIST_BUILD_PATH)
|
||||
@@ -83,7 +83,7 @@ local:
|
||||
fn=$$(basename $$profile); \
|
||||
echo "# Site-specific additions and overrides for '$$fn'" > ${PROFILES_SOURCE}/local/$$fn; \
|
||||
grep "include[[:space:]]\\+if[[:space:]]\\+exists[[:space:]]\\+<local/$$fn>" "$$profile" >/dev/null || { echo "$$profile doesn't contain include if exists <local/$$fn>" ; exit 1; } ; \
|
||||
done; \
|
||||
done
|
||||
|
||||
.PHONY: install
|
||||
install: local
|
||||
@@ -119,7 +119,7 @@ CHECK_PROFILES=$(filter-out ${IGNORE_FILES} ${SUBDIRS}, $(wildcard ${PROFILES_SO
|
||||
CHECK_ABSTRACTIONS=$(shell find ${ABSTRACTIONS_SOURCE} -type f -print)
|
||||
|
||||
.PHONY: check
|
||||
check: check-parser check-logprof check-abstractions.d
|
||||
check: check-parser check-logprof check-abstractions.d check-extras
|
||||
|
||||
.PHONY: check-parser
|
||||
check-parser: test-dependencies local
|
||||
@@ -151,3 +151,11 @@ check-abstractions.d:
|
||||
test "$$file" = 'ubuntu-helpers' && continue ; \
|
||||
grep -q "^ include if exists <abstractions/$${file}.d>$$" $$file || { echo "$$file does not contain 'include if exists <abstractions/$${file}.d>'"; exit 1; } ; \
|
||||
done
|
||||
|
||||
.PHONY: check-extras
|
||||
check-extras:
|
||||
@echo "*** Checking if all extra profiles contain include if exists <local/*>"
|
||||
$(Q)cd ${EXTRAS_SOURCE} && for file in * ; do \
|
||||
test "$$file" = 'README' && continue ; \
|
||||
grep -q "^ include if exists <local/$${file}>$$" $$file || { echo "$$file does not contain 'include if exists <local/$${file}>'"; exit 1; } ; \
|
||||
done
|
||||
|
@@ -85,5 +85,8 @@ owner @{HOME}/.local/share/openal/hrtf/{,**} r,
|
||||
# wildmidi
|
||||
/etc/wildmidi/wildmidi.cfg r,
|
||||
|
||||
# pipewire
|
||||
/usr/share/pipewire/client.conf r,
|
||||
|
||||
# Include additions to the abstraction
|
||||
include if exists <abstractions/audio.d>
|
||||
|
@@ -36,8 +36,8 @@
|
||||
/usr/share/locale-langpack/** r,
|
||||
/usr/share/locale/** r,
|
||||
/usr/share/**/locale/** r,
|
||||
/usr/share/zoneinfo/ r,
|
||||
/usr/share/zoneinfo/** r,
|
||||
/usr/share/zoneinfo{,-icu}/ r,
|
||||
/usr/share/zoneinfo{,-icu}/** r,
|
||||
/usr/share/X11/locale/** r,
|
||||
@{run}/systemd/journal/dev-log w,
|
||||
# systemd native journal API (see sd_journal_print(4))
|
||||
@@ -62,6 +62,7 @@
|
||||
@{etc_ro}/ld.so.conf r,
|
||||
@{etc_ro}/ld.so.conf.d/{,*.conf} r,
|
||||
@{etc_ro}/ld.so.preload r,
|
||||
@{etc_ro}/ld-musl-*.path r,
|
||||
/{usr/,}lib{,32,64}/ld{,32,64}-*.so mr,
|
||||
/{usr/,}lib/@{multiarch}/ld{,32,64}-*.so mr,
|
||||
/{usr/,}lib/tls/i686/{cmov,nosegneg}/ld-*.so mr,
|
||||
@@ -101,6 +102,7 @@
|
||||
@{PROC}/cpuinfo r,
|
||||
@{sys}/devices/system/cpu/ r,
|
||||
@{sys}/devices/system/cpu/online r,
|
||||
@{sys}/devices/system/cpu/possible r,
|
||||
|
||||
# glibc's *printf protections read the maps file
|
||||
@{PROC}/@{pid}/{maps,auxv,status} r,
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
abi <abi/3.0>,
|
||||
|
||||
@{etc_ro}/gcrypt/hwf.deny r,
|
||||
@{etc_ro}/gcrypt/random.conf r,
|
||||
@{PROC}/sys/crypto/fips_enabled r,
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
@{system_share_dirs}/mime/** r,
|
||||
|
||||
# per-user configurations
|
||||
owner @{HOME}/.icons/ r,
|
||||
owner @{HOME}/.icons/{,**} r,
|
||||
owner @{HOME}/.recently-used.xbel* rw,
|
||||
owner @{HOME}/.local/share/recently-used.xbel* rw,
|
||||
owner @{HOME}/.config/user-dirs.dirs r,
|
||||
|
67
profiles/apparmor.d/abstractions/groff
Normal file
67
profiles/apparmor.d/abstractions/groff
Normal file
@@ -0,0 +1,67 @@
|
||||
# ------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (C) 2002-2009 Novell/SUSE
|
||||
# Copyright (C) 2009 Canonical Ltd.
|
||||
# Copyright (C) 2023 SUSE LLC
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of version 2 of the GNU General Public
|
||||
# License published by the Free Software Foundation.
|
||||
#
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# Note: executing groff and nroff themself is not included in this abstraction
|
||||
# so that you can choose to ix, Px or Cx them in your profile
|
||||
|
||||
# groff/nroff helpers, preprocessors, and postprocessors
|
||||
/usr/bin/addftinfo mrix,
|
||||
/usr/bin/afmtodit mrix,
|
||||
/usr/bin/chem mrix,
|
||||
/usr/bin/eqn mrix,
|
||||
/usr/bin/eqn2graph mrix,
|
||||
/usr/bin/gdiffmk mrix,
|
||||
/usr/bin/geqn mrix,
|
||||
/usr/bin/grap2graph mrix,
|
||||
/usr/bin/grn mrix,
|
||||
/usr/bin/grodvi mrix,
|
||||
/usr/bin/groffer mrix,
|
||||
/usr/bin/grog mrix,
|
||||
/usr/bin/grolbp mrix,
|
||||
/usr/bin/grolj4 mrix,
|
||||
/usr/bin/gropdf mrix,
|
||||
/usr/bin/grops mrix,
|
||||
/usr/bin/grotty mrix,
|
||||
/usr/bin/gtbl mrix,
|
||||
/usr/bin/hpftodit mrix,
|
||||
/usr/bin/indxbib mrix,
|
||||
/usr/bin/lkbib mrix,
|
||||
/usr/bin/lookbib mrix,
|
||||
/usr/bin/mmroff mrix,
|
||||
/usr/bin/neqn mrix,
|
||||
/usr/bin/pdfmom mrix,
|
||||
/usr/bin/pdfroff mrix,
|
||||
/usr/bin/pfbtops mrix,
|
||||
/usr/bin/pic mrix,
|
||||
/usr/bin/pic2graph mrix,
|
||||
/usr/bin/post-grohtml mrix,
|
||||
/usr/bin/pre-grohtml mrix,
|
||||
/usr/bin/preconv mrix,
|
||||
/usr/bin/refer mrix,
|
||||
/usr/bin/roff2dvi mrix,
|
||||
/usr/bin/roff2html mrix,
|
||||
/usr/bin/roff2pdf mrix,
|
||||
/usr/bin/roff2ps mrix,
|
||||
/usr/bin/roff2text mrix,
|
||||
/usr/bin/roff2x mrix,
|
||||
/usr/bin/soelim mrix,
|
||||
/usr/bin/tbl mrix,
|
||||
/usr/bin/tfmtodit mrix,
|
||||
/usr/bin/troff mrix,
|
||||
/usr/bin/xtotroff mrix,
|
||||
|
||||
# at least its macros and fonts
|
||||
/usr/libexec/groff/** r,
|
||||
/usr/share/groff/** r,
|
||||
|
||||
# Include additions to the abstraction
|
||||
include if exists <abstractions/groff.d>
|
@@ -41,8 +41,11 @@ owner @{HOME}/.config/Trolltech.conf rwk,
|
||||
owner @{HOME}/.config/baloofilerc r, # indexing options (excludes, etc), used by KFileWidget
|
||||
owner @{HOME}/.config/dolphinrc r, # settings used by KFileWidget
|
||||
owner @{HOME}/.config/kde.org/libphonon.conf r, # for KNotifications::sendEvent()
|
||||
owner @{HOME}/.config/kdedefaults/kdeglobals r, # QPlatformThemeFactory::create() -> KDEPlasmaPlatformTheme.so
|
||||
owner @{HOME}/.config/kdedefaults/kwinrc r, # QStyleFactory::create() -> qt5/plugins/styles/breeze.so
|
||||
owner @{HOME}/.config/kdeglobals r, # global settings, used by Breeze style, etc.
|
||||
owner @{HOME}/.config/klanguageoverridesrc r, # per-application languages, for KDEPrivate::initializeLanguages() from libKF5XmlGui.so
|
||||
owner @{HOME}/.config/kwinrc r, # QStyleFactory::create() -> qt5/plugins/styles/breeze.so
|
||||
owner @{HOME}/.config/trashrc r, # Used by KFileWidget
|
||||
|
||||
/usr/share/X11/XKeysymDB r,
|
||||
|
@@ -22,6 +22,11 @@
|
||||
/usr/lib/@{multiarch}/krb5/plugins/preauth/ r,
|
||||
/usr/lib/@{multiarch}/krb5/plugins/preauth/* mr,
|
||||
|
||||
/usr/lib{,32,64}/krb5/plugins/authdata/ r,
|
||||
/usr/lib{,32,64}/krb5/plugins/authdata/* mr,
|
||||
/usr/lib/@{multiarch}/krb5/plugins/authdata/ r,
|
||||
/usr/lib/@{multiarch}/krb5/plugins/authdata/* mr,
|
||||
|
||||
/etc/krb5.keytab rk,
|
||||
/etc/krb5.conf r,
|
||||
/etc/krb5.conf.d/ r,
|
||||
|
@@ -44,6 +44,7 @@
|
||||
@{run}/{resolvconf,NetworkManager,systemd/resolve,connman,netconfig}/resolv.conf r,
|
||||
@{etc_ro}/resolvconf/run/resolv.conf r,
|
||||
@{run}/systemd/resolve/stub-resolv.conf r,
|
||||
/mnt/wsl/resolv.conf r,
|
||||
|
||||
@{etc_ro}/samba/lmhosts r,
|
||||
@{etc_ro}/services r,
|
||||
|
@@ -23,9 +23,13 @@
|
||||
|
||||
@{sys}/devices/system/memory/block_size_bytes r,
|
||||
|
||||
owner @{HOME}/.cache/nvidia/ w,
|
||||
owner @{HOME}/.cache/nvidia/GLCache/ rw,
|
||||
owner @{HOME}/.cache/nvidia/GLCache/** rwk,
|
||||
owner @{HOME}/.nv/ w,
|
||||
owner @{HOME}/.nv/GLCache/ rw,
|
||||
owner @{HOME}/.nv/GLCache/** rwk,
|
||||
owner @{PROC}/@{pid}/comm r, # somehwere in libnvidia-glcore.so
|
||||
|
||||
unix (send, receive) type=dgram peer=(addr="@nvidia[0-9a-f]*"),
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
abi <abi/3.0>,
|
||||
|
||||
/etc/ssl/openssl.cnf r,
|
||||
/etc/ssl/openssl-*.cnf r,
|
||||
/etc/ssl/{engdef,engines}.d/ r,
|
||||
/etc/ssl/{engdef,engines}.d/*.cnf r,
|
||||
/usr/share/ssl/openssl.cnf r,
|
||||
|
@@ -23,11 +23,12 @@
|
||||
/var/lib/samba/** rwk,
|
||||
/var/log/samba/cores/ rw,
|
||||
/var/log/samba/cores/** rw,
|
||||
/var/log/samba/* w,
|
||||
/var/log/samba/* rw,
|
||||
@{run}/{,lock/}samba/ w,
|
||||
@{run}/{,lock/}samba/*.tdb rw,
|
||||
@{run}/{,lock/}samba/msg.lock/ rwk,
|
||||
@{run}/{,lock/}samba/msg.lock/[0-9]* rwk,
|
||||
@{run}/{,lock/}samba/*.tdb rwk,
|
||||
@{run}/{,lock/}samba/msg.{lock,sock}/ rwk,
|
||||
@{run}/{,lock/}samba/msg.{lock,sock}/[0-9]* rwk,
|
||||
/var/cache/samba/*.tdb rwk,
|
||||
/var/cache/samba/msg.lock/ rwk,
|
||||
/var/cache/samba/msg.lock/[0-9]* rwk,
|
||||
|
||||
|
@@ -38,5 +38,6 @@ profile snap_browsers {
|
||||
/snap/opera/[0-9]*/meta/{snap.yaml,hooks/} r,
|
||||
|
||||
/var/lib/snapd/sequence/{chromium,firefox,opera}.json r,
|
||||
/var/lib/snapd/inhibit/{chromium,firefox,opera}.lock rk,
|
||||
# add other browsers here
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
/etc/{,libre}ssl/certs/{,**} r,
|
||||
/{etc,usr/share}/pki/bl[ao]cklist/{,*} r,
|
||||
/{etc,usr/share}/pki/trust/{,*} r,
|
||||
/{etc,usr/share}/pki/trust/anchors/{,**} r,
|
||||
/{etc,usr/share}/pki/trust/{bl[oa]cklist,anchors}/{,**} r,
|
||||
/usr/share/ca-certificates/{,**} r,
|
||||
/usr/share/ssl/certs/ca-bundle.crt r,
|
||||
/usr/local/share/ca-certificates/{,**} r,
|
||||
|
@@ -80,6 +80,7 @@ profile sanitized_helper {
|
||||
/opt/brave.com/brave{,-beta,-dev,-nightly}/chrome-sandbox PUxr,
|
||||
/opt/brave.com/brave{,-beta,-dev,-nightly}/brave-browser{,-beta,-dev,-nightly} Pixr,
|
||||
/opt/brave.com/brave{,-beta,-dev,-nightly}/brave Pixr,
|
||||
/opt/brave.com/brave{,-beta,-dev,-nightly}/chrome_crashpad_handler Pixr,
|
||||
/opt/brave.com/brave{,-beta,-dev,-nightly}/{,**/}lib*.so{,.*} m,
|
||||
|
||||
# Full access
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user