Commit graph

2272 commits

Author SHA1 Message Date
Tyler Hicks
f2dfd613f8 tests: Add regression tests for dbus
Integrate dbus tests into the regression testing framework.

This started out as dbus-send.c, from the dbus source, and then grew
from there.

dbus_message is an example "client" program that only sends out
messages. dbus_service binds to a well-known name and then listens and
responds to incoming messages. They share some code in dbus_common.c.

The test scripts, dbus_message.sh and dbus_service.sh, share some
functionality in dbus.inc.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-20 12:14:03 -07:00
Steve Beattie
d1791ff286 Description: clean out test dir python cache directory
Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-12 17:55:45 -07:00
Tyler Hicks
cbedbdde81 libapparmor: ENOENT should only signify label not found in label queries
It may be useful to applications that do AppArmor queries to know if the
subject label in the query is unknown to the kernel. For example, the
corresponding profile may have been removed/renamed.

This patch eliminates all potential return locations of aa_query_label()
that may have errno set to ENOENT, except for the write() to
apparmorfs/.access that sets ENOENT when the subject label isn't found
by the kernel.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-09 18:55:16 -07:00
Tyler Hicks
fe3ccea370 libaalogparse: Regression tests for dbus-daemon audit messages
Test a set of send, bind, and receive denials routed through syslog,
as well as a set routed through auditd.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-08-09 11:08:57 -07:00
Tyler Hicks
5aa58bef7c libaalogparse: Parse dbus-daemon audit messages
This requires libaalogparse to become aware of USER_AVC messages.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-09 11:02:41 -07:00
Tyler Hicks
5bddcaa84d tests: Verify delegation of fd inheritance
Add a new set of tests that tests delegation of file descriptors when
inherited across combinations of confined and unconfined processes.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-08 22:47:25 -07:00
Tyler Hicks
de69b2242c tests: Verify delegation of fd passing
This patch broadens the testing of file descriptor passing over Unix
domain sockets, but the real focus is on passing a file descriptor from
an unconfined server to a confined client. The confined client should
have full access to the file descriptor, despite not having a
corresponding file rule in its profile, due to delegation.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-08-08 22:45:49 -07:00
John Johansen
d680eb7b6d This quick little patch adds the ability to specify the features
required for a test to run. This will help keep the regression suite
from reporting a lot of failures when it hits a kernel that doesn't
support the feature being tested.

its current iteration is pretty brain dead, only testing for the
existance of feature files/dirs (and not contents) but I think it is
probably sufficient for now.

To use it, just call the required_features fn right after sourcing
prologue.inc in the bash test script that is called by the make file.

If any of the requested features don't exist the bash script will exit
reporting the first feature that was missing

Eg.

. $bin/prologue.inc
required_features dbus
required_features dbus dbus/mask network domain/change_hatv

Acked-by: Tyler Hicks <tyhicks@canonical.com>
2013-08-02 16:22:12 -07:00
Tyler Hicks
2fbea1ceea tests: Add an optional final check to checktestfg and checktestbg
Allows for the test script to specify a final check to be performed
after checking the output of the test binary. This may be useful, for
example, if the test script wants to compare logging output of the test
binary to known-good logging output.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-08-02 16:19:54 -07:00
Tyler Hicks
553d0d9eaf libapparmor: Export a label-based query interface
Add an interface for trusted applications to use when they need to query
AppArmor kernel policy to determine if an action should be allowed.

This is a simplified interface that tries to make it as easy as possible
for applications to use. They provide a permissions mask and query
string and they get a pair of booleans back that let them know if the
action should be allowed and/or audited.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-31 09:22:40 -07:00
Tyler Hicks
7c817bde70 parser: Binary profile equality tests for DBus rules
This test is to verify that a list of profiles compile down into the
same binary representation. This is useful, for example, when testing a
rule syntax that includes permission aliases, as well as implied and
explicit accesses.
    
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-31 09:22:11 -07:00
Tyler Hicks
670a1815ed parser: Regression tests for DBus rules
This is a test in the style of gen-xtrans.pl that attempts to run
through the most commonly constructed DBus rules. It also attempts to
run through some common mistakes to ensure that the parser fails
appropriately.
    
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-31 09:20:56 -07:00
Tyler Hicks
ab84444d3a parser: Add support for DBus rules
This patch implements the parsing of DBus rules.

It attempts to catch all corner cases, such as specifying a bind
permission with an interface conditional or specifying a subject name
conditional and a peer name conditional in the same rule.

It introduces the concept of conditional lists to the lexer and parser
in order to handle 'peer=(label=/usr/bin/foo name=com.foo.bar)', since
the existing list support in the lexer only supports a list of values.

The DBus rules are encoded as follows:

bus,name<bind_perm>,peer_label,path,interface,member<rw_perms>

