2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-03 15:55:46 +00:00

Compare commits

...

18 Commits

Author SHA1 Message Date
Seth Arnold
3b47558827 Bump libapparmor's AA_LIB_REVISION in preparation for 2.8.2 release.
Bump common/Version in preparation for 2.8.2 release.
2013-08-15 16:14:58 -07:00
Steve Beattie
2fec3758ed Subject: [patch] fix apparmor cache tempfile location to use passed arg v2
Merge from trunk revision 2142

This patch fixes problems in the handling of both the final cache
name location and the temporary cache file when an alternate location
is specified.

The first issue is that if the alternate cache directory location was
specified, the alternate directory name would be used as the final
location for the cache file, rather than the alternate directory +
the basename of the profile.

The second issue is that it would generate the temporary file that it
stores the cache file in [basedir]/cache even if an alternate cache
location was specified on the command line. This causes a problem
if [basedir]/cache is on a separate device than the alternate cache
location, because the rename() of the tempfile into the final location
would fail (which the parser would not check the return code of).

This patch fixes the above by incorporating the basename into the cache
file name if the alternate cache location has been specified, bases the
temporary cache file name on the destination cache name (such that they
end up in the same directory), and finally detects if the rename fails
and unlinks the temporary file if that happens (rather than leave it
around). It also has been updated to add a couple of testcases to verify
that writing and reading from an alternate cache location work.

Patch history:
  v1: first draft of patch
  v2: add testcases, convert PERROR() to pwarn() if rename() fails for
      placing cachefile into place.

For 2.8 branch:

Signed-off-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-07-29 09:52:18 -07:00
Seth Arnold
09c2da3a69 Fix $options -> @options in previous patch. Fix tabs -> spaces.
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-07-09 16:03:09 -07:00
Seth Arnold
9d5269b601 Merge intrigeri's abstractions/fonts improvements 2013-07-08 17:45:20 -07:00
Seth Arnold
28a97bf3c5 Kshitij Gupta fixed a display bug in aa-logprof, aa-genprof, with the Glob
and Glob with Ext putting duplicate entries in the list.

The fix introduced a Perl 5.10.1 or higher dependency, so start documenting
minimum required versions of packages.

Acked-By: Christian Boltz <apparmor@cboltz.de>
2013-07-07 18:33:48 -07:00
Seth Arnold
b77a05aa52 Fix potential NULL-write in aa_getprocattr() error path
https://bugs.launchpad.net/apparmor/+bug/1196880

Patch by Gernot Vormayr <gvormayr@gmail.com>

Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2013-07-02 11:53:31 -07:00
Steve Beattie
2c6e1b6e0f Subject: libapparmor - use python-config if it exists when configuring
Merge from trunk commit 2108

Author: Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>
Nominated-by: Steve Beattie <sbeattie@ubuntu.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>

Modifiy the libapparmor macro for python to use python-config if it
exists to determine what CPPFLAGS and LDFLAGS to use when building
the python swig libraries. Without this addition, python detection
fails on ubuntu 13.04. I've confirmed that with this patch applied,
the python libraries still build successfully on older releases as well
(as far back as ubuntu 11.10).
2013-07-02 10:35:36 -07:00
Christian Boltz
b0fd46af26 add Dolphin (default Kubuntu file manager) to the list of file managers in
abstractions/ubuntu-browsers.d/ubuntu-integration.

Patch by Felix Geyer <debfx@ubuntu.com>

Acked-by: Seth Arnold <seth.arnold at canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de> 

(backport of trunk r2133)
2013-07-01 17:51:11 +02:00
Christian Boltz
9687641741 merge https://code.launchpad.net/~kensington/apparmor/apparmor/+merge/169010
Michael Palimaka 2013-06-13 Add missing key shortcuts for hu linguas.

