Commit graph

2262 commits

Author SHA1 Message Date
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
Christian Boltz
53f9cd79f5 Add missing permissions to the nscd profile.
Also deny capability block_suspend because nobody can imagine why it 
would be needed.

References: https://bugzilla.novell.com/show_bug.cgi?id=807104

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-03-05 22:11:59 +01:00
Steve Beattie
0c3899065b Subject: libapparmor - use python-config if it exists when configuring
Author: Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>

Modifiy the libapparmor macro for python to use python-config if it
exists to determine what CPPFLAGS and LDFLAGS to use when building
the python swig libraries. Without this addition, python detection
fails on ubuntu 13.04. I've confirmed that with this patch applied,
the python libraries still build successfully on older releases as well
(as far back as ubuntu 11.10).

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Kees Cook <kees@ubuntu.com>
2013-01-29 15:21:47 -08:00
Steve Beattie
8f931d8fd6 jjohansen's recent commit to extend the datetime parsing of syslog
messages neglected to include the empty .err files in the testsute
directory, resulting in ERROR output. These files were included in the
patch submitted to the mail list. This commit adds them.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-28 11:19:54 -08:00
Steve Beattie
f4716805aa Merge from Michael Palimaka <kensington@gentoo.org>:
* parser - Respect LDFLAGS while building the parser
* libapparmor - Remove an unused configure option

Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-01-28 11:15:57 -08:00
Jamie Strandboge
3c41028cd5 Committing per IRC discussions. Does not update the Makefile to install it yet.
= How it works =
There are basically two modes:
 1. using an existing profile with --profile
 2. dynamically generating a profile

For '1', aa-sandbox is just a wrapper around aa-exec.

For '2', aa-sandbox leverages easyprof and allows you to specify policy
in a limited way on the command line. It then loads the policy into the
kernel as a profile (ie, 'profile <foo> { ... }') so it doesn't get in
the way of existing profiles. It currently calls apparmor_parser via
sudo or pkexec. Once the profile is loaded, aa-exec the application
under the profile.

When -X is specified, the application is launched inside its own X
server using either xpra (the default, which uses Xvfb), xephyr and
xpra3d (xpra, but using Xorg with the xdummy[1] driver for now[2].
xpra3d doesn't currently perform well, but works ok with newer Gnome
applications that now require GLX). When using '-X', it:
- adds an explicit deny rule for ~/.Xauthority
- generates a dynamic Xauthority file for the session in 
  ~/.Xauthority-sandbox<DISPLAYNUMBER>
- adds an allow rule for ~/.Xauthority-sandbox<DISPLAYNUMBER>
- adds checks for xhost being properly setup
- honors the --with-xauthority option which can be used with --profile

With the above, the :0.0 display should no longer be accessible. Eg:
$ ./aa-sandbox -t ~/sandbox-xterm -X /usr/bin/xterm
$ XAUTHORITY=~/.Xauthority DISPLAY=:0.0 xinput
No protocol specified
Unable to connect to X server

This requires a specifically configured xauth/xhost setup, which is less common
on modern distributions. The man page details how to get this setup.


= Trying it out =
Apply the patch, then:
$ cd ./utils
# cli
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates --read-path=/proc/ /usr/bin/uptime

# 2d only
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X /usr/bin/gedit

# 2d alternate (xephyr)
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xephyr /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xephyr /usr/bin/gedit

# 3d
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xpra3d /usr/bin/xeyes
$ ./aa-sandbox --templates-dir=`pwd`/easyprof/templates -X --with-xserver=xpra3d /usr/bin/glxgears

# With an existing profile:
$ ./aa-sandbox --profile=/usr/bin/evolution -X --with-xserver=xpra3d /usr/bin/evolution


= The Patch =
The patch itself is pretty self contained:
utils/aa-easyprof:
- adjusted to import optparse

utils/easyprof/templates/sandbox*
- add two new templates to easyprof

utils/apparmor/easyprof.py:
- use 'profile <foo>' if '<foo>' is not an absolute path
- adjust parser handling so we can reuse it

utils/aa-sandbox:
- small script to drive utils/apparmor/sandbox.py

utils/apparmor/common.py:
- the start of our python library. aa-easyprof would eventually use 
  this (along with the various rewrites), but for now, only the 
  sandboxing uses it.

utils/apparmor/sandbox.py:
- the sandboxing code itself. Of particular note is the use of classing
  to support different X servers

utils/aa-sandbox.pod:
- the corresponding man page


= Improvements =
* don't use sudo
* make pulseaudio in xpra opt-in (currently it is off)
* take advantage of upstream's 3D patches when they stabilize
* investigate how applications can work with the Unity global menu
* surely lots more 

[1]http://xpra.org/Xdummy.html
[2]http://xpra.org/trac/ticket/147
2013-01-14 09:11:58 -06:00
Jamie Strandboge
e91ac70739 revert r2080, it doesn't actually help anything 2013-01-14 08:55:53 -06:00
Jamie Strandboge
52d8345a55 merge from trunk 2013-01-14 08:54:29 -06:00
Christian Boltz
c4947a5a1c abstractions/mysql: changed paths and MariaDB support
abstractions/mysql  contains
   /var/lib/mysql/mysql.sock rw,
   /usr/share/mysql/charsets/ r,
   /usr/share/mysql/charsets/*.xml r,

but the files moved (at least on openSUSE) to
    /usr/share/mysql-community-server/charsets/*.xml
    /var/run/mysql/mysql.sock
This causes denials for all applications using MySQL on 12.2 and 
Factory.

MariaDB has the *.xml files in
    /usr/share/mariadb/charsets/*.xml
and also seems to use /var/run/mysql/ for the socket.

Since MariaDB is basically a drop-in replacement for MySQL, it makes
sense to allow access to it via abstractions/mysql.

References: https://bugzilla.novell.com/show_bug.cgi?id=798183

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-01-13 14:38:28 +01:00
Michael Palimaka
f86e2858a2 Respect LDFLAGS. 2013-01-14 00:10:41 +11:00
Michael Palimaka
a9e0ae35ba Remove rootlib configure option.
This option is not referenced anywhere, so it should be safe to remove.
2013-01-13 01:56:56 +11:00