Commit graph

713 commits

Author SHA1 Message Date
Steve Beattie
bedcb8c19c Merge from lp translations branch: a few de updates, some en_GB additions. 2014-10-17 12:07:51 -07:00
Launchpad Translations on behalf of apparmor-dev
c504acb09e Launchpad automatic translations update. 2014-10-17 05:36:15 +00:00
Steve Beattie
39b9985afb utils: make html version of apparmor.vim manpage
Bug: https://bugs.launchpad.net/bugs/1366572

In the move of the apparmor.vim manpage source from the parser
directory to utils/vim/, the creation of the html version of the
manpage was lost.  This patch fixes that, as well as fixes the vim
Makefile to use the common/Make.rules _clean target (which clears the
pod2htm*.tmp files created by pod2html as well).

It also fixes a bug in common/Make.rules where the _clean target
would report an error when used in a directory where the Makefile
doesn't set the NAME variable, such as utils/vim/.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-10-16 15:50:13 -07:00
Christian Boltz
2758e2e2a1 apparmor.vim: add support for the "hat" keyword
Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-16 23:55:43 +02:00
Christian Boltz
1203923be3 more aa-mergeprof fixes
- change --help for files - "Profile(s) to merge" instead of "base profile"
- display the profile to save when asking to save it
- disable searching for existing network rules in abstractions because 
  it crashes. This doesn't hurt too much, see 
  https://bugs.launchpad.net/apparmor/+bug/1382241


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-16 23:35:06 +02:00
Christian Boltz
aeebcbc243 various aa-mergeprof fixes
- remove some debug output (which Kshitij intentionally kept in the 
  draft patch)
- add a UI_Info to display which profile will be merged
- disable the mergeprofiles.clear_common() call because it crashes
  (https://bugs.launchpad.net/apparmor/+bug/1382236)
- disable (M)ore (CMD_OTHER) because it crashes
- make (F)inish work everywhere
- change the help text so that it doesn't mention 3-way-merge until we
  implement it
2014-10-16 23:25:33 +02:00
Christian Boltz
31c4dc80a8 fix parsing of "hat foo {" lines
The python utils didn't know about the hat keyword, for example
    hat foo {

This patch changes RE_PROFILE_HAT_DEF to add support for the hat keyword.

Note that this patch only changes profile reading - when saving a 
profile, the ^foo syntax will always be used.

While on it, also convert the regex to named matches - the result 
numbering changed anyway ;-)


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-10-16 22:03:42 +02:00
Christian Boltz
31a57bdfa9 update the aa-mergeprof manpage to match the new commandline syntax
introduced with the aa-mergeprof patch collection.

Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-16 20:26:45 +02:00
Christian Boltz
4f4eded593 aa-mergeprof: don't ask for includes that are already there
Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-16 20:22:52 +02:00
Christian Boltz
4f9183b23e aa-mergeprof cmdline changes, disable 3-way-merge for now
This is the rebased version of the patch by
Kshitij Gupta <kgupta8592@gmail.com>


(mostly) original patch description:

Changes to facilitate 2-way merge (maybe also 3-way) of multiple
profiles as discussed on IRC

This patch
- moves reset method to reset_aa function
- modifies message displayed to user
- allows processing of multiple files in 2-way merge
- disables 3-way merge till new syntax has been decided

The changes reflect the approach of providing arbitrary number of
files using wildcards or explicitly.

The changes map the profiles in the given files to their respective
files in the local directory specified using -d. Then the merges take
place profile-wise.


Acked-by: Steve Beattie <steve@nxnw.org>.
2014-10-16 20:06:45 +02:00
Christian Boltz
3cb61c5dae highlight comments in alias and link rules with correct color
(in blue, instead of the color used for the rule itsself)

Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-14 21:36:41 +02:00
Christian Boltz
c613d8a884 fix "list index out of range" when allowing inet rules
When adding inet rules in aa-logprof, it crashes with
    IndexError: list index out of range

The reason is that it doesn't display the options if only the raw rule
is available (aka "no abstraction").

This patch checks if options[] is set and otherwise sets selection to
the raw rule.


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-14 21:28:32 +02:00
Christian Boltz
d11055aa0c Fix "Invalid mode found: /usr/lib64/firefox/firefox.sh"
After several hours of debugging on IRC and flooding paste.opensuse.org ;-)
I finally found the reason - reading(!) from log_dict with a wrong 
key caused the creation of that strange mode in log_dict.keys().

While finding that bug was very hard, the fix is easy - just replace 
"profile" with "aamode". (That probably makes one char per hour of 
debugging...)