(backport of trunk r2132)
2013-07-01 17:45:50 +02:00
Seth Arnold
6e67ef7cc3 Move poppler's cMaps from gnome to fonts; gnome includes fonts
Acked-By: Christian Boltz <apparmor@cboltz.de>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-05-30 14:46:31 -07:00
Jamie Strandboge
76e23529af cherrypick r2119 from trunk:
deny writes to upstart user sessions jobs in abstractions/private-files

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:58:28 -05:00
Jamie Strandboge
d345d4a93a cherrypick r2118 from trunk:
add @{HOME}/.gnome2/keyrings/** to abstractions/private-files-strict

Acked-By: Jamie Strandboge <jamie@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-13 14:57:35 -05:00
Christian Boltz
bd09ea910b Backport the python3 compability changes from trunk r2052 to
the 2.8 branch.

Original commit message:
    committer: Jamie Strandboge <jamie@canonical.com>
    Initial port to python3 for utilities. Thanks to Dmitrijs Ledkovs
    Acked-By: Jamie Strandboge <jamie@canonical.com>

Most of trunk r2052 also applies to the 2.8 branch. The only difference
is the last section of changes in utils/vim/create-apparmor.vim.py

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
Skimmed-by: Seth Arnold <seth.arnold@canonical.com>
2013-05-07 22:38:18 +02:00
John Johansen
18d66a09f6 This is a minimal fix to apparmor 2.8 for cache failures when the feature
file is larger than the feature buffer used for cache version comparison.

Ideally this would be dynamically allocated but for 2.8 just bumping the
buffer size is the quick fix.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2013-05-02 11:30:19 -07:00
Jamie Strandboge
5d439f2fcc cherrypick 2111 from trunk:
add read access to @{PROC}/sys/vm/overcommit_memory as used by glibc. See
  http://sourceware.org/git/?p=glibc.git;a=commit;h=9fab36eb583c0e585e83a01253299afed9ea9a11

Acked-By: Christian Boltz <apparmor@cboltz.de>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:18:40 -05:00
Jamie Strandboge
e9353b757c cherrypick r2110 from trunk:
update pulseaudio directory and cookie file paths

Acked-By: Christian Boltz <apparmor@cboltz.de>
Acked-By: Jamie Strandboge <jamie@canonical.com>
2013-04-09 08:17:39 -05:00
Christian Boltz
8029059d73 Add missing permissions to the nscd profile.
Also deny capability block_suspend because nobody can imagine why it 
would be needed.

References: https://bugzilla.novell.com/show_bug.cgi?id=807104

Acked-by: Seth Arnold <seth.arnold@canonical.com>

(backport of trunk r2109)
2013-03-05 22:12:37 +01:00
Christian Boltz
05251eef06 abstractions/mysql: changed paths and MariaDB support
abstractions/mysql  contains
   /var/lib/mysql/mysql.sock rw,
   /usr/share/mysql/charsets/ r,
   /usr/share/mysql/charsets/*.xml r,

but the files moved (at least on openSUSE) to
    /usr/share/mysql-community-server/charsets/*.xml
    /var/run/mysql/mysql.sock
This causes denials for all applications using MySQL on 12.2 and 
Factory.

MariaDB has the *.xml files in
    /usr/share/mariadb/charsets/*.xml
and also seems to use /var/run/mysql/ for the socket.

Since MariaDB is basically a drop-in replacement for MySQL, it makes
sense to allow access to it via abstractions/mysql.

References: https://bugzilla.novell.com/show_bug.cgi?id=798183

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2013-01-13 14:41:56 +01:00
25 changed files with 149 additions and 75 deletions

18
README
View File

@@ -198,3 +198,21 @@ Building and Installing AppArmor Kernel Patches
TODO
-----------------
Required versions
-----------------
The AppArmor userspace utilities are written with some assumptions about
installed and available versions of other tools. This is a (possibly
incomplete) list of known version dependencies:
AppArmor.pm (used by aa-audit, aa-autodep, aa-complain, aa-disable,
aa-enforce, aa-genprof, aa-logprof, aa-unconfined) requires minimum
Perl 5.10.1.
Python scripts require minimum Python 2.7. Some utilities may require
Python 3.3. Python 3.0, 3.1, 3.2 are largely untested.
Most shell scripts are written for POSIX-compatible sh. aa-decode expects
bash, probably version 3.2 and higher.

View File

@@ -32,6 +32,10 @@ ifndef AWK
$(error awk utility required for build but not available)
endif
# Convenience functions
pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH)))))
map = $(foreach a,$(2),$(call $(1),$(a)))
# OVERRIDABLE variables
# Set these variables before including Make.rules to change its behavior
# SPECFILE - for packages that have a non-standard specfile name
@@ -132,6 +136,17 @@ endif
endif
ifndef PYTHON_VERSIONS
PYTHON_VERSIONS = $(call map, pathsearch, python2 python3)
endif
ifndef PYTHON
PYTHON = $(firstword ${PYTHON_VERSIONS})
endif
#Helper function to be used with $(call pyalldo, run_test_with_all.py)
pyalldo=set -e; $(foreach py, $(PYTHON_VERSIONS), $(py) $(1);)
.PHONY: version
.SILENT: version
version:

View File

@@ -1 +1 @@
2.8.1
2.8.2

View File

@@ -17,9 +17,9 @@ AC_DEFUN([AC_PYTHON_DEVEL],[
# Check for a version of Python >= 2.1.0
#
AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
ver = string.split(sys.version)[[0]]; \
print ver >= '2.1.0'"`
ac_supports_python_ver=`$PYTHON -c "import sys; \
ver = sys.version.split()[[0]]; \
sys.stdout.write(str(ver >= '2.1.0'))"`
if test "$ac_supports_python_ver" != "True"; then
if test -z "$PYTHON_NOVERSIONCHECK"; then
AC_MSG_RESULT([no])
@@ -44,9 +44,9 @@ to something else than an empty string.
#
if test -n "$1"; then
AC_MSG_CHECKING([for a version of Python $1])
ac_supports_python_ver=`$PYTHON -c "import sys, string; \
ver = string.split(sys.version)[[0]]; \
print ver $1"`
ac_supports_python_ver=`$PYTHON -c "import sys; \
ver = sys.version.split()[[0]]; \
sys.stdout.write("%s\n" % (ver == $1))"`
if test "$ac_supports_python_ver" = "True"; then
AC_MSG_RESULT([yes])
else
@@ -79,9 +79,12 @@ $ac_distutils_result])
# Check for Python include path
#
AC_MSG_CHECKING([for Python include path])
if type $PYTHON-config; then
PYTHON_CPPFLAGS=`$PYTHON-config --includes`
fi
if test -z "$PYTHON_CPPFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \
print distutils.sysconfig.get_python_inc();"`
python_path=`$PYTHON -c "import sys; import distutils.sysconfig;\
sys.stdout.write('%s\n' % distutils.sysconfig.get_python_inc());"`
if test -n "${python_path}"; then
python_path="-I$python_path"
fi
@@ -94,25 +97,26 @@ $ac_distutils_result])
# Check for Python library path
#
AC_MSG_CHECKING([for Python library path])
if type $PYTHON-config; then
PYTHON_LDFLAGS=`$PYTHON-config --ldflags`
fi
if test -z "$PYTHON_LDFLAGS"; then
# (makes two attempts to ensure we've got a version number
# from the interpreter)
py_version=`$PYTHON -c "from distutils.sysconfig import *; \
from string import join; \
print join(get_config_vars('VERSION'))"`
py_version=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
sys.stdout.write('%s\n' % ''.join(get_config_vars('VERSION')))"`
if test "$py_version" == "[None]"; then
if test -n "$PYTHON_VERSION"; then
py_version=$PYTHON_VERSION
else
py_version=`$PYTHON -c "import sys; \
print sys.version[[:3]]"`
sys.stdout.write("%s\n" % sys.version[[:3]])"`
fi
fi
PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \
from string import join; \
print '-L' + get_python_lib(0,1), \
'-lpython';"`$py_version
PYTHON_LDFLAGS=`$PYTHON -c "import sys; from distutils.sysconfig import *; \
sys.stdout.write('-L' + get_python_lib(0,1) + ' -lpython\n')"`$py_version`$PYTHON -c \
"import sys; sys.stdout.write('%s' % getattr(sys,'abiflags',''))"`
fi
AC_MSG_RESULT([$PYTHON_LDFLAGS])
AC_SUBST([PYTHON_LDFLAGS])
@@ -122,8 +126,8 @@ $ac_distutils_result])
#
AC_MSG_CHECKING([for Python site-packages path])
if test -z "$PYTHON_SITE_PKG"; then
PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
print distutils.sysconfig.get_python_lib(0,0);"`
PYTHON_SITE_PKG=`$PYTHON -c "import sys; import distutils.sysconfig; \
sys.stdout.write('%s\n' % distutils.sysconfig.get_python_lib(0,0));"`
fi
AC_MSG_RESULT([$PYTHON_SITE_PKG])
AC_SUBST([PYTHON_SITE_PKG])
@@ -133,9 +137,9 @@ $ac_distutils_result])
#
AC_MSG_CHECKING(python extra libraries)
if test -z "$PYTHON_EXTRA_LIBS"; then
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
print conf('LOCALMODLIBS'), conf('LIBS')"`
PYTHON_EXTRA_LIBS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
sys.stdout.write('%s %s\n' % (conf('LOCALMODLIBS'), conf('LIBS')))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
AC_SUBST(PYTHON_EXTRA_LIBS)
@@ -145,9 +149,9 @@ $ac_distutils_result])
#
AC_MSG_CHECKING(python extra linking flags)
if test -z "$PYTHON_EXTRA_LDFLAGS"; then
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
print conf('LINKFORSHARED')"`
PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import sys; import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
sys.stdout.write('%s\n' % conf('LINKFORSHARED'))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
AC_SUBST(PYTHON_EXTRA_LDFLAGS)

View File

@@ -19,7 +19,7 @@ INCLUDES = $(all_includes)
# - set AA_LIB_AGE to 0.
#
AA_LIB_CURRENT = 1
AA_LIB_REVISION = 3
AA_LIB_REVISION = 4
AA_LIB_AGE = 0
SUFFIXES = .pc.in .pc

View File

@@ -279,7 +279,8 @@ int aa_getprocattr(pid_t tid, const char *attr, char **buf, char **mode)
if (rc == -1) {
free(buffer);
*buf = NULL;
*mode = NULL;
if (mode)
*mode = NULL;
} else
*buf = buffer;

View File

@@ -78,7 +78,7 @@ int preprocess_only = 0;
int skip_mode_force = 0;
struct timespec mru_tstamp;
#define FLAGS_STRING_SIZE 1024
#define FLAGS_STRING_SIZE 8192
char *match_string = NULL;
char *flags_string = NULL;
char *cacheloc = NULL;
@@ -1087,8 +1087,7 @@ int process_profile(int option, char *profilename)
if ((profilename && option != OPTION_REMOVE) && !force_complain &&
!skip_cache) {
if (cacheloc) {
cachename = strdup(cacheloc);
if (!cachename) {
if (asprintf(&cachename, "%s/%s", cacheloc, basename)<0) {
PERROR(_("Memory allocation error."));
exit(1);
}
@@ -1107,7 +1106,7 @@ int process_profile(int option, char *profilename)
}
if (write_cache) {
/* Otherwise, set up to save a cached copy */
if (asprintf(&cachetemp, "%s/%s/%s-XXXXXX", basedir, "cache", basename)<0) {
if (asprintf(&cachetemp, "%s-XXXXXX", cachename)<0) {
perror("asprintf");
exit(1);
}
@@ -1165,8 +1164,11 @@ out:
}
if (useable_cache) {
rename(cachetemp, cachename);
if (show_cache)
if (rename(cachetemp, cachename) < 0) {
pwarn("Warning failed to write cache: %s\n", cachename);
unlink(cachetemp);
}
else if (show_cache)
PERROR("Wrote cache: %s\n", cachename);
}
else {

View File

@@ -12,7 +12,8 @@ fi
# fake base directory
basedir=$(mktemp -d -t aa-cache-XXXXXX)
trap "rm -rf $basedir" EXIT
altcachedir=$(mktemp -d -t aa-alt-cache-XXXXXXXX)
trap "rm -rf $basedir $altcachedir" EXIT
mkdir -p $basedir/cache
ARGS="--base $basedir --skip-kernel-load"
@@ -158,3 +159,13 @@ echo "ok"
echo -n "Cache reading is skipped when parser in \$PATH is newer: "
(PATH=$basedir/parser/ /bin/sh -c "apparmor_parser $ARGS -v -r $basedir/$profile") | grep -q 'Replacement succeeded for' || { echo "FAIL"; exit 1; }
echo "ok"
echo -n "Profiles are cached in alternate location when requested: "
../apparmor_parser $ARGS -q --write-cache --cache-loc $altcachedir -r $basedir/$profile
[ ! -f $altcachedir/$profile ] && echo "FAIL ($altcachedir/$profile does not exist)" && exit 1
echo "ok"
echo -n "Cache is loaded from alt location when it exists and features match: "
../apparmor_parser $ARGS -v -r $basedir/$profile --cache-loc $altcachedir | grep -q 'Cached reload succeeded' || { echo "FAIL"; exit 1; }
echo "ok"

View File

@@ -55,6 +55,9 @@ owner /{run,dev}/shm/pulse-shm* rwk,
owner @{HOME}/.pulse-cookie rwk,
owner @{HOME}/.pulse/ rw,
owner @{HOME}/.pulse/* rwk,
owner /{,var/}run/user/*/pulse/ rw,
owner /{,var/}run/user/*/pulse/* rwk,
owner @{HOME}/.config/pulse/cookie rwk,
owner /tmp/pulse-*/ rw,
owner /tmp/pulse-*/* rw,

View File

@@ -100,6 +100,9 @@
# glibc statvfs
@{PROC}/filesystems r,
# glibc malloc (man 5 proc)
@{PROC}/sys/vm/overcommit_memory r,
# Workaround https://launchpad.net/bugs/359338 until upstream handles stacked
# filesystems generally. This does not appreciably decrease security with
# Ubuntu profiles because the user is expected to have access to files owned

View File

@@ -18,6 +18,7 @@
/usr/share/fonts/** r,
/etc/fonts/** r,
/usr/share/fontconfig/conf.avail/** r,
/opt/kde3/share/fonts/** r,
@@ -30,7 +31,9 @@
/usr/share/a2ps/fonts/** r,
/usr/share/xfce/fonts/** r,
/usr/share/ghostscript/fonts/** r,
/usr/share/javascript/*/fonts/** r,
/usr/share/texmf/{,*/}fonts/** r,
/usr/share/texlive/texmf-dist/fonts/** r,
/var/lib/ghostscript/** r,
@{HOME}/.fonts.conf r,
@@ -44,3 +47,6 @@
/usr/local/share/fonts/ r,
/usr/local/share/fonts/** r,
# poppler CMap tables
/usr/share/poppler/cMap/** r,

View File

@@ -83,6 +83,3 @@
# mime-types
/etc/gnome/defaults.list r,
/usr/share/gnome/applications/mimeinfo.cache r,
# poppler CMap tables
/usr/share/poppler/cMap/** r,

View File

@@ -1,6 +1,7 @@
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2006 Novell/SUSE
# Copyright (C) 2013 Christian Boltz
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
@@ -9,5 +10,6 @@
# ------------------------------------------------------------------
/var/lib/mysql/mysql.sock rw,
/usr/share/mysql/charsets/ r,
/usr/share/mysql/charsets/*.xml r,
/{var/,}run/mysql/mysql.sock rw,
/usr/share/{mysql,mysql-community-server,mariadb}/charsets/ r,
/usr/share/{mysql,mysql-community-server,mariadb}/charsets/*.xml r,

View File

@@ -15,6 +15,8 @@
# special attention to (potentially) executable files
audit deny @{HOME}/bin/** wl,
audit deny @{HOME}/.config/autostart/** wl,
audit deny @{HOME}/.config/upstart/** wl,
audit deny @{HOME}/.init/** wl,
audit deny @{HOME}/.kde{,4}/Autostart/** wl,
audit deny @{HOME}/.kde{,4}/env/** wl,
audit deny @{HOME}/.pki/nssdb/*.so{,.[0-9]*} wl,

View File

@@ -8,6 +8,7 @@
audit deny @{HOME}/.gnupg/** mrwkl,
audit deny @{HOME}/.ssh/** mrwkl,
audit deny @{HOME}/.gnome2_private/** mrwkl,
audit deny @{HOME}/.gnome2/keyrings/** mrwkl,
audit deny @{HOME}/.mozilla/** mrwkl,
audit deny @{HOME}/.config/chromium/** mrwkl,
audit deny @{HOME}/.{,mozilla-}thunderbird/** mrwkl,

View File

@@ -20,6 +20,7 @@
# File managers
/usr/bin/nautilus Cxr -> sanitized_helper,
/usr/bin/{t,T}hunar Cxr -> sanitized_helper,
/usr/bin/dolphin Cxr -> sanitized_helper,
# Themes
/usr/bin/gnome-appearance-properties Cxr -> sanitized_helper,

View File

@@ -16,6 +16,7 @@
#include <abstractions/nameservice>
#include <abstractions/ssl_certs>
deny capability block_suspend,
capability net_bind_service,
capability setgid,
capability setuid,
@@ -31,9 +32,9 @@
/{,var/}run/.nscd_socket wl,
/{,var/}run/avahi-daemon/socket w,
/{,var/}run/nscd/ rw,
/{,var/}run/nscd/db* wl,
/{,var/}run/nscd/db* rwl,
/{,var/}run/nscd/socket wl,
/var/{cache,run}/nscd/{passwd,group,services,hosts} rw,
/var/{cache,run}/nscd/{passwd,group,services,hosts,netgroup} rw,
/{,var/}run/{nscd/,}nscd.pid rwl,
/var/log/nscd.log rw,
@{PROC}/[0-9]*/fd/ r,
@@ -41,6 +42,7 @@
@{PROC}/[0-9]*/maps r,
@{PROC}/[0-9]*/mounts r,
@{PROC}/filesystems r,
@{PROC}/sys/vm/overcommit_memory r,
# Site-specific additions and overrides. See local/README for details.
#include <local/usr.sbin.nscd>

