Commit graph

1619 commits

Author SHA1 Message Date
Jamie Strandboge
1b78752db6 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 22:08:28 -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
36f6da62aa update ubuntu abstractions to use '# vim:syntax=apparmor' 2010-12-21 12:54:57 -06:00
Jamie Strandboge
046cfe305f update ubuntu abstractions to use '# vim:syntax=apparmor' 2010-12-21 12:53:33 -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
acfcdfe750 ignore generated manpages 2010-12-20 14:02:03 -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
Kees Cook
46e96476d8 add python2.7 to python abstraction, LP: #644983
Bug: https://launchpad.net/bugs/644983
2010-12-20 12:10:52 -08:00
Jamie Strandboge
b3c6ec3ded add aa_change_profile.pod manpage and reference it in aa_change_hat.pod 2010-12-20 14:01:58 -06: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
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
77b864527a changehat/mod_apparmor/mod_apparmor.pod: make several clarifications and
add a summary for the order of operations
2010-12-20 13:45:56 -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
7296af3f39 mod_apparmor.pod: adjust for Canonical, launchpad and Ubuntu binaries and tools 2010-12-20 08:35:00 -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