Commit graph

895 commits

Author SHA1 Message Date
Christian Boltz
d799edbcc6 create-apparmor.vim.sh:
- move cap_sys_module and cap_sys_rawio to "dangerous" capabilities
- sorted sdKapKeyDanger

Proposed by Seth Arnold,
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-04-09 18:47:42 +02:00
Christian Boltz
5b3190d39c Add files to generate apparmor.vim to bzr.
Basically the files will generate apparmor.vim as included in openSUSE 
11.4 (and posted here before at the end of january). The only difference 
is that the patch that Steve posted some days ago is already included 
(patch summary: sdGlob: first character of variable name has to be 
 :alpha:, followed by any number of :alnum: or _)
2011-04-05 23:56:14 +02:00
Steve Beattie
f8b43d5ba9 The parser's lexer supports variables defined matching the regex
'[[:alpha:]][[:alnum:]_]*' (i.e. a single alpha followed by any number
of alphanumerics or underscores). Unfortunately, the code that expends
variables inside a profile does not match this, it incorrectly matched
'([[:alpha:]]|_)+' (one or more alphas or underscores). This patch
corrects the behavior there as well as synchronizing the expected
variable names in the apparmor.d manpage and apparmor.vim syntax file.

It also adds unit tests and testcases to verify the behavior.

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
2011-03-28 10:52:02 -07:00
John Johansen
6e6b57fbd1 Sync apparmor.vim to the latest version from Christian Boltz
Signed-off-by: John Johansen <john.johansen@canonical.com>
2011-02-22 03:57:37 -08:00
Steve Beattie
a39d6e36e8 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor-utils: Inherit flags in sub-profiles when generating profiles
References: bnc#496204

 When creating profiles with cx subprofiles, genprof will set the
 sub-profile in enforce mode. When genprof cycles multiple times, it
 prohibits the sub-profile from working correctly.

 e.g.

 # Last Modified: Mon Jan 24 13:52:26 2011
 #include <tunables/global>

 /home/jeffm/mycat flags=(complain) {
   #include <abstractions/base>
   #include <abstractions/bash>
   #include <abstractions/consoles>

   /bin/bash ix,
   /bin/cat cx,
   /home/jeffm/mycat r,

 profile /bin/cat {
     #include <abstractions/base>

     /bin/cat r,
     /home/jeffm/mycat r,

   }
 }

 This patch allows sub-profiles to inherit the flags from the parent
 profile, which allows it to be created in complain mode (if appropriate).
 The temporary complain flags are cleaned up at genprof completion as
 expected.

 This issue was reported at: https://bugzilla.novell.com/show_bug.cgi?id=496204

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>

Bug: https://launchpad.net/bugs/707092
2011-02-15 16:26:05 -08:00
Steve Beattie
4e01f55a81 From: Jeff Mahoney <jeffm@suse.com>
Subject: Subdomain.pm: Fix for null path
References: bnc#407959

When handling the following log entry, logprof will spew perl errors and
ultimately generate an invalid config: "r,"

Since there is nothing to do with a null path, just skip to the next entry.

type=APPARMOR_DENIED msg=audit(1214497030.421:39): operation="inode_permission" info="Failed name resolution - object not a valid entry" requested_mask="r" denied_mask="r" pid=31367 profile="/usr/sbin/httpd2-worker

Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-02-15 14:45:04 -08:00
Steve Beattie
4c8d4490cb From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor: Subdomain.pm: Fix handling of audits of unconfined processes

 The version of AppArmor that was accepted into the mainline kernel
 issues audit events for things like change_hat while unconfined.
 Previous versions just returned -EPERM without the audit.

 This results in logprof and friends spewing uninitialized value errors
 when it hits events like:
 type=AVC msg=audit(1291742101.899:220): apparmor="DENIED" operation="change_hat" info="unconfined" error=-1 pid=28005 comm="cron

 ... which happen any time an unconfined process does something with pam
 when pam_apparmor is installed.

 This patch skips those events.

[Note that the second half of the OpenSUSE patch had already been applied.]

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-02-15 11:16:28 -08:00
Steve Beattie
3c8538c0c6 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor-utils: Translation unification
References: bnc#586072

 This patch removes small inconsistencies between identical strings to
 allow for easier translation.

Reported-by: Isis Binder <isis.binder@gmail.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-02-08 16:29:59 -08:00
Steve Beattie
4df8c4c09c Purge utils/severity.pl due to incorrect license/copyright statement. It
should have been covered under both the Immunix acquisition by Novell
Inc and by the open sourcing of the apparmor tree by Novell Inc.
2011-02-08 15:50:51 -08:00
Steve Beattie
bf9a559dcc From: Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH] apparmor-utils: cleanup after abort in genprof
References: bnc#307067

 The initial generation of the base profile is required to be written out
 to put the process in complain mode for observation. If the user
 decides to abort the profiling session, that base profile is left
 behind.

 This patch removes all profiles created during the run up to an abort.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
