Commit graph

444 commits

Author SHA1 Message Date
Steve Beattie
3768096308 Fix compilation errors that slipped in. Yes, I realize this breaks the
one translation string that was intended for regexp.y, sorry.
2011-02-23 14:40:07 -08:00
John Johansen
9df0a29e9e Update the copyright message in apparmor_parser --version 2011-02-22 14:58:49 -08:00
Jamie Strandboge
da1e958eb9 parser/rc.apparmor.functions: Don't unload libvirt's dynamic profiles on
reload. For now just special-case libvirt's profiles. If more applications
use dynamic profiles, this should be generalized in some way to flag profiles
as dynamic. (LP: #702774)
2011-02-22 16:24:29 -06:00
John Johansen
52ca88141a Fix previously committed translation patch that didn't correctly add the
new apparmor-parser.pot file
2011-02-22 11:36:14 -08:00
Jamie Strandboge
fb188972dc parser/rc.apparmor.functions: Don't unload libvirt's dynamic profiles on
reload. For now just special-case libvirt's profiles. If more applications
 use dynamic profiles, this should be generalized in some way to flag profiles
 as dynamic.
2011-02-22 11:14:34 -06:00
John Johansen
d788969c25 Update apparmor_parser translation files
The apparmor_parser translation files where using the old subdomain_parser
domain, but the parser was binding to apparmor-parser.  Create a new
apparmor-parser.pot file and remove the subdomain_parser.pot file.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2011-02-22 03:48:03 -08:00
John Johansen
db70a37621 Update x conflict failure message
Output a better failure message when a conflict of x permissions cause
policy compilation to fail.  We don't have enough information available
to output which rules during the dfa compilation so just improve the
message to let people know that it means there are conflicting x modifiers
in the rules.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2011-02-22 03:47:03 -08:00
Steve Beattie
f471bc4018 Author: Jamie Strandboge <jamie@canonical.com>
Description: the Ubuntu buildds do not have the AppArmor securityfs mounted, so
the cache tests fail. This patch skips these tests if the introspection
directory is not mounted, but runs them if it is. This should allow testing of
local builds while still allowing builds on the official buildds.

Acked-By: Steve Beattie <sbeattie@ubuntu.com> - both Ubuntu and
OpenSUSE were carrying patches that disabled the caching test,
though OpenSUSE's disabled it completely rather than checking. The
parser builds need to complete even when the kernel it's building on
doesn't support AppArmor or all the extensions that the parser needs
at runtime.
2011-02-15 10:41:29 -08:00
Steve Beattie
596cba37e8 From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor-docs: Fix grammar error in techdoc.pdf
References: bnc#588235

This patch fixes a grammar error in techdoc.pdf.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-02-09 14:29:05 -08:00
Steve Beattie
93ae7808cb From: Jeff Mahoney <jeffm@suse.com>
Subject: apparmor-parser: Fix up translations
References: bnc#586070

Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2011-01-14 17:44:51 -06: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
39b5240966 mark parser/tst/simple_tests/xtrans/minimize-x-conflict.sd as "TODO" and hook up parser/tst/Makefile "clean" to parser/Makefile "clean" rule 2010-12-20 13:44:14 -08:00
Kees Cook
b11fd82d96 make gen-xtrans executable 2010-12-20 13:25:54 -08:00
John Johansen
3973387295 Add missing files from my last 11 patches as I forgot to do bzr add before
committing.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 13:18:36 -08:00
Kees Cook
a6dc414f57 adjust line offset now that $Id$ was removed 2010-12-20 13:06:54 -08:00
Kees Cook
723a20ba7d as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
John Johansen
283abda83c Default permission-hashing for dfa creation to on, to fix a bug
When doing permission merging in the dfa minimization phase the information
about whether a rule is dominant or not has been lost so the merge of
xtransitions can not be handled correctly.

When two conflicting x transitions are merged the results are unpredicitable
and not currently detected.  So default dfa minimization to set up its
initial partitions with permission hashing, this ensures that dfa states
that have different xtransitions in the minimization stage will never
be merged thus will not result in a conflict.

x permission checking is still enforced at the dfa creation phase where
the originial information is available to check whether the conflicting
permissions came from exact match or re rules so that conflict resolution
can be properly applied.

The end result is that dfa minimization does not result in a truely minimal
dfa (the minimization phase is also slightly faster).

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:58:44 -08:00
John Johansen
77be2c450f Add the safe xtransition key word
Currently apparmor provides the unsafe keyword to indicate an xtransition
is not scrubbing its environment variables.  This can be used to be
explicit about which transition are unsafe instead of relying on people
remembering which of px Px is safe or unsafe.

Add the orthogonal keyword safe to allow specifying a transition is
safe.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:58:05 -08:00
John Johansen
4eea3ae073 Make meaning of leading permissions consistent with trailing permissions
x Permissions when specified as a the start of the rule had a differnt
meaning than when they appeared at the tail of a rule.

Specifically px,cx,ux were not treated as unsafe when they appeared at
the start of the rule.
  px /foo,
instead of at the tail of the rule
  /foo px,

the keyword unsafe had to be used to force the rule to cause the x transitio
to be its unsafe variant.

Fix leading permissions so that they are consistent with file rules that
use trailing permissions.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:56:57 -08:00
John Johansen
c059224811 Merge parsing of file rules with leading permissions into a single rule
Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:56:30 -08:00
John Johansen
a29078ac04 Add auto generation of tests to verify leading and trailing perms for xrules
Test the leading permission form of an xrule against its trailing permission
form, to verify that they are generating the same xtransition and thus
don't conflict (assumes xtransition conflict checking is working).
  eg.
    px /foo,
    /foo px,

should generate the same rule and thus not result in any conflicts

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:54:27 -08:00
John Johansen
851b7655c1 Add auto generation of xtransition conflict tests
All the combiniation of xtransition conflics where not well represented in
the regression test suite.  Instead of relying on multiple static test
files, automatically generate all possible conflicts.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:53:52 -08:00
John Johansen
bdea9e5678 Fix two x transition conflict bugs.
The is_merged_x_consistend macro was incorrect in that is tested for
USER_EXEC_TYPE to determine if there was an x transition.  This fails
for unconfined execs so an unconfined exec would not correctly conflict
with another exec type.

The dfa match flag table for xtransitions was not large enough and not
indexed properly for pux, and cux transitions.  The index calculation did
not take into account the pux flag so that pux and px aliased to the same
location and cux and cx aliased to the same location.

This would result in the first rule being processed defining what the
transition type was for all following rules of the type following.  So
if a px transition was processed first all pux, transitions in the profile
would be treated pux.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:52:53 -08:00
John Johansen
6d6df2a16b Make libaare built depend on immunix.h
The dfa engine uses the defines from immunix.h for permission conflict
checking, so make the build depend on it.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:52:10 -08:00
John Johansen
240c4e3674 Fix error checking of conflicting x-trans during dfa construction.
During some of the dfa cleanups, the checks for conflicting xtransition
was removed.  This adds the conflict checking back in and makes it part
of dfa creation.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:51:20 -08:00
John Johansen
fb61ea7635 Fix xtrans tests
Several of the x-trans tests where failing because of the include file was
bad.  This kept the test from testing what it was supposed as the test
was expected to fail.  Thus hidding a bug :(

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:50:31 -08:00
John Johansen
d4ca9f3ba0 Add profile names that are independent of attachment specification
Add the ability to specify the name and attachment of the profile
separately. It does not allow for the attachment specification to
begin with a variable however since variables in profile names is not
currently support this shouldn't be and issue.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-12-20 11:49:42 -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
Jamie Strandboge
e5f4aa4140 parser/apparmor.d.pod: more fully document child profiles, including:
- cx and Cx
  - change_profile()
2010-12-20 13:40:59 -06:00
Jamie Strandboge
289dcfb492 add [^] 2010-12-20 12:50:53 -06:00
Jamie Strandboge
79828d1f10 LP: #349049: document audit, deny and owner rule qualifiers 2010-12-20 12:48:26 -06:00
Jamie Strandboge
2ade2782d4 parser/apparmor.d.pod: clarify alias rules 2010-12-20 08:34:12 -06:00
John Johansen
34c78d34b1 Combine hat and local profile parsing into the same base rule as profile
parsing.
2010-12-13 16:29:16 -08:00
John Johansen
7c1f5fd932 Merge profile and :namespace:profile parsing into a single rule.
clean up profile parsing by merging profile and :namespace:profile parsing
into a single rule.

This also fixes a bug where the profile	keyword was not allowed to proceed
profiles with a namespace declaration.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2010-12-13 16:26:38 -08:00
Steve Beattie
810f54ffdd Bug: https://bugzilla.novell.com/show_bug.cgi?id=510740
Short summary: Unloading of profiles with a space in the name fails,
therefore "rcapparmor stop" (or restart) causes a funny message - and
the profile is still loaded.

Thanks to Christian Boltz <apparmor@cboltz.de>
2010-11-29 13:40:45 -08:00
Steve Beattie
8740fd517d This patch fixes the parser's lexer to not passthrough other invalid
characters in variable declarations. It also adds testcases
demonstrating the issue.
2010-11-19 02:27:33 -08:00
Steve Beattie
7ef28d9fdc This patch fixes the parser to return an error when variable declaration
statements contain trailing commas, instead of passing them through to
STDOUT. It also adds parser testcases demonstrating the issue.
2010-11-19 01:42:04 -08:00
Steve Beattie
83c4a5132e This minor patch updates the compilation dependencies for bits of the
parser that interact with the regex DFA generation library, and thus
need to be recompiled when the header file changes.

(This patch isn't particularly of interest to distros, as they
typically won't be doing incremental compilation.)
2010-11-12 13:38:21 -08:00
John Johansen
85c133cd84 Rework the code so that update for nodes is now a function
The other changes have made it so that using a macro really isn't justified
so rework the code to get rid of the hiddeous update_for_nodes macro.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:20:32 -08:00
John Johansen
d551a1a9ab Make the work_queue be a work_queue of states that need finished computing
With the addition of the nodes field to the state we can make the work
queue, be based off of the state instead of the node, and avoid doing
the node to map lookup to get back to the state.

This means that the NodeMap is now only used for duplicate elimination.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:19:47 -08:00
John Johansen
e87e45c0a2 Factor updating the state transitions into its own fn
Factoring the updating of the state transitions doesn't save on any code
but it provides a nice logical seperation and makes the dfa work_queue
loop and the updating of the state transitions easier to understand as
units.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:18:48 -08:00
John Johansen
72aa490e49 Factor adding a new state to the dfa the map into its own function
Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:16:38 -08:00
John Johansen
35d55fce81 Move state label, nodes, and permission setting into the State constructor
Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:14:12 -08:00
John Johansen
5578299445 Group dfa stats into a single structure.
Move the dfa stats into a structure to provide a single access point to
them.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:12:50 -08:00
John Johansen
99a7991664 Rename the match_count variable to duplicates
The match_count variable is a sum of the number of duplicates node sets
that have been encountered and discarded.  Rename it to better reflect what
it is doing.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:09:05 -08:00
John Johansen
15567a55dc Embedded the temporary computed nodes as part of the state
Embedding the nodes are part of the state gives fast back reference from
the state to the nodes that created it.  This is useful for the state to
nodes mapping dump as it lets us output the states in order.  It will also
let us avoid certain nodemap lookup in the future.

Overlay the nodes field (used only in dfa construction) with the partition
field which is only used during dfa minimization to avoid making the state
any larger.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:08:02 -08:00
John Johansen
5b68e0f7c4 Fix comment about what state information is being dumped
Signed-off-by: John Johansen <john.johansen@canonical.com>
2010-11-11 16:06:52 -08:00
Kees Cook
eaa6a3c297 This cleans up a number of warnings that appeared after the parser rework
commits were made (as well as a few other minor warnings elsewhere).

The Makefile change is to avoid passing -Wstrict-prototypes and
-Wnested-externs to the C++ compiler, which the compiler yells about and
then ignores.

Since we compile with -Wmissing-field-initializers I dropped the
unreferenced zero-width fields in the header structs, and then explicitly
initialized the remaining fields.

I tagged several unused function parameters to silence those warnings.

And finally, I dropped the unused filter_escapes() too.
2010-11-09 13:39:18 -08:00
John Johansen
d53bb7f811 Embedded the State to partition mapping into the State.
Embedding the the partition mapping into the State structure significantly
speeds up dfa minimization, by converting rbtree finds to straight direct
references when checking for same mappings.

The overall time improvement is small but it can half the time spent in
minimization.
2010-11-09 11:57:43 -08:00
John Johansen
29c6f7e3ac Re-enable the ability to invoke remove-unreachable-states.
Now that removing unreachable states is not on by default re-enable the
ability to turn it on.
2010-11-09 11:56:58 -08:00