Bind rules stop matching at name<bind_perm>. Note that name is used for
the subject name in bind rules and the peer name in rw rules. The
function new_dbus_entry() is what does the proper sanitization to make
sure that if a name conditional is specified, that it is the subject
name in the case of a bind rule or that it is the peer name in the case
of a rw rule.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-31 09:05:51 -07:00
Tyler Hicks
1aba3394a3 parser: Update man page for DBus rules
Document the DBus rule syntax and provide several examples.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-31 09:03:15 -07:00
Steve Beattie
8e47307fed Subject: [patch] fix apparmor cache tempfile location to use passed arg v2
This patch fixes problems in the handling of both the final cache
name location and the temporary cache file when an alternate location
is specified.

The first issue is that if the alternate cache directory location was
specified, the alternate directory name would be used as the final location for
the cache file, rather than the alternate directory + the basename of
the profile.

The second issue is that it would generate the temporary file that it
stores the cache file in [basedir]/cache even if an alternate cache
location was specified on the command line. This causes a problem
if [basedir]/cache is on a separate device than the alternate cache
location, because the rename() of the tempfile into the final location
would fail (which the parser would not check the return code of).

This patch fixes the above by incorporating the basename into the cache
file name if the alternate cache location has been specified, bases the
temporary cache file name on the destination cache name (such that they
end up in the same directory), and finally detects if the rename fails
and unlinks the temporary file if that happens (rather than leave it
around). It also has been updated to add a couple of testcases to verify
that writing and reading from an alternate cache location work.

Patch history:
  v1: first draft of patch
  v2: add testcases, convert PERROR() to pwarn() if rename() fails for
      placing cachefile into place.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-07-26 10:55:52 -07:00
Seth Arnold
2ba755318f Fix $options -> @options in previous patch. Fix tabs -> spaces.
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-07-09 16:02:08 -07:00
Seth Arnold
f745f7df33 From: intrigeri <intrigeri@boum.org>
At least on Debian sid, software such as Vidalia and Iceweasel go look for
fonts in there.

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-08 17:43:49 -07:00
Seth Arnold
ddcf88b827 From: intrigeri <intrigeri@boum.org>
Debian sid's fonts-mathjax ships fonts in
/usr/share/javascript/mathjax/fonts, that are now used by default by
fontconfig-enabled software.

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-08 17:43:08 -07:00
Seth Arnold
bf0674c40b From: intrigeri <intrigeri@boum.org>
At least on Debian, with recent versions of fontconfig-config
(>= 2.10), files in /etc/fonts/conf.d/ are symlinks pointing to
/usr/share/fontconfig/.

This was reported by Jakub Wilk <jwilk@debian.org> on Debian bug #714843.

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-08 17:42:09 -07:00
Seth Arnold
38b8d4527c Describe some known minimum versions of tools needed for which parts
Acked-By: Christian Boltz <apparmor@cboltz.de>
2013-07-07 18:30:18 -07:00
Seth Arnold
03908feacc Kshitij Gupta found and fixed a problem with Glob and Glob w/ Ext behavior
in aa-logprof and aa-genprof that would add duplicate entries to the
interactive list of permissions.

https://bugs.launchpad.net/bugs/1180230
2013-07-05 14:12:08 -07:00
Seth Arnold
7b50892339 Fix potential NULL-write in aa_getprocattr() error path
Gernot Vormayr provided this fix in
https://bugs.launchpad.net/apparmor/+bug/1196880
2013-07-02 11:47:43 -07:00
John Johansen
5b8abaee50 refactor/simplify the regex for ruby abstractions
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-07-01 11:06:52 -07:00
Christian Boltz
6753f46bf5 add Dolphin (default Kubuntu file manager) to the list of file managers in
abstractions/ubuntu-browsers.d/ubuntu-integration.

Patch by Felix Geyer <debfx@ubuntu.com>

Acked-by: Seth Arnold <seth.arnold at canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2013-07-01 17:48:58 +02:00
Christian Boltz
e03a9ba22f merge https://code.launchpad.net/~kensington/apparmor/apparmor/+merge/169010
Michael Palimaka 2013-06-13 Add missing key shortcuts for hu linguas.
2013-07-01 17:44:53 +02:00
Christian Boltz
54a5c2a5c4 merge https://code.launchpad.net/~kensington/apparmor/vim-man/+merge/172201
Michael Palimaka 2013-06-30 Move apparmor.vim.5 from parser to utils (apparmor.vim already lives there).
2013-07-01 17:35:18 +02:00
Michael Palimaka
1974c22e54 Move apparmor.vim.5 from parser to utils (apparmor.vim already lives there). 2013-06-30 00:25:44 +10:00
Jamie Strandboge
9b7a7d797e remove unneeded perl requires on Time::Local and File::Basename
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Marc Deslauriers <marc.deslauriers@canonical.com>
2013-06-28 12:37:36 -05:00
Jamie Strandboge
80f5a9a448 remove unneeded perl requires on Time::Local and File::Basename
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-06-27 12:11:09 -05:00
Kees Cook
4eb5fa017d fix missing long opt arg value
Using --subdomainfs without an argument triggers a segfault. This was due
to the long option missing the "has_arg" flag.

