mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 14:25:52 +00:00
Initial port to python3 for utilities.
This commit is contained in:
@@ -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 > /dev/null
|
||||
|
||||
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
|
||||
|
@@ -30,8 +30,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:
|
||||
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, universal_newlines=True)
|
||||
except OSError:
|
||||
e = sys.exc_info()[1]
|
||||
return [127, str(e)]
|
||||
|
||||
out, outerr = sp.communicate(input)
|
||||
@@ -47,7 +48,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 +60,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 = []
|
||||
@@ -164,16 +165,16 @@ filerule = filerule + create_file_rule ( 'sdEntryR', r'[rl]+', 'read entry, n
|
||||
|
||||
regex = "@@(" + "|".join(aa_regex_map) + ")@@"
|
||||
|
||||
print '" generated from apparmor.vim.in by create-apparmor.vim.py'
|
||||
print '" do not edit this file - edit apparmor.vim.in or create-apparmor.vim.py instead' + "\n"
|
||||
sys.stdout.write('" generated from apparmor.vim.in by create-apparmor.vim.py\n')
|
||||
sys.stdout.write('" do not edit this file - edit apparmor.vim.in or create-apparmor.vim.py instead' + "\n")
|
||||
|
||||
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(line)
|
||||
|
||||
print "\n\n\n"
|
||||
sys.stdout.write("\n\n\n\n")
|
||||
|
||||
print '" file rules added with create_file_rule()'
|
||||
print re.sub(regex, my_repl, filerule)
|
||||
sys.stdout.write('" file rules added with create_file_rule()\n')
|
||||
sys.stdout.write(re.sub(regex, my_repl, filerule)+'\n')
|
||||
|
||||
|
Reference in New Issue
Block a user