Commit graph

802 commits

Author SHA1 Message Date
John Johansen
54655cf9a4 Add network.c, network.h, missing from previous ci 2014-08-23 23:55:12 -07:00
John Johansen
d3c229fc48 group network rule bits into their own file
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-08-23 23:52:15 -07:00
John Johansen
9fe1e72c44 put the gettext define in one place
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-08-23 23:50:43 -07:00
Christian Boltz
ddd78f97d9 Simplify simple_tests/profile/flags/*bad*.sd testcases to make sure
they only fail because of one (expected) reason and we notice if they
don't fail anymore. Complex profiles have the risk to fail for multiple
reasons, which also means nobody will notice if they fail for one reason
less.

The simplification is done by
- removing #include lines
- in some cases, replace the #include line with "/foo/bar r," to avoid 
  empty hats

Acked-by: Steve Beattie <steve@nxnw.org>
2014-08-16 13:22:51 +02:00
Steve Beattie
0c64863c97 Merge from launchpad translations branch:
* updates to Bosnian, Suomi, and Malay parser translations
* added stub Turkish translation for utils
2014-07-16 11:28:08 -07:00
Launchpad Translations on behalf of apparmor-dev
1619144323 Launchpad automatic translations update. 2014-07-16 05:44:54 +00:00
Christian Boltz
faff4b97c4 We still carry around the initscripts for aa-eventd. Since aa-eventd
is dead since a very long time, move them to the deprecated/ directory.

Acked-by: Steve Beattie <steve@nxnw.org>
2014-07-12 20:51:03 +02:00
Steve Beattie
3bd3573dbb parser: fix unit test for \\ quoting in r2537
The change to processing escape sequences in trunk commit r2537 requires
a corresponding change to the unit tests in parser_misc.c.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-06-19 13:50:57 -07:00
John Johansen
f3fd90ea57 fix: pass through escape sequences that result in aare special chars
escape sequences that result in special character that will be interpreted
by later processing need to be passed through as well.

Eg. previously \\ was fixed to be passed through, but other chars
get interpretted as well.

*?[]{}
and ^, in character classes

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-06-19 13:49:53 -07:00
John Johansen
7f29e7edee Fix: backend processing was not treating ${} as a special pcre character
Also for characters that are not recognized as a valid escape seq
make sure that the character is emitted.

previously
  \$ resulted in \
where it should have been \$ if $ wasn't recognized

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-06-19 13:49:00 -07:00
John Johansen
80cb9dd67b Fix the processing of character escape sequences
r2456 unified escape sequence processing but it results in the \\
sequence being processed multiple times (lexer, regex conversion,
backend pcre parsing).

What used to happen was the lexer would only convert octal sequences
and a few special escapes, \\ would be passed through the lexer and
the regex conversion, thus only being handled in the pcre backend.

r2456 changed that so that \\ is handled by the lexer, converting it
to \, which is handled as an escape sequence in both the regex
conversion and the pcre backend.

This means
  \\001 instead of being treated as the literal \001 is treated
  as an octal escape sequence which is rejected by the regex conversion
  (it only allows for certain special chars).

  etc.

Fix this by ensuring the lexer does not processes \\ and passes it
through so it is only handled in the backend as was done in the past.

Also fix front end escape sequence processing of octals etc from resulting
in a later escape sequence.  That is \134, \d92, .. would get converted
to \ in the lexer and then treated as an escape sequence in the regex
conversion or pcre processing.

We fix this by converting them to the equivalent \\ sequence in the
lexer and letting the backend processes it.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-06-19 13:47:39 -07:00
John Johansen
d2d6cdb1c2 Convert cache to using mtime
For some strange reason our caching use ctime instead of mtime.
However this can lead to odd cases of the cache missing even though
neither the profile data nor cache data have changed.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-06-17 10:59:15 -07:00
John Johansen
4a753029bb Update error message to indicate it is about a binary profile or cache file
Signed-off-by: John Johansen <john.johansen@canonical.com>
2014-06-17 10:58:09 -07:00
John Johansen
8eebcf28ac Bump parser ABI version to 1
Commit r2456 fixes a bug in the parsers compilation that can result
policy failures. Unfortunately this Bug slipped into the wild and
shipped in at least one distro.

Bump the parser abi so that parsers that have the fix will invalid
existing cache files, and recompile policy to ensure the fix is applied.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-06-03 15:29:14 -07:00
Jamie Strandboge
24210c084d Author: John Johansen <john.johansen@canonical.com>,
Jamie Strandboge <jamie@canonical.com>
Description: man page updates for signals, ptrace and new variables

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-05-15 17:22:21 -05:00
John Johansen
fdc55ff203 Move C++ files from .c suffix to .cc suffix
mount.c  -> mount.cc
  dbus.c   -> dbus.cc
  rule.c   -> rule.cc
  signal.c -> signal.cc
  ptrace.c -> ptrace.cc

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-05-09 15:34:34 -07:00
John Johansen
e08eaa39e2 Fix profile loads from cache files that contain multiple profiles
v3: fix freeing of filename when undefined
v2: address tyhicks feedback
    refactor to have a common write routine
    fix issue with set profile load being done even if !kernel_load

Profile loads from cache files that contain multiple profiles can
result in multiple reloads of the same profile or error messages about
failure to load profiles if the --add option is used. eg.

  apparmor="STATUS" operation="profile_load"
  name="/usr/lib/apache2/mpm-prefork/apache2" pid=8631
  comm="apparmor_parser"
  <sth0R> [82932.058388] type=1400 audit(1395415826.937:616):
  apparmor="STATUS" operation="profile_load" name="DEFAULT_URI" pid=8631
  comm="apparmor_parser"
  <sth0R> [82932.058391] type=1400 audit(1395415826.937:617):
  apparmor="STATUS" operation="profile_load"
  name="HANDLING_UNTRUSTED_INPUT" pid=8631 comm="apparmor_parser"
  <sth0R> [82932.058394] type=1400 audit(1395415826.937:618):
  apparmor="STATUS" operation="profile_load" name="phpsysinfo" pid=8631
  comm="apparmor_parser"
  <sth0R> [82932.059058] type=1400 audit(1395415826.937:619):
  apparmor="STATUS" operation="profile_replace" info="profile can not be
  replaced" error=-17
  name="/usr/lib/apache2/mpm-prefork/apache2//DEFAULT_URI" pid=8631
  comm="apparmor_parser"
  <sth0R> [82932.059574] type=1400 audit(1395415826.937:620):
  apparmor="STATUS" operation="profile_replace" info="profile can not be
  replaced" error=-17
  name="/usr/lib/apache2/mpm-prefork/apache2//HANDLING_UNTRUSTED_INPUT"
  pid=8631 comm="apparmor_parser"


The reason this happens is that the cache file is a container that
can contain multiple profiles in sequential order
  profile1
  profile2
  profile3

The parser loads the entire cache file to memory and the writes the
whole file to the kernel interface. It then skips foward in the file
to the next profile and reloads the file from that profile into
the kernel.
  eg. First load
    profile1
    profile2
    profile3

  advance to profile2, do second load
    profile2
    profile3

  advance to profile3, do third load
    profile3


With older kernels the interface would stop after the first profile and
return that it had processed the whole file, thus while wasting compute
resources copying extra data no errors occurred. However newer kernels
now support atomic loading of multipe profiles, so that all the profiles
passed in to the interface get processed.

This means on newer kernels the current parser load behavior results
in multiple loads/replacements when a cache file contains more than
one profile (note: loads from a compile do not have this problem).

To fix this, detect if the kernel supports atomic set loads, and load
the cache file once. If it doesn't only load one profile section
from a cache file at a time.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-05-08 09:03:13 -07:00
Tyler Hicks
ea4cbd68e7 parser: Document that pivot_root arguments must end in '/'
Mention, in the apparmor.d man page, that pivot_root arguments must end
with a '/' character since they are directories.

The parser currently allows pivot_root arguments that do not end in '/',
but those rules will always fail to match.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-05-05 11:36:00 -05:00
Tyler Hicks
46586a6334 parser: Add example dbus rule for unconfined peers
It may not be obvious that the peer label can be "unconfined". Provide
an example rule, in the apparmor.d man page, demonstrating the
peer=(label=unconfined) conditional.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-05-05 11:35:50 -05:00
Launchpad Translations on behalf of apparmor-dev
e7001e0d94 Launchpad automatic translations update. 2014-05-02 05:29:28 +00:00
Steve Beattie
cb5306e2c5 Merge in some Italian translations. 2014-05-01 11:10:21 -07:00
Launchpad Translations on behalf of apparmor-dev
f4c0353061 Launchpad automatic translations update. 2014-05-01 05:27:43 +00:00
Steve Beattie
17fa550665 parser: extend dbus language tests
This patch extends the coverage of the parser's simple dbus language
tests.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-25 21:48:25 -07:00
Steve Beattie
236c7db4b3 parser: add signal language tests
This patch adds basic signal tests to the parser's simple language
test suite.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-25 21:46:06 -07:00
Steve Beattie
0033f683fd parser language tests: force using a features file
With the recent addition of features like ptrace and signals that
give warnings and then ignore the subset of rules when the features
directory indicates that the kernel does not support mediating such
features, at least one of the language tests fails in a chroot
environment where the apparmor securityfs tree is not mounted
inside it.

To compensate, a features file containing the current supported features
is included, and the simple.pl test driver is modified to pass it as an
argument to the parser, so that it will act as if the environment
supports all our current features.

A simple python script is included that was used to generate the
features file based on the current feature set.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-24 12:14:54 -07:00
Steve Beattie
55fe4c4a4e Merge from launchpad translations branch.
What a great lot of gratuitous changes just to get one new translated
Italian string.
2014-04-24 10:26:16 -07:00
Steve Beattie
a67d9be5a2 parser: add implicit set variable @{profile_name} to profile symbol
table

This patch adds the creation of an implicit set variable
@{profile_name} for use within policy. It expands to:

  - a given profile name if specified; e.g. for
      'profile flappy_bird /some/pattern/match* { [...] }'
    @{profile_name} would expand to 'flappy_bird'
  - if no given name, the match pattern; e.g. for
      '/usr/bin/doge_bird { [...] }'
    @{profile_name} would expand to '/usr/bin/doge_bird'
  - hats and child profiles will include the fully qualified name; e.g.
    the 'doge' hat in the /usr/bin/flappy_bird profile would cause
    @{profile_name} to expand to '/usr/bin/flappy_bird//doge' within the
    'doge' hat, and '/usr/bin/flappy_bird' outside of it in the profile.

There are some parsing tests added, but more tests are needed to verify
that expansion occurs properly (I've verified manually using parser
dumps of the added tests, but automated checks are needed).

The @{profile_name} variable is expected to be most useful in the
context of signal and ptrace rules (e.g. for specifying that an app
can send itself signals).

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 16:38:29 -07:00
Steve Beattie
e9019eb650 Subject: parser: refactor symtab unit tests, expand coverage, fix
seenlist bug

This patch:
  - refactors the parser_symtab.c unit tests a bit in preparation for
    the patch to add an implicit autofilled @{profile_name} variable
  - expands coverage of the unit tests such that all code paths that
    don't result in an exit() or are due to memory allocation errors are
    exercised (this doesn't mean the tests are complete; the
    __expand_variable() could use more tests for correctness).
  - it fixes a bug where variables were not being removed from the
    seenlist when a problem was detected in __expand_variable().

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-By: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 16:36:30 -07:00
Steve Beattie
5cf1c6973d parser: add ptrace language tests
This patch adds a bunch of language parsing tests for ptrace rules.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-04-23 12:25:45 -07:00
Steve Beattie
49b51e8070 parser: include rules class entries when dumping profiles
This patch adds the newer rules class entries (e.g. ptrace, signals)
when dumping profiles (invoking the parser with the -dd argument).

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-04-23 12:21:49 -07:00
John Johansen
0cc659cdb4 change syntax of ptrace target
change from
  ptrace /foo,

to
  ptrace peer=/foo,

Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Steve Beattie <steve@nxnw.org>
2014-04-23 11:39:59 -07:00
John Johansen
a1a7c78755 Add the ability to specify ptrace rules
ptrace rules currently take the form of

  ptrace [<ptrace_perms>] [<peer_profile_name>],
  ptrace_perm := read|trace|readby|tracedby
  ptrace_perms := ptrace_perm | '(' ptrace_perm+ ')'

After having used the cross check (permission needed in both profiles)
I am not sure it is correct for ptrace.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:38:04 -07:00
John Johansen
559f0a72fa fix: the what conditional names can be a condlistid
The match
  {VARIABLE_NAME}/{WS}*={WS}*\(

is too broad causing mount and dbus rules to fail for sets of values eg.

  mount options=(ro bind)

Instead of doing a broad match, for now lets lock it down to just
peer=(...) being the only cond that can cause entry into CONDLISTID

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:37:18 -07:00
John Johansen
f19c9f9511 fix: the what names can treated as a condlistid
The match
  {VARIABLE_NAME}/{WS}*={WS}*\(

is too broad causing mount and dbus rules to fail for sets of values eg.

  mount options=(ro bind)

Instead of doing a broad match, for now lets lock it down to just
peer=(...) being the only cond that can cause entry into CONDLISTID

Signed-off-by: John Johansen <john.johansen@canonical.com>
2014-04-23 11:36:26 -07:00
John Johansen
b222731c4f Add the ability to mediate signals.
Add signal rules and make sure the parser encodes support for them
if the supported feature set reports supporting them.

The current format of the signal rule is

  [audit] [deny] signal [<signal_perms>] [<signal_set>] <target_profile>,

  signal_perm  := 'send'|'receive'|'r'|'w'|'rw'
  signal_perms := <signal_perm> | '(' <signal_perm> ([,]<signal_perm>)* ')'
  signal := ("hup"|"int"|"quit"|"ill"|"trap"|"abrt"|"bus"|"fpe"|"kill"|
             "usr1"|"segv"|"usr2"|"pipe"|"alrm"|"term"|"tkflt"|"chld"|
             "cont"|"stop"|"stp"|"ttin"|"ttou"|"urg"|"xcpu"|"xfsz"|"vtalrm"|
             "prof"|"winch"|"io"|"pwr"|"sys"|"emt"|"exists")
  signal_set   := set=<signal> | '(' <signal> ([,]<signal>)* ')'


it does not currently follow the peer=() format, and there is some question
as to whether it should or not. Input welcome.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:35:29 -07:00
John Johansen
b10965b78e Fix: output of apparmor_parser -p having double comma
For some rules the output of apparmor_parser -p has a double comma

Eg.
   ptrace (tracedby),
   dbus (send,receive),
is output as
   ptrace (tracedby),,
   dbus (send,receive),,

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:17:41 -07:00
John Johansen
2e01c945aa Fix garbage characters in -p profile preprocessing output
apparmor_parser -p is broken. Outputting garbage charcters after every
include statement.

eg.

##included <tunables/multiarch>
^@^@V><A8>^?^@^@<C8>^NV><A8>^?^@^@<A0>^Pu^@# -----------------------------------
-------------------------------
#

This is happening because includes are handled specially and should not
go through the usual preprocessing output dump.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:17:08 -07:00
John Johansen
f5494f0331 A few fixes/improvements to the lexer debug output
Signed-off-by: John Johansen <john.johansen@canonical.com>

requires following two fix patches as well which have the acks
2014-04-23 11:16:08 -07:00
John Johansen
77cd2e34a0 Split dfa optimization and dump flag handling into a separate file so that it can be shared with DFA test programs
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-04-23 11:10:41 -07:00
John Johansen
746cecf4b7 Convert to htoleXX fns instead of ifdef on endian
This patch makes use of the htoleXX() functions (see endian(3))
defined as part of endian.h (already included in parser_interface.c),
instead of defining a function differently based on the detection of
endian related macros.

This fixes a build failure experienced on powerpc with John's patch
set applied. This patch has been updated with John's feedback to use
letoh16() in the le16_to_cpu() macro.


Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:07:49 -07:00
John Johansen
564ffd3c8d Move buffer management for the interface to C++ ostringstream class
includes sbeattie's pad calculation fix.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:07:01 -07:00
John Johansen
727489fffd Turn on diff-encoding if the kernel supports it
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:05:58 -07:00
John Johansen
2097398232 The label class is used to lookup object permissions based off of label
alone when the labeling is not path dependent.

Some rules will not generate label entries, some will generate only
label entries and some will generate both label and path entries.
This is left to the particular rule encoding.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:02:25 -07:00
John Johansen
6ecf828a13 Don't use the parser time stamp to determine if policy is newer.
Using the parser timestamp was a work around to force recompilation of
policy that was built with a buggy parser. There are better ways to
handle this so remove checking of the parser timestamp.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:01:33 -07:00
John Johansen
d05313f555 Add the ability to separate policy_version from kernel and parser abi
This will allow for the parser to invalidate its caches separate of whether
the kernel policy version has changed. This can be desirable if a parser
bug is discovered, a new version the parser is shipped and we need to
force cache files to be regenerated.

Policy current stores a 32 bit version number in the header binary policy.
For newer policy (> v5 kernel abi) split this number into 3 separate
fields policy_version, parser_abi, kernel_abi.

If binary policy with a split version number is loaded to an older
kernel it will be correctly rejected as unsupported as those kernels
will see it as a none v5 version. For kernels that only support v5
policy on the kernel abi version is written.

The rules for policy versioning should be
policy_version:
  Set by text policy language version. Parsers that don't understand
  a specified version may fail, or drop rules they are unaware of.

parser_abi_version:
  gets bumped when a userspace bug is discovered that requires policy be
  recompiled. The policy version could be reset for each new kernel version
  but since the parser needs to support multiple kernel versions tracking
  this is extra work and should be avoided.

kernel_abi_version:
  gets bumped when semantic changes need to be applied. Eg unix domain
  sockets being mediated at connect.

  the kernel abi version does not encapsulate all supported features.
  As kernels could have different sets of patches supplied. Basic feature
  support is determined by the policy_mediates() encoding in the policydb.

  As such comparing cache features to kernel features is still needed
  to determine if cached policy is best matched to the kernel.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 11:00:32 -07:00
John Johansen
b9b99508e8 Add tag indicating file policy is mediated.
Tag start of entries in the policydb as being mediated. This makes
the start state for any class being mediated be none 0. The kernel
can detect this to determine whether the parser expected mediation
for the class.

This is just a way of encoding what features expect mediation within
the policydb it self so that a separate table isn't needed.

This is also used to indicate the new unix semantics for mediation of
unix domain sockets on connect should be applied.

Note: this does cause a fail open on situation on Ubuntu Saucy, which
did not properly indicate support. That is if a kernel using this patch
is installed on an Ubuntu Saucy system, unix domain socket mediation
on connect won't happen, instead the older behavior will be applied.
This won't cause policy failures as it is less strict than what
Ubuntu Saucy applies.

This is necessary so that AppArmor can properly function on older
userspaces without a compile time configuration on the kernel to determine
behavior. A kernel expecting this behavior will function correctly
with all old userspaces expect it will not enforce connect time mediation
on Ubuntu Saucy. However Ubuntu does not support Trusty (or newer)
kernels as backports to Saucy, so this does not break them.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 10:59:07 -07:00
John Johansen
f7e12a9bc5 Convert aare_rules into a class
This cleans things up a bit and fixes a bug where not all rules are
getting properly counted so that the addition of policy_mediation
rules fails to generate the policy dfa in some cases.

Because the policy dfa is being generated correctly now we need to
fix some tests to use the new -M flag to specify the expected features
set of the test.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 10:57:16 -07:00
John Johansen
873ae31d29 fix: network detection
The features file patch broke detection of network support.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 10:55:46 -07:00
John Johansen
0d42a832c1 Hack rework of the feature/match file support
This is not the cleanup this code needs, but a quick hack to add the
-M flag so we can specify a feature file (or directory) to use for
the compile.

It mostly just moves around existing code and adds the -M option,
though it does introduce a few changes.

While I didn't do it in this patch I propose we drop support for
the match file without create support. This is several years old
now and would clean things up a lot.

Note: that the manually input -m or -M drop support for it already
I just can't see a good way to support a single input stream indicating
the result/existance of two separate files.

This needs more work but is needed to support tests and the policy_mediates
frame work depends on the policydb getting generated with the special
stub rules to indicate whether policy was compiled expecting a certain
feature. But this can break the current tests, at least once a bug
in the policy rule counting is fixed in a follow on patch.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-04-23 10:53:46 -07:00
Steve Beattie
53216edd1d parser: find SIZE_MAX on older versions of glibc and g++
Another issue with commit 2456 is that with older versions of glibc and
g++, a definition for SIZE_MAX was not being found; e.g. on Ubuntu 12.04
LTS and 12.10, the parser fails to compile with the following error:

  g++ -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat-security -Wunused-parameter -std=gnu++0x -D_GNU_SOURCE -DPACKAGE=\"apparmor-parser\" -DLOCALEDIR=\"/usr/share/locale\" -DSUBDOMAIN_CONFDIR=\"/etc/apparmor\" -I../libraries/libapparmor//include -c -o lib.o lib.c
  lib.c: In function 'int str_escseq(const char**, const char*)':
  lib.c:292:32: error: 'SIZE_MAX' was not declared in this scope

The following patch addresses the issue by explicitly including the C stdint
header which contains the definition for SIZE_MAX.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-04-17 11:10:41 -07:00