Commit graph

9 commits

Author SHA1 Message Date
John Johansen
532d52309e parser: call filter slashes for mount conditionals
The mnt_point and devices conditionals in mount rules are generally
paths and should have slashes filtered after variable expansion.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/607
Signed-off-by: John Johansen <john.johansen@canonical.com>
(cherry picked from commit a1978fb1b2)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:45:46 -07:00
John Johansen
fd708dc939 parser: enable variable expansion for mount type= and options=
Currently mount options type= and options= do not expand variables
but they should. Fix it.

Note: this does not treat either as paths because their use is
too device dependent for it to be safe to filter slashes.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/99
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/638
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
(cherry picked from commit 882380ad3d)
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-10-09 02:45:46 -07:00
John Johansen
a0706d3a46 And the related patch to fix globbing for af_unix abstract names
Abstract af_unix socket names can contain a null character, however the
aare to pcre conversion explicitly disallows null characters because they
are not valid characters for pathnames. Fix this so that they type of
globbing is selectable.

this is a partial fix for

Bug: http://bugs.launchpad.net/bugs/1413410

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2015-02-12 10:19:16 -08:00
Tyler Hicks
0bf2e4f2e1 parser: Fix typo in mount rule error message
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-12-12 08:21:31 -06:00
Tyler Hicks
7140bc27c3 parser: Fail compilation if unknown mount options are found
The parser should not indicate success when mount rules contain
unknown mount options:

  $ echo "/t { mount options=(XXX) -> **, }" | apparmor_parser -qQ
  $ echo $?
  0

This patch modifies the parser so that it prints an error message and
exits with 1:

  $ echo "/t { mount options=(XXX) -> **, }" | apparmor_parser -qQ
    unsupported mount options
  $ echo $?
  1

Bug: https://bugs.launchpad.net/bugs/1401621

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-12-12 08:20:49 -06:00
Tyler Hicks
d336d23e4d parser: Sync mount options parsing and documentation
There are a number of differences between what the apparmor.d(5) man
page lists as valid AppArmor mount rule options and what apparmor_parser
looks for when parsing mount rules. There are also typos in the man page
and parser around mount options. Here's the breakdown of problems and
fixes made in this patch:

 * The apparmor.d(5) man page improperly documented a "nodirsync"
   option.
   - That mount option does not exist and the parser did not honor it.
     Remove the mention from the apparmor.d(5) man page.
 * The loud option was typoed as "load" in both the man page and parser
   - There's no sense in preserving backwards compatibility. "load" is
     simply wrong and should not be honored. The man page and parser are
     updated to only use "loud".
 * The rbind option wasn't listed in the man page.
   - Add rbind to the man page. No change needed for the parser.
 * The documented unbindable, private, slave, and shared options were
   not correctly parsed. The parser expected
   make-{unbindable,private,slave,shared}.
   - The parser is updated to accept both the documented
     {unbindable,private,slave,shared} options and their variants
     prefixed with "make-". The man page will not document the "make-"
     variants.
 * The recursive {runbindable,rprivate,rslave,rshared} options were not
   documented and were only recognized by the parser if they were
   prefixed with "make-".
   - The man page is updated to document the option strings that are not
     prefixed with "make-". The parser still accepts the "make-"
     variants.
 * The man page documented a "rec" option but the parser didn't honor
   it. The MS_REC macro is used by the mount utility to be bitwise OR'ed
   with MS_{UNBINDABLE,PRIVATE,SLAVE,SHARED} to indicate the
   corresponding recursive mount options.
   - This is not an option that should be exposed in the AppArmor policy
     since we already allow have the
     {runbindable,rprivate,rslave,rshared} options.
 * The man page typoed the {no,}relatime options as {no,}relative.
   - The man page is updated to document the correct option strings. The
     parser requires no change.

Bug: https://bugs.launchpad.net/bugs/1401619

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-12-12 08:20:31 -06:00
John Johansen
c2b8a72317 disable downgrade and not enforced rule messages by default
Currently the apparmor parser warns about rules that are not enforced or
downgraded. This is a problem for distros that are not carrying the out of
tree kernel patches, as most profile loads result in warnings.

Change the behavior to not output a message unless a warn flag is passed.
This patch adds 2 different warn flags
  --warn rule-downgraded    	 # warn if a rule is downgraded
  --warn rule-not-enforced	   # warn if a rule is not enforced at all

If the warnings are desired by default the flags can be set in the
parser.conf file.

v2 of patch
- update man page
- add --warn to usage statement
- make --quiet clear warn flags

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-08 13:20:20 -07:00
Steve Beattie
a44b6ce0a2 C tools: rename __unused macro to unused
Bug: https://bugzilla.novell.com/show_bug.cgi?id=895495

We define the __unused macro as a shortcut for __attribute__((unused))
to quiet compiler warnings for functions where an argument is unused,
for whatever reason. However, on 64 bit architectures, older glibc's
bits/stat.h header defines an array variable with the name __unused
that collides with our macro and causes the parser to fail to build,
because the resulting macro expansion generates invalid C code.

This commit fixes the issue by removing the __unused macro where it's
not needed (mod_apparmor) and renaming it to 'unused' elsewhere. It also
in some instances reorders the arguments so that the unused macro
appears last consistently.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
2014-10-02 12:58:54 -07: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
Renamed from parser/mount.c (Browse further)