2011-02-08 14:50:43 -08:00
Steve Beattie
974d0a33b0 Remove obsolete rc.sd-event-dispatch.suse; was replaced by not nearly
but almost as obsolete aa-eventd and controlled by the main apparmor
initscript.

Acked-by: John Johansen <john.johansen@canonical.com>
2011-02-08 14:21:51 -08:00
Steve Beattie
ef2fa2c895 From: Jeff Mahoney <jeffm@suse.com>
utils/Immunix/Reports.pm: s/SubDomain/AppArmor/ in header comment
2011-02-08 13:58:52 -08:00
Steve Beattie
fb8d5d05dc From: Jeff Mahoney <jeffm@suse.com>
utils/Makefile: abstract out the perl vendor location for distros to
override if necessary
2011-02-08 10:39:44 -08:00
Steve Beattie
cef7289d75 From: Jeff Mahoney <jeffm@suse.com>
Fix grammar in in utils UI text.
2011-02-08 10:25:05 -08:00
Jamie Strandboge
61e7aac455 make aa-disable executable 2011-02-07 21:02:57 -06:00
Jamie Strandboge
74b2fdc52c update documentation for aa-disable 2011-02-07 17:39:54 -06:00
Jamie Strandboge
1459c9eb20 add aa-disable 2011-02-07 17:39:36 -06:00
Steve Beattie
1005bfdf7e Subject: logprof - variable definitions should not have trailing commas.
This patch fixes a logprof bug where when profiles with variable
declarations at the top level (not hidden in an include) were written
back to a file, a trailing comma was being added to the declaration
statement, which is invalid apparmor policy syntax. This patch corrects
this and no longer adds the trailing comma.
2011-02-04 21:20:58 -08:00
John Johansen
52453313c1 Update to latest version of apparmor.vim from Chritian Boltz 2011-01-26 06:43:39 -08:00
Steve Beattie
6f620e9247 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor: Fix network event parsing
References: bnc#665483

 The upstream version of AppArmor had network mediation but it was
 removed. There's a compability patch floating around that both openSUSE
 and Ubuntu have applied to their kernels. Unfortunately, one part was
 overlooked. The socket operation event names where changed from the
 socket_ prefixed names they had when AppArmor was out-of-tree and
 utils/SubDomain.pm was never updated to understand them.

 This patch adds an operation-type table so that the code can just
 do a optype($operation) call to discover what type of operation a
 particular name refers to. It then uses this in place of the socket_
 checks to decide whether an event is a network operation.

 This allows genprof and logprof to work with networking rules again.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>

Bug: https://launchpad.net/bugs/706733
2011-01-24 15:49:46 -08:00
Kees Cook
14d8bac7b2 Here's an update to rename another chunk of things that still used
"SubDomain" in some way. This leaves only "subdomain.conf" and the
function names internally.