To improve that ratio, also add a warning to common.py so that this 
interesting[tm] behaviour of hasher() is at least documented.


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-14 12:54:39 +02:00
Christian Boltz
7e84f4efe9 If a filename mentioned in audit.log contains an @, aa-logprof crashes with
...
  File "/home/cb/apparmor/HEAD-CLEAN/utils/apparmor/severity.py", line 147, in handle_variable_rank
      variable = regex_variable.search(resource).groups()[0]
	  AttributeError: 'NoneType' object has no attribute 'groups'

handle_variable_rank() checked with   if '@' in resource:
and if it finds it, expects it can match a variable, which means   @{.....}
If a filename contains a   @   this fails.

The patch fixes the if condition so that it does a regex match.

It also adds two testcases for filenames containing @ to make sure they
don't cause a crash and result in the exptected severity rank.


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-14 12:50:20 +02:00
Christian Boltz
9a960a22a9 prevent adding multiple quotes in file rules
aa-cleanprof (and others?) duplicate quotes in file rules.

If a profile contains
      "/bin/foo bar" mrix,
and I run aa-cleanprof on it several times, I end up with
   """"""/bin/foo bar"""""" mrix,

This patch calls strip_quotes on the pathname.
(If needed, the quotes are re-added when writing the profile - tested 
with aa-cleanprof.)

References: https://bugs.launchpad.net/apparmor/+bug/1328707


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-10-11 23:30:46 +02:00
Christian Boltz
7ef2ae9b05 Prevent encoding errors when reading a file
This patch changes open_file_read() and open_file_write() to use 
errors='surrogateescape' (with fallback to 'replace' for py2).

This avoids a crash when reading a logfile with special characters that 
are not utf8-encoded (for example a latin1 "ö"), and also avoids crashes 
at several other places we don't know yet ;-)

The patch also changes open_file_read() and open_file_write() to wrapper
functions, and moves the "real" code to the new open_file_anymode() 
function.

Also, I removed the try/except - it's superfluous because it throws the 
exception without any modifications.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-10-10 20:35:32 +02:00
Kshitij Gupta
8bc6a176f6 Fix: fix aa-genprof to use new PromptQuestion class
The following patch:
- ensures aa-genprof also uses class based prompt

Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-10-09 01:37:18 +05:30
Steve Beattie
1e437a3cd8 utils: fix missed conversion in move to more class based approach
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-10-08 11:05:01 -07:00
Steve Beattie
22af3ba507 utils: fix typo in apparmor/aa.py
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-10-08 10:41:31 -07:00
Christian Boltz
f1c86e2486 Convert RE_PROFILE_BARE_FILE_ENTRY and the code using it to named
match groups. 

Also split out RE_OWNER that matches the "owner" keyword.

To make the code easier to understand, I dropped the existing audit
variable and instead directly query the "new" audit variable while 
filling path_rule['audit'].


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-08 12:31:56 +02:00
Kshitij Gupta
52cd4835e2 Refractor prompts in utils.
The following patch:
- creates a class for prompt questions moving away from Perl hash hack
for the purpose.
- moves some functions to the methods for that class
- fix options being incorrectly passed to questionPrompt in aa-mergeprof

Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-10-07 18:36:01 +05:30
Christian Boltz
ed1e2f3321 fix utils/test/runtests-py*.sh exitcode
utils/test/runtests-py*.sh always exits with $? = 1 even if there is no 
error. This is caused by the last executed command, test -n

