mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
utils: use internal which implementation
* removes runtime dependency on which * fixes aa-unconfined when ss is installed outside {/usr,}/bin Signed-off-by: Michal Vasilek <michal.vasilek@nic.cz>
This commit is contained in:
parent
1a190f2e30
commit
c31d49234f
3 changed files with 8 additions and 12 deletions
|
@ -118,7 +118,7 @@ def read_proc_current(filename):
|
|||
pids = set()
|
||||
if paranoid:
|
||||
pids = get_all_pids()
|
||||
elif args.with_ss or (not args.with_netstat and (os.path.exists('/bin/ss') or os.path.exists('/usr/bin/ss'))):
|
||||
elif args.with_ss or (not args.with_netstat and (aa.which("ss") is not None)):
|
||||
pids = get_pids_ss()
|
||||
else:
|
||||
pids = get_pids_netstat()
|
||||
|
|
|
@ -22,6 +22,8 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
|
||||
from apparmor.aa import which
|
||||
|
||||
#
|
||||
# TODO: move this out to the common library
|
||||
#
|
||||
|
@ -294,13 +296,9 @@ class AppArmorEasyProfile:
|
|||
if os.path.isfile(self.conffile):
|
||||
self._get_defaults()
|
||||
|
||||
self.parser_path = '/sbin/apparmor_parser'
|
||||
self.parser_path = which('apparmor_parser')
|
||||
if opt.parser_path:
|
||||
self.parser_path = opt.parser_path
|
||||
elif not os.path.exists(self.parser_path):
|
||||
rc, self.parser_path = cmd(['which', 'apparmor_parser'])
|
||||
if rc != 0:
|
||||
self.parser_path = None
|
||||
|
||||
self.parser_base = "/etc/apparmor.d"
|
||||
if opt.parser_base:
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# ------------------------------------------------------------------
|
||||
|
||||
from apparmor.common import AppArmorException, debug, error, msg, cmd
|
||||
from apparmor.aa import which
|
||||
import apparmor.easyprof
|
||||
import optparse
|
||||
import os
|
||||
|
@ -31,8 +32,7 @@ def check_requirements(binary):
|
|||
|
||||
for e in exes:
|
||||
debug("Searching for '%s'" % e)
|
||||
rc, report = cmd(['which', e])
|
||||
if rc != 0:
|
||||
if which(e) is None:
|
||||
error("Could not find '%s'" % e, do_exit=False)
|
||||
return False
|
||||
|
||||
|
@ -306,8 +306,7 @@ class SandboxXephyr(SandboxXserver):
|
|||
def start(self):
|
||||
for e in ['Xephyr', 'matchbox-window-manager']:
|
||||
debug("Searching for '%s'" % e)
|
||||
rc, report = cmd(['which', e])
|
||||
if rc != 0:
|
||||
if which(e) is None:
|
||||
raise AppArmorException("Could not find '%s'" % e)
|
||||
|
||||
'''Run any setup code'''
|
||||
|
@ -567,8 +566,7 @@ EndSection
|
|||
|
||||
def start(self):
|
||||
debug("Searching for '%s'" % 'xpra')
|
||||
rc, report = cmd(['which', 'xpra'])
|
||||
if rc != 0:
|
||||
if which('xpra') is None:
|
||||
raise AppArmorException("Could not find '%s'" % 'xpra')
|
||||
|
||||
if self.driver == "xdummy":
|
||||
|
|
Loading…
Add table
Reference in a new issue