Additionally, I added a "make check" rule to the utils/Makefile to do a
simple "perl -c" sanity check just for good measure.
2011-01-13 13:58:26 -08:00
Kees Cook
dd3a964249 drop /var/log/apparmor, stop installing Reports.pm, use LOGPROF_DEBUG as the debugging target instead of /var/log/apparmor 2011-01-13 09:13:34 -08:00
Steve Beattie
d088727bdf Support newer auditd formatted messages. Patch from mancha on irc.
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-12 13:57:19 -06:00
Jamie Strandboge
ca30e18692 utils/Config.pm: disable the repository by explicitly setting
$config->{repository}{enabled} = "no" (LP: #692406). We need to do this
since opensuse's site is down and there is no current alternative. Can
reenable once we have an alternative.
2010-12-21 16:56:21 -06:00
Jamie Strandboge
5272c9ef0a utils/apparmor.vim: update comments on how to use 2010-12-21 10:55:24 -06:00
Jamie Strandboge
aa7304f01e utils/apparmor.vim: remove trailing whitespace 2010-12-21 10:45:33 -06:00
Kees Cook
723a20ba7d as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
Kees Cook
319777962b update RPM spec, thanks to Christian Boltz. See https://bugzilla.novell.com/show_bug.cgi?id=619893 2010-12-20 12:01:23 -08:00
Jamie Strandboge
49f27414e0 update the man pages to:
* add Canonical to the headers of the pod files touched
  * use aa_change_hat() instead of change_hat() (LP: #692216)
  * use http://wiki.apparmor.net in the SEE ALSO
  * use http://https://bugs.launchpad.net/apparmor/+filebug for bugs
  * prefix 'aa-' in SEE ALSO section for utilities (eg, 'aa-complain' for
    'complain')
2010-12-20 13:47:09 -06:00
Kees Cook
485df894ab This fixes a few typos in documentation that lintian noticed. 2010-11-04 14:27:30 -07:00
Kees Cook
38cefc358a add symlink for manpage as well 2010-11-04 13:36:38 -07:00
Kees Cook
6d2d55057c retain one backward compat symlink for the heavily-documented "apparmor_status" command 2010-11-04 11:52:33 -07:00
Kees Cook
6717e29909 Here is a patch to standardize on all utils using the "aa-" prefix instead
of a mix of symlinks to non-prefixed comands, and "apparmor_" prefixed
commands.

This also refactors the manpage generation slightly since we no longer
need special cases for the manpages, and drops aa-eventd from the default
list of tools to install (it also lacks a manpage).
2010-11-03 17:03:52 -07:00
Steve Beattie
7e0969bf82 From: Jesse Michael <jesse@lonelyrhinoceros.com>
This just adds prototypes to all functions to make further cleanup
slightly easier by getting perl to complain if not enough args are
passed to a function.  Perl doesn't appear to complain about this in
every case even with prototypes, which is kind of annoying.
2010-10-06 13:06:05 -07:00
Steve Beattie
8e51a7b31e From: Jesse Michael <jesse@lonelyrhinoceros.com>
One of the uses of eval { } wasn't checking $@ for errors, so if
something bad happened, it'd be silently ignored.  This just adds in
an extra check to die if we hit a failure.
2010-10-06 12:21:56 -07:00
John Johansen
513611ff92 Fix memory leak where apparmor_notify is not freeing up messages that
are not reported.
2010-09-09 10:40:38 -07:00
John Johansen
fe3cce7828 Default apparmor_notify to report messages, when it is installed and
started.  Since apparmor_notify is not installed by default and not started
by default, the act of installing and starting it implies the desire to
get messages.
2010-09-09 10:31:45 -07:00
Steve Beattie
046e1fb215 This is an incomplete fix for bug
https://bugs.launchpad.net/apparmor/+bug/623467

This patch adds some additional testcases to the log parsing
testsuite, to cover rejections for operations that aren't covered by
other testcase (truncate, rename_src, rename_dest, mkdir) as well
as fixing SubDomain.pm to take those operations into account when
parsing log files.

The operations link, unlink, and possibly setattr still need to be
covered by SubDomain.pm
2010-08-25 09:53:39 -07:00
Kees Cook
5649f5237b Add testcases for new LSM-audit log messages.
Update log parser grammar to handle new LSM-audit log messages.
2010-07-26 09:16:23 -07:00
Jamie Strandboge
a029b16066 apparmor_notify:
- verify $opt_s is initialized (LP: #582075)
- don't show summary if $opt_s < 1
2010-05-27 09:08:12 -05:00
Jamie Strandboge
ea4756a802 ##rmor_notify: show last date when using -s # -v 2010-05-14 00:08:31 +02:00
Jamie Strandboge
7d76eea05a apparmor_notify: show last date when using -s # -v 2010-05-14 00:07:32 +02:00
Jamie Strandboge
8e97e4a405 apparmor_notify: add long options. Your welcome Steve ;) 2010-05-12 10:46:22 +02:00
Jamie Strandboge
96b1328967 apparmor_notify: adjust '(3 total)' to '(3 found)' 2010-04-08 23:00:52 -05:00
Jamie Strandboge
0254d63fdc apparmor_notify: group like entries together when using -v with -s. Eg:
$ sudo apparmor_notify -s 1 -v
 Profile: /usr/lib/firefox-3.6.3/firefox-*bin
 Operation: exec
 Name: /usr/bin/apturl
 Denied: ::x
 Logfile: /var/log/audit/audit.log

 Profile: /usr/sbin/ntpd
 Operation: open
 Name: /var/lib/ntp/ntp.conf.dhcp
 Denied: r::
 Logfile: /var/log/audit/audit.log
 (3 total)

 AppArmor denials: 4 (since Wed Apr  7 22:57:56 2010)
 For more information, please see: https://wiki.ubuntu.com/DebuggingApparmor
2010-04-08 22:57:04 -05:00
Jamie Strandboge
c38f0f22bc apparmor_notify: remove stray print 2010-03-30 12:26:32 -05:00
Jamie Strandboge
24446dd1d0 apparmor_notify.pod: add -u and -w options 2010-03-30 10:48:51 -05:00
Jamie Strandboge
cd90674f37 apparmor_notify: fix reopening logfile after dropping privileges (ie, notice
when auditd logs get rotated)
- use getgrnam() with setgid when dropping to nobody_group
- add '-u USER' option to drop to this user when running priviliged but
  not under sudo. Useful for starting when logged in as root.
- add a read access check before get_logfile_inode() so we don't have to
  wait for the timeout in get_logfile_inode()
- set euid only when dropping privileges, instead of using POSIX::setuid()
  which sets uid, euid and saved id when starting privileged
- create send_message() function which fork/execs so that we can set the
  real uid before calling notify-send (notify-send looks at the real uid
  when trying to connect to dbus)
- adjust reopen_logfile() to raise privileges (via euid) before accessing
  logfile when $< != $>. Drop them again after open().
2010-03-30 10:31:23 -05:00
Jamie Strandboge
4cfe8e9d48 apparmor_notify.pod: update for -f 2010-03-27 09:16:38 -05:00
Jamie Strandboge
5ceb1fa1c9 apparmor_notify:
- also check for inode change
- update size to use stat
- treat logfile_size like logfile_inode
- update logfile_size and logfile_inode in reopen_logfile()
2010-03-27 09:14:33 -05:00