Commit graph

432 commits

Author SHA1 Message Date
Steve Beattie
390cfb2cd5 utils: fix apparmor.ui references in aa-genprof
aa-genprof was incorrectly trying to refer to UI_xxx functions in
apparmor.aa rather than the correct apparmor.ui. This patch fixes the
issue.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-06 10:22:26 -08:00
Steve Beattie
7580a02c6c utils: remove generated vim manpage on make clean
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-06 10:20:21 -08:00
Steve Beattie
07bcb79b1d utils: use realpath of tmpdir in test-aa-easyprof.py
The relative directory tests in test-aa-easyprof.py were failing when
TMPDIR pointed to a directory that was a symlink, because the generated
tmpdir path was not the same as the realpath that easyprof resolved to.
This patch sets the tmpdir to the realpath of the result of the
tempfile.mkdtemp() to avoid the issue.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-03-05 13:13:39 -08:00
Steve Beattie
6ceb2030f9 utils: more verbose fail messages for relative dir tests in test-aa-easyprof.py
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-03-05 13:12:12 -08:00
Steve Beattie
6cf4cbea21 utils: remove aa-enforce '--remove' option
This patch removes the '--remove' option on aa-enforce as well as from
the man page. It also removes the test entry that contains it, but I
don't think this is entirely correct because I think the second half
of the test is dependent on the (now deleted) first half of the test.

(It also removes a missed reference to --revert in the aa-disable man
page.)

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-03 14:59:47 -08:00
Steve Beattie
3575ca4ac9 utils: remove aa-disable non-functional '-r' option
This patch removes the non-funcional -r option for aa-disable, as
well as the test and manpage documentation for it.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-03 13:29:32 -08:00
Steve Beattie
4f8dea0db8 utils: make test-aa-easyprof.py cope with UsrMove
The test-aa-easyprof.py script has '/bin/ls' hardcoded as a path;
however, on systems that have undergone UsrMove, this is a symlink to
/usr/bin/ls. This patch fixes the issue by getting the realpath of
/bin/ls and storing it as an instance field.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-03 13:26:41 -08:00
Steve Beattie
fc24ae63ef s patch splits out the disable functionality from the
apparmor/tools.py:act() method into a separate cmd_disable()
method. The intent is to unwind the logic in act() into smaller, more
digestible chunks, while sharing commonality via helper functions
(e.g. the added get_next_to_profile() function).

A secondary driver of this change is that the tools fail when used
against the trunk profiles, due to act() forcing all the profiles to
be read and the tools not understanding the recently added dbus rules
(they were intentionally ignored as part of scoping the rewrite).
Unfortunately, this is not a solution for aa-enforce, aa-complain, etc.
as they are expected to know enough about profiles to understand and
update profile flags.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-03-03 07:50:12 -08:00
Christian Boltz
6a44e0eef5 add recursive_print() to common.py.
It prints a data structure in an easily readable output and is quite 
useful for debugging. However, I don't recommend to call it in 
production code ;-)

Acked-by: Kshitij Gupta <kgupta8592 at gmail.com>
2014-02-28 23:31:16 +01:00
Kshitij Gupta
781d237798 Fix tests for new tools.
Update path to tools in minitools_test.py
Fix assert values in config_test.py

Signed-off: Kshitij Gupta <kgupta8592@gmail.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-02-28 16:09:00 +05:30
Steve Beattie
5045d74716 utils: add common symlink to test/ clean target, to compensate for
packaging systems that do a make clean while trying to represent
changes.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-02-27 16:47:06 -08:00
Steve Beattie
20f26a0680 utils: hook in vim generator sanity test into make check
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-02-27 16:25:00 -08:00
Steve Beattie
0dede73da8 utils: fix path in test-aadecode.py and push make check into the test/
subdirectory.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2014-02-27 16:23:35 -08:00
Seth Arnold
fc7a7004da Fix module import errors, remove extraneous newlines
AttributeError: 'module' object has no attribute 'UI_Info'
AttributeError: 'module' object has no attribute 'open_file_read'
AttributeError: 'module' object has no attribute 'check_for_apparmor'

Signed-off-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-02-27 14:53:25 -08:00
Christian Boltz
7e60928b34 aa-autodep (and therefore also aa-genprof) created a nearly-empty
profile files with only tunables/global, but no profile. This patch 
makes sure that the profile itsself is also written to the profile file.

Without the added line, filelist[prof_filename]['profiles'].keys()) in 
serialize_profile was empty, which means the loop that writes the 
profile was never executed.

Acked-by: Steve Beattie <steve@nxnw.org>
2014-02-26 23:41:00 +01:00
Christian Boltz
410e1eb132 Change aa-complain / set_complain() to (only) add the complain flag.
We don't need to additionally create a force-complain symlink.

Acked-by: Steve Beattie <steve@nxnw.org>
2014-02-25 13:17:46 +01:00
Steve Beattie
361f08bad8 utils: fix cmd reference in apparmor/tools.py
This patch fixes up the parser command invocation via
apparmor/common.py:cmd(), as it handles stdout/stderr redirection,
and the redirection that was being attempted were being handed as
arguments to the parser.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2014-02-24 14:22:35 -08:00
Christian Boltz
a5d003f90d new profile tools - handling of "(F)inish"
Let "(F)inish" ask the user if he wants to save the changed profiles 
before exiting, instead of aborting without saving (we already have 
Abo(r)t for that ;-)


Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-02-24 20:56:28 +01:00
Christian Boltz
ce8429523d fix two (unrelated) issues in common.py:
- add some debug logging in valid_path()
- fix a py2 incompability in DebugLogger.__init__ (OSError vs. IOError)

Acked-by: Kshitij Gupta <kgupta8592@gmail.com>
2014-02-24 20:34:21 +01:00
Christian Boltz
2e3d542c28 Profile parsing: some fixes around the REPOSITORY: line
- use the (new) "parts" variable for the line.split result to make the 
  code less confusing
- change the line.startswith to check for "REPOSITORY:" (note the 
  added ":") like it was in the code before my previous patch.
- make the check for "NEVERSUBMIT" more exact
- print a warning on invalid REPOSITORY: lines and make sure to keep
  them as unmodified line (it might just be a "normal" comment someone
  added manually)


Acked-by: Kshitij Gupta <kgupta8592@gmail.com> (on IRC)
2014-02-24 19:20:11 +01:00
Christian Boltz
295a836324 new profile tools: preserve full initial comment
This patch
- preserves the complete initial comment
- makes sure whitespace inside the comment is kept (except leading 
  whitespace - line.trim() is still applied).
- no longer removes the "# vim:syntax" line

Note: I didn't test if handling the "REPOSITORY" line still works (in
theory it should), but without a working repo, I don't care too much ;-)


Acked-by: Steve Beattie <steve@nxnw.org>
2014-02-22 13:09:15 +01:00
Steve Beattie
b98c40181c utils/apparmor/yasti.py: remove XXX comments; when the time comes for
someone to attempt to see if things work with the python ycp bindings,
they'll discover whether the functions are the right ones or not.
2014-02-14 22:52:31 -08:00
Steve Beattie
7fab3a7a69 Sync with trunk. 2014-02-14 14:47:18 -08:00
Steve Beattie
ec7676bdec utils/aa-*: adjust python shebang lines to ease rewriting to an
alternate python if installed via the python-tools-setup.py script.
2014-02-14 14:42:19 -08:00
Steve Beattie
a482139616 utils/aa-autodep: make --force be a boolean argument, not require an additional value 2014-02-14 12:25:13 -08:00
Steve Beattie
3cbbeac60d utils/apparmor/tools.py: fix misimport of UI stuff as well as a paren
depth error in use_autodep()
2014-02-14 12:19:55 -08:00
Steve Beattie
edb874a2de utils/apparmor/aa.py: fix confusion over name vs data structure 2014-02-14 11:54:02 -08:00
Steve Beattie
4d2b9b5c5d utils/apparmor/aa.py: fix dict/list confusion in create_new_profile() 2014-02-14 11:20:20 -08:00
Seth Arnold
b432cf45c9 Add aa-easyprof and easyprof.py and related pieces from the Ubuntu
apparmor packaging.

These were originally 0030-easyprof-sdk.patch and
0037-easyprof-sdk-pt2.patch. Jamie posted an updated
0030-easyprof-sdk_v2.patch and I squashed both patches into one commit.