This patch changes it to test -z so that we'll get $? = 0 if all tests 
succeed.


Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-10-03 11:48:21 +02:00
Christian Boltz
95994ed64a convert RE_PROFILE_CAP in aa.py and the code using it to named match groups
(capability is one of the easiest rule types, so it's good as a start.)

The patch also adds basic support for rules containing more than one 
capability, like
    capability chown dac_override,
Note that this is just a pass-through mode (instead of complaining about 
an invalid line). aa-logprof will happily add another "capability chown" 
if it hits a log entry for it. (But: we never got a bugreport about not 
supporting multi-capability lines, so I guess they are rarely used ;-)

I also added a parse_audit_allow() function to handle the audit and 
allow/deny keywords. They are used in most rule types, which means we 
can get rid of some duplicated code with this function.


Finally, update utils/test/test-regex_matches.py - RE_PROFILE_CAP now 
has 5 instead of 4 match groups because of the added multi-capability 
support.

While on it, I also improved the error message in setup_regex_tests()
to also show the rule that causes a problem.


Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-01 21:45:22 +02:00
Christian Boltz
deaa692aa2 test if aa-enforce removes force-complain symlinks
Two weeks ago, I fixed various tests in minitools_test.py which also 
included disabling the test if aa-complain deletes the force-complain 
symlink because nothing (especially aa-complain) creates those symlinks.

Seth didn't like the removal of that test too much. Therefore this patch
"manually" creates the force-complain symlink and tests that it's removed
by aa-enforce.


Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-09-26 22:03:14 +02:00
Launchpad Translations on behalf of apparmor-dev
4ae5e94aec Launchpad automatic translations update. 2014-09-24 05:57:57 +00:00
Steve Beattie
8b030e8877 Merge launchpad translations:
- updated utils templates for named string parameters
- parser Malay strings update
2014-09-23 09:18:21 -07:00
Christian Boltz
0daaaca946 Make the profile parsing regexes in aa.py easier to read by splitting
out common parts (like audit and deny flags or the typical end of the
line (comma and comment).

The patch also introduces the named match groups <audit>, <allow> and
<comment> which we can start to use whenever we want. The group
numbering is kept unchanged, so we can migrate one regex / rule type
after the other to named groups (not only audit, allow and comments, but
changing all regexes will be another patch ;-)

As a side effect, fix RE_PROFILE_CHANGE_PROFILE, RE_PROFILE_ALIAS and
RE_PROFILE_RLIMIT which did not allow ",   #" (comma, space, comment) at
the end of the line.


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-09-22 23:41:54 +02:00
Steve Beattie
08bc0441d4 Due to wanting to support additional external apparmor python modules,
both real [0] and hypothetical (e.g. gui prototypes), as part of
the python utils merge, some namespace packaging bits were added
to apparmor/__init__.py, based on the (not very clear) advice given
in python's pep 0420 [1]. However, a side effect of this is that it
causes system installed versions of python modules to be used over
paths specified via PYTHONPATH [2], which breaks our in-tree tests
when the system versions of the python modules are out of date with
respect to the in-tree version.

It seems based on testing, however, that carrying this code snippet
is no longer necessary to have external modules be found. Thus,
the following patch drops it.

[0] e.g. https://launchpad.net/click-apparmor
[1] http://www.python.org/dev/peps/pep-0420/
[2] a python upstream discussion about this occurred at
    https://mail.python.org/pipermail/distutils-sig/2014-March/024049.html

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-15 12:18:16 -07:00
Steve Beattie
c48d7dc71f manpages: incorporate podchecker; fix errors and (most) warnings
This patch adds a 'check_pod_files' make target to the common make
rules, and then fixes the errors it highlighted as well as most of
the warnings. It will cause 'make check' in most of the directories to
fail if there are errors in a pod file (but not if there are warnings).

Common issues were:

  - using an '=over/=back' pair for code-like snippets that did not
    contain any =items therein; the =over keyword is intended for
    indenting lists of =item entries, and generates a warning if
    there isn't any.

  - not escaping '<' or '>'

  - blank lines that contained spaces or tabs

The second -warnings flag passed to podchecker is to add additional
warnings, un-escaped '<' and '>' being of them.

I did not fix all of the warnings in apparmor.d.pod, as I have not come
up with a good warning-free way to express the BNF of the language
similar in format to what is currently generated. The existing
libapparmor warnings (complaints about duplicate =item definition
names) are actually a result of passing the second -warnings flag.
The integration into libapparmor is suboptimal due to automake's
expectation that there will be a test driver program(s) for make check
targets; that's why I added the podchecker call to the manpage
generation point.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
---
 changehat/mod_apparmor/Makefile         |    3 
 changehat/mod_apparmor/mod_apparmor.pod |   28 ++-
 common/Make.rules                       |    4 
 libraries/libapparmor/doc/Makefile.am   |    7 
 parser/Makefile                         |    2 
 parser/apparmor.d.pod                   |  275
+++++++++++++-------------------
 utils/Makefile                          |    3 
 utils/aa-cleanprof.pod                  |    2 
 utils/aa-complain.pod                   |    2 
 utils/aa-decode.pod                     |    2 
 utils/aa-easyprof.pod                   |   69 +++-----
 utils/aa-enforce.pod                    |    2 
 utils/aa-genprof.pod                    |    2 
 utils/aa-logprof.pod                    |    6 
 utils/aa-sandbox.pod                    |   64 ++-----
 utils/logprof.conf.pod                  |    2 
 utils/vim/Makefile                      |    2 
 17 files changed, 212 insertions(+), 263 deletions(-)
2014-09-15 11:30:47 -07:00
Launchpad Translations on behalf of apparmor-dev
f4b5811109 Launchpad automatic translations update. 2014-09-15 06:03:21 +00:00
Kshitij Gupta
b7ff639d73 Fix warnings generated due to unnamed arguments in translatable strings.
This patch:
- replaces unnamed arguments with named arguments wherever more than 1
one arguments ware present in a message
- minor fix in aa-unconfined for pname argument in 2 strings
- updated pot files (as a side-effect of testing with make)

Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-14 23:47:00 +05:30
Christian Boltz
bc06f9f23a various fixes for utils/test/minitools_test.py:
- test_audit: fix error message
- test_complain: replace "aa-complain -r" with aa-enforce (we removed 
  the -r flag from aa-complain)
- test_complain: disable checks for force-complain symlinks, 
  aa-complain doesn't create them

Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-09-14 17:27:01 +02:00
Launchpad Translations on behalf of apparmor-dev
8418703863 Launchpad automatic translations update. 2014-09-13 05:57:25 +00:00
Launchpad Translations on behalf of apparmor-dev
e67f6561c4 Launchpad automatic translations update. 2014-09-12 05:53:50 +00:00
Steve Beattie
b099168e6b Merge translation updates back from launchpad. 2014-09-11 10:35:47 -07:00
Launchpad Translations on behalf of apparmor-dev
298df16292 Launchpad automatic translations update. 2014-09-11 05:48:53 +00:00
Christian Boltz
47ec6707e5 fix syntax error
Pre-Acked-by: Steve Beattie <steve@nxnw.org>
2014-09-11 01:09:07 +02:00
Christian Boltz
40a829ef6b merge in some translations from old utils de.po
A side effect of not including utils/apparmor/*.py in the .pot file was
that some translations were lost. This patch includes backported (or
forward-ported?) translations from r2186. It's not a simple merge, I 
reviewed everything I merged and changed it if necessary.

I also removed the outdated 
    "Language-Team: Novell Language <language@novell.com>\n"


Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-09-11 00:10:03 +02:00
Steve Beattie
251a8a9650 Regenerate the utils translation template (.pot) file, both to prepare
for the upcoming release and to compensate for the previous commit that
fixed an issue with missing translatable strings.
2014-09-10 11:15:56 -07:00
Steve Beattie
2f54f0d97a utils: search python modules for translatable strings
In the conversion from perl to python, it got overlooked to add the
python-apparmor modules to the set of things to search for translatable
strings in. This patch addresses the issue.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-10 11:13:59 -07:00
Steve Beattie
0e7c2e4296 Merge added Chechen po template and meta info updates from launchpad
translations branch.
2014-09-09 16:27:07 -07:00
Christian Boltz
3035660716 add missing --display to aa-notify.pod
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-09-08 20:40:33 +02:00
Kshitij Gupta
f63f08d79a Fix incorrect options being displayed for capabilites in aa.py
The following patch:
- ensures the options are passed correctly in the expected form.

Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-08 18:01:18 +05:30
Christian Boltz
6bc1b6ef43 replace copy_netrules_other with list(netrules_other[...]) in
delete_net_duplicates()

Also remove the now unused "import copy".

Acked-by: Kshitij Gupta <kgupta8592@gmail.com>.
2014-09-05 23:21:00 +02:00
Christian Boltz
826e9d998b fix "dictionary changed size during iteration" in cleanprof.py
delete_net_duplicates()

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-09-04 13:19:39 +02:00
Steve Beattie
3a5106527c utils tests: restructure signal parse tests
Convert the signal parse tests to use common AAParseTest super class in
common_test.py.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:36:11 -07:00
Steve Beattie
b05cc0f36f utils tests: restructure ptrace parse tests
Convert the ptrace parse tests to use common AAParseTest super class
in common_test.py.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:32:59 -07:00
Steve Beattie
e8d7dcd321 utils tests: restructure pivotroot parse tests
Convert the pivotroot parse tests to use common AAParseTest super
class in common_test.py.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:31:09 -07:00
Steve Beattie
37adff769c utils tests: restructure mount parse tests
Convert the mount parse tests to use common AAParseTest super class in
common_test.py.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:28:18 -07:00
Steve Beattie
59b5b8bab6 Subject: utils tests: restructure DBUS parse tests
Convert the DBUS parse tests to use common AAParseTest super class in
common_test.py.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-09-03 18:26:19 -07:00