Signed-off-by: Kees Cook <kees@ubuntu.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-06-26 11:26:43 -07:00
Tyler Hicks
1423e8f8ff Subject: libapparmor: Update aa_getcon man page to reflect getpeercon changes
Add aa_getpeercon_raw() to the man page and adjust aa_getpeercon()
prototype to include the new mode parameter.

Also, explain the significance of ERANGE for aa_getpeercon_raw() and fix
a misspelling in the meaning of ERANGE.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:55:52 -07:00
Tyler Hicks
7d81fbcd05 Subject: libapparmor: Make aa_getpeercon_raw() similar to aa_getprocattr_raw()
The parameter names are slightly different in the two functions. Rename
buffer to buf and rename size to len to make the two function prototypes
look similar.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:55:08 -07:00
Tyler Hicks
43f29bbc58 Subject: libapparmor: Parse mode from confinement string in getpeercon
functions

The functions that return the confinement information of a peer socket
connection should parse and return the mode like the task-based
functions.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:54:17 -07:00
Tyler Hicks
063095bcaa Subject: libapparmor: Move mode parsing into separate function
The getpeercon functions need to parse the mode from the confinement
string. This patch creates a function that aa_getpeercon_raw() and
aa_getprocattr_raw() can both use.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:53:39 -07:00
John Johansen
0d86e64114 Subject: libapparmor: fix return value of aa_getpeercon_raw
Return the total size of the security context on success
as documented.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:52:46 -07:00
John Johansen
b6c9a7623a Subject: libapparmor: Safeguard aa_getpeercon buffer reallocation
Protect against bugs in AppArmor's getsockopt() LSM hook from sending
aa_getpeercon() into an infinite loop.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:52:15 -07:00
Tyler Hicks
887c0a9a44 Subject: Fix mount rule preprocessor output
Currently, mount rule preprocessor output is incorrect:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mountmount =ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mountmount  in (ro) /s -> /d, }

This is due to incorrect placement of DUMP_PREPROCESS in parser_lex.l.
With this patch, the output is correct:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mount options=ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mount options in (ro) /s -> /d,

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-06-25 15:46:57 -07:00
John Johansen
a3a3624c57 More updates to the apparmor 3 docs - they are still not in a usable state 2013-06-14 12:35:51 -07:00
Michael Palimaka
b6c9f6cc53 Add missing key shortcuts for hu linguas. 2013-06-13 02:10:46 +10:00
Seth Arnold
647d7c1585 move poppler cMap from gnome to fonts, thanks to Felix Geyer 2013-05-30 12:01:27 -07:00
Jamie Strandboge
58f5df11e6 deny writes to upstart user sessions jobs in abstractions/private-files
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:56:10 -05:00
Jamie Strandboge
e3c0425857 add @{HOME}/.gnome2/keyrings/** to abstractions/private-files-strict
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:55:23 -05:00
John Johansen
b643a42dfd This is a minimal fix to apparmor 2.8 for cache failures when the feature
file is larger than the feature buffer used for cache version comparison.

Ideally this would be dynamically allocated but for 2.8 just bumping the
buffer size is the quick fix.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-02 11:32:56 -07:00
John Johansen
c0123646f6 Add more wip apparmor documentation 2013-05-02 10:57:23 -07:00
John Johansen
5d220486e9 rename variable doc 2013-05-02 10:55:02 -07:00
John Johansen
8a2efb0dec Add wip AppArmor Policy document 2013-05-02 10:45:36 -07:00
Jamie Strandboge
ae2cdf0fad Fix two race conditions:
1) make sure that the xpra socket exists before trying to attach to it
2) make sure that the client has attached before we start the application

The fix for '1' solves a problem when the system is under load and the
one for '2' fixes a problem with firefox starting too soon and not
having system themes applied.

Exercising the 1 week rule. Seth Arnold commented on the added sleeps and I
adjusted one based on his comments and replied to the list that the other is
needed and that this improves the sandbox/xpra code but that there are
limitations with driving xpra.

Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:31:39 -05:00
Jamie Strandboge
5f871cfad2 profiles/apparmor.d/usr.sbin.nscd: remove read access to
@{PROC}/sys/vm/overcommit_memory, now included in base

Acked-By: Christian Boltz <apparmor@cboltz.de>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:19:55 -05:00
Jamie Strandboge
7679ac49b1 add read access to @{PROC}/sys/vm/overcommit_memory as used by glibc. See
http://sourceware.org/git/?p=glibc.git;a=commit;h=9fab36eb583c0e585e83a01253299afed9ea9a11

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-04-08 20:11:43 -05:00
Jamie Strandboge
7e9c7c37be update pulseaudio directory and cookie file paths
Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2013-04-08 20:10:36 -05:00