Acked-By: Jamie Strandboge <jamie@canonical.com>
2014-02-13 17:53:40 -08:00
Steve Beattie
e61d8bda60 utils: have make clean purge python3 __pycache__ dir in apparmor/ 2014-02-13 11:54:42 -08:00
Steve Beattie
f54a574ee4 utils/: fix last make check failure, though the new utils tests need to
be added in (but they have failures themselves currently)
2014-02-13 11:32:36 -08:00
Steve Beattie
56b01b6eaa utils/apparmor/yasti.py: work around ycp not being available everywhere 2014-02-13 11:14:34 -08:00
Steve Beattie
3b726b996d utils: no need to run pyflakes on aa-status twice 2014-02-13 11:01:29 -08:00
Steve Beattie
2db3a226dc Regenerate apparmor-utils pot (translations template) file 2014-02-13 10:59:16 -08:00
Steve Beattie
be2296edf1 utils/apparmor/: work around last of pyflakes issues here 2014-02-13 10:52:00 -08:00
Steve Beattie
81b3db3dbf Fix more pyflakes issues that cause make check to fail 2014-02-13 10:01:03 -08:00
Steve Beattie
f652178a02 aa-mergeprof: fixup some of the whitespace issues 2014-02-13 08:31:59 -08:00
Steve Beattie
d318ff6100 Fix up last pyflakes issues with tools 2014-02-13 08:24:02 -08:00
Steve Beattie
15a95e3b36 Fix up some more pyflakes issues with the tools 2014-02-13 08:20:59 -08:00
Steve Beattie
bf655b530f Fix make install to handle new python binaries, as well as informing
setuptools to install the entire apparmor python package.
2014-02-13 00:04:39 -08:00
Steve Beattie
e9db24ac23 Add support for better integration of external apparmor modules (e.g.
appamror-click), see http://www.python.org/dev/peps/pep-0402/ for details.
2014-02-12 23:32:25 -08:00
Steve Beattie
32e0931588 Fix up execute permissions that were lost in the merger for some reason. 2014-02-12 16:59:27 -08:00
Steve Beattie
f989dd0132 Merge in Kshitij Gupta <kgupta8592@gmail.com>'s rewrite of the
logprof/genprof and related utilities in python. Because the branch that
was worked on was not based on the apparmor tree, not all of the history
can be maintained for files that are not newly created or entirely
rewritten in the branch.

(This merge also includes a subsequent commit to the branch
I was merging from which includes my missed bzr add of
utils/apparmor/translations.py)
2014-02-12 15:54:00 -08:00
Steve Beattie
975e389f1d Move over the perl apparmor modules (Immunix) as well as some other
perl utilities to the deprecated to directory; a couple of perl
utilities remain, but they are still useful and do not depend on the
Immunix module (just the LibAppArmor perl module).
2014-02-12 10:27:44 -08:00
Steve Beattie
c43d4eaa93 Move perl applications that were reimplemented in python by Kshitij
Gupta to the deprecated directory.
2014-02-12 09:59:23 -08:00
Jamie Strandboge
4b01cb2544 Move os.chdir(old_cwd) to before the aa-exec call it remove the side-effect of
the chdir to $HOME when using Xpra.

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-02-06 15:15:48 -05:00
Christian Boltz
8b802b3fe6 update logprof.conf for UsrMove
logprof.conf contains a list of binaries in the [qualifiers] section 
that should for example never have their own profile.

Since some distributions moved lots of files from /bin/ to /usr/bin/ 
("UsrMove"), this list is outdated.

The patch adds copies of all /bin/ (and /sbin/) lines with /usr 
prepended.

Acked-by: John Johansen <john.johansen@canonical.com>
2014-02-02 15:12:32 +01:00
Christian Boltz
bdaf2592e8 apparmor.vim says "attach_disconnect" is correct, but the parser only
likes "attach_disconnected".

Acked-By: Jamie Strandboge <jamie@canonical.com>
2014-01-29 23:16:36 +01:00
Steve Beattie
cb679f3206 add keyword 'other' vim syntax support, plus language parsing tests
Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-01-24 11:17:23 -08:00
Steve Beattie
9bb81e1ed3 parser: add rttime rlimit support
This patch adds support for the rttime rlimit (aka RLIMIT_RTTIME),
available since the 2.6.25 kernel, according to the getrlimit(2)
man page; see that man page for more details on this rlimit.
An acceptance test is also added, as well as an update to the
apparmor.vim input template.

While reviewing to see what made sense in apparmor.vim for the rttime
rlimit, I discovered that RLIMIT_RTTIME's units are microseconds, not
seconds like RLIMIT_CPU (according to the setrlimit(2) manpage). This
necessitated not sharing the case switch with RLIMIT_CPU. I didn't add
a keyword for microseconds, but I did for milliseconds. I also don't
accept any unit larger than minutes, as it didn't seem appropriate
(and even minutes felt... gratuitous). I would appreciate feedback
on what keywords would be useful here.

Patch History:
  v1: initial submission
  v2: - add apparmor.vim support for rttime keyword
      - adjust RLIMIT_TIME value assignment due to its units being
	microseconds, not seconds, and add milliseconds keyword.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2014-01-24 11:06:31 -08:00