View File

@@ -3879,8 +3879,8 @@ sub ask_the_questions() {
$newpath =~ s/\/[^\/]+$/\/\*/;
}
}
if ($newpath ne $selected) {
push @options, $newpath;
if (not $newpath ~~ @options) {
push @options, $newpath;
$defaultoption = $#options + 1;
}
}
@@ -3896,7 +3896,7 @@ sub ask_the_questions() {
} else {
$newpath =~ s/\/[^\/]+(\.[^\/]+)$/\/\*$1/;
}
if ($newpath ne $selected) {
if (not $newpath ~~ @options) {
push @options, $newpath;
$defaultoption = $#options + 1;
}

View File

@@ -65,7 +65,7 @@ install: ${MANPAGES} ${HTMLMANPAGES}
$(MAKE) install_manpages DESTDIR=${DESTDIR}
$(MAKE) -C vim install DESTDIR=${DESTDIR}
ln -sf aa-status.8 ${DESTDIR}/${MANDIR}/man8/apparmor_status.8
python ${PYSETUP} install --prefix=${PYPREFIX} --root=${DESTDIR} --version=${VERSION}
${PYTHON} ${PYSETUP} install --prefix=${PYPREFIX} --root=${DESTDIR} --version=${VERSION}
.PHONY: clean
ifndef VERBOSE
@@ -105,6 +105,4 @@ check: check_severity_db
test -s $$tmpfile && cat $$tmpfile && rm -f $$tmpfile && exit 1; \
done || true; \
rm -f $$tmpfile
for i in test/* ; do \
python $$i || exit 1; \
done
$(foreach test, $(wildcard test/test-*.py), $(call pyalldo, $(test)))

View File

@@ -35,7 +35,7 @@ if __name__ == "__main__":
try:
easyp = apparmor.easyprof.AppArmorEasyProfile(binary, opt)
except AppArmorException, e:
except AppArmorException as e:
error(e.value)
except Exception:
raise
@@ -61,5 +61,5 @@ if __name__ == "__main__":
# if we made it here, generate a profile
params = apparmor.easyprof.gen_policy_params(binary, opt)
p = easyp.gen_policy(**params)
print p,
sys.stdout.write('%s\n' % p)

View File

@@ -8,6 +8,8 @@
#
# ------------------------------------------------------------------
from __future__ import with_statement
import codecs
import glob
import optparse
@@ -40,7 +42,7 @@ DEBUGGING = False
def error(out, exit_code=1, do_exit=True):
'''Print error message and exit'''
try:
print >> sys.stderr, "ERROR: %s" % (out)
sys.stderr.write("ERROR: %s\n" % (out))
except IOError:
pass
@@ -51,7 +53,7 @@ def error(out, exit_code=1, do_exit=True):
def warn(out):
'''Print warning message'''
try:
print >> sys.stderr, "WARN: %s" % (out)
sys.stderr.write("WARN: %s\n" % (out))
except IOError:
pass
@@ -59,7 +61,7 @@ def warn(out):
def msg(out, output=sys.stdout):
'''Print message'''
try:
print >> output, "%s" % (out)
sys.stdout.write("%s\n" % (out))
except IOError:
pass
@@ -70,7 +72,7 @@ def cmd(command):
try:
sp = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except OSError, ex:
except OSError as ex:
return [127, str(ex)]
out = sp.communicate()[0]
@@ -82,7 +84,7 @@ def cmd_pipe(command1, command2):
try:
sp1 = subprocess.Popen(command1, stdout=subprocess.PIPE)
sp2 = subprocess.Popen(command2, stdin=sp1.stdout)
except OSError, ex:
except OSError as ex:
return [127, str(ex)]
out = sp2.communicate()[0]
@@ -93,7 +95,7 @@ def debug(out):
'''Print debug message'''
if DEBUGGING:
try:
print >> sys.stderr, "DEBUG: %s" % (out)
sys.stderr.write("DEBUG: %s\n" % (out))
except IOError:
pass
@@ -181,6 +183,8 @@ def verify_policy(policy):
fn = policy
else:
f, fn = tempfile.mkstemp(prefix='aa-easyprof')
if not isinstance(policy, bytes):
policy = policy.encode('utf-8')
os.write(f, policy)
os.close(f)
@@ -219,9 +223,9 @@ class AppArmorEasyProfile:
if opt.policy_groups_dir and os.path.isdir(opt.policy_groups_dir):
self.dirs['policygroups'] = os.path.abspath(opt.policy_groups_dir)
if not self.dirs.has_key('templates'):
if not 'templates' in self.dirs:
raise AppArmorException("Could not find templates directory")
if not self.dirs.has_key('policygroups'):
if not 'policygroups' in self.dirs:
raise AppArmorException("Could not find policygroups directory")
self.aa_topdir = "/etc/apparmor.d"
@@ -445,11 +449,12 @@ class AppArmorEasyProfile:
def print_basefilenames(files):
for i in files:
print "%s" % (os.path.basename(i))
sys.stdout.write("%s\n" % (os.path.basename(i)))
def print_files(files):
for i in files:
print open(i).read()
with open(i) as f:
sys.stdout.write(f.read()+"\n")
def parse_args(args=None):
'''Parse arguments'''

View File

@@ -333,11 +333,11 @@ msgstr ""
#: ../AppArmor.pm:1379 ../AppArmor.pm:1419
msgid "(Y)es"
msgstr "Igen"
msgstr "(I)gen"
#: ../AppArmor.pm:1380 ../AppArmor.pm:1420
msgid "(N)o"
msgstr "Nem"
msgstr "(N)em"
#: ../AppArmor.pm:1383 ../AppArmor.pm:1424
msgid "Invalid hotkey for"

View File

@@ -101,6 +101,7 @@ TEMPLATES_DIR="%s/templates"
def tearDown(self):
'''Teardown for tests'''
if os.path.exists(self.tmpdir):
sys.stdout.write("%s\n" % self.tmpdir)
recursive_rm(self.tmpdir)
#
@@ -328,7 +329,7 @@ POLICYGROUPS_DIR="%s/templates"
def test_binary_symlink(self):
'''Test binary (symlink)'''
exe = os.path.join(self.tmpdir, 'exe')
open(exe, 'wa').close()
open(exe, 'a').close()
symlink = exe + ".lnk"
os.symlink(exe, symlink)
@@ -441,7 +442,7 @@ POLICYGROUPS_DIR="%s/templates"
self.assertFalse(inv_s in p, "Found '%s' in :\n%s" % (inv_s, p))
if debugging:
print p
sys.stdout.write("%s\n" % p)
return p
@@ -859,7 +860,7 @@ if __name__ == '__main__':
# Create the necessary files to import aa-easyprof
init = os.path.join(os.path.dirname(absfn), '__init__.py')
if not os.path.exists(init):
open(init, 'wa').close()
open(init, 'a').close()
created.append(init)
symlink = os.path.join(os.path.dirname(absfn), 'easyprof.py')

View File

@@ -14,12 +14,15 @@ VIM_INSTALL_PATH=${DESTDIR}/usr/share/apparmor
all: apparmor.vim
apparmor.vim: apparmor.vim.in Makefile create-apparmor.vim.py
python create-apparmor.vim.py > $@
${PYTHON} create-apparmor.vim.py > apparmor.vim
install: apparmor.vim
install -d $(VIM_INSTALL_PATH)
install -m 644 $< $(VIM_INSTALL_PATH)
test: apparmor.vim.in Makefile create-apparmor.vim.py
#Testing with all pythons
$(call pyalldo, create-apparmor.vim.py > /dev/null)
clean:
rm -f apparmor.vim common

View File

@@ -10,7 +10,6 @@
# Christian Boltz <apparmor@cboltz.de>
from __future__ import with_statement
import os
import re
import subprocess
import sys
@@ -30,9 +29,9 @@ def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.P
return a textual error if it failed.'''
try:
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True)
except OSError, e:
return [127, str(e)]
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, universal_newlines=True)
except OSError as ex:
return [127, str(ex)]
out, outerr = sp.communicate(input)
@@ -47,7 +46,7 @@ def cmd(command, input = None, stderr = subprocess.STDOUT, stdout = subprocess.P
# get capabilities list
(rc, output) = cmd(['make', '-s', '--no-print-directory', 'list_capabilities'])
if rc != 0:
print >>sys.stderr, ("make list_capabilities failed: " + output)
sys.stderr.write("make list_capabilities failed: " + output)
exit(rc)
capabilities = re.sub('CAP_', '', output.strip()).lower().split(" ")
@@ -59,7 +58,7 @@ for cap in capabilities:
# get network protos list
(rc, output) = cmd(['make', '-s', '--no-print-directory', 'list_af_names'])
if rc != 0:
print >>sys.stderr, ("make list_af_names failed: " + output)
sys.stderr.write("make list_af_names failed: " + output)
exit(rc)
af_names = []
@@ -105,7 +104,7 @@ aa_regex_map = {
}
def my_repl(matchobj):
#print matchobj.group(1)
matchobj.group(1)
if matchobj.group(1) in aa_regex_map:
return aa_regex_map[matchobj.group(1)]
@@ -113,7 +112,7 @@ def my_repl(matchobj):
regex = "@@(" + "|".join(aa_regex_map) + ")@@"
with file("apparmor.vim.in") as template:
with open("apparmor.vim.in") as template:
for line in template:
line = re.sub(regex, my_repl, line.rstrip())
print line
sys.stdout.write('%s\n' % line)