mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
make parser optional
This commit is contained in:
parent
41a960ecc7
commit
ac3628c1fd
2 changed files with 25 additions and 17 deletions
|
@ -21,8 +21,7 @@ if __name__ == "__main__":
|
|||
return 'USAGE: %s [options] <path to binary>' % \
|
||||
os.path.basename(sys.argv[0])
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
(opt, args) = apparmor.easyprof.parse_args(parser)
|
||||
(opt, args) = apparmor.easyprof.parse_args()
|
||||
binary = None
|
||||
|
||||
m = usage()
|
||||
|
|
|
@ -451,10 +451,30 @@ def print_files(files):
|
|||
for i in files:
|
||||
print open(i).read()
|
||||
|
||||
def parse_args(parser, args=None):
|
||||
def add_parser_policy_args(parser):
|
||||
'''Add parser arguments'''
|
||||
parser.add_option("-a", "--abstractions",
|
||||
dest="abstractions",
|
||||
help="Comma-separated list of abstractions",
|
||||
metavar="ABSTRACTIONS")
|
||||
parser.add_option("--read-path",
|
||||
dest="read_path",
|
||||
help="Path allowing owner reads",
|
||||
metavar="PATH",
|
||||
action="append")
|
||||
parser.add_option("--write-path",
|
||||
dest="write_path",
|
||||
help="Path allowing owner writes",
|
||||
metavar="PATH",
|
||||
action="append")
|
||||
|
||||
def parse_args(args=None, parser=None):
|
||||
'''Parse arguments'''
|
||||
global DEBUGGING
|
||||
|
||||
if parser == None:
|
||||
parser = optparse.OptionParser()
|
||||
|
||||
parser.add_option("-c", "--config-file",
|
||||
dest="conffile",
|
||||
help="Use alternate configuration file",
|
||||
|
@ -495,20 +515,6 @@ def parse_args(parser, args=None):
|
|||
help="Show specified policy groups",
|
||||
action='store_true',
|
||||
default=False)
|
||||
parser.add_option("-a", "--abstractions",
|
||||
dest="abstractions",
|
||||
help="Comma-separated list of abstractions",
|
||||
metavar="ABSTRACTIONS")
|
||||
parser.add_option("--read-path",
|
||||
dest="read_path",
|
||||
help="Path allowing owner reads",
|
||||
metavar="PATH",
|
||||
action="append")
|
||||
parser.add_option("--write-path",
|
||||
dest="write_path",
|
||||
help="Path allowing owner writes",
|
||||
metavar="PATH",
|
||||
action="append")
|
||||
parser.add_option("-n", "--name",
|
||||
dest="name",
|
||||
help="Name of policy",
|
||||
|
@ -531,6 +537,9 @@ def parse_args(parser, args=None):
|
|||
metavar="@{VARIABLE}=VALUE",
|
||||
action="append")
|
||||
|
||||
# add policy args now
|
||||
add_parser_policy_args(parser)
|
||||
|
||||
(my_opt, my_args) = parser.parse_args(args)
|
||||
if my_opt.debug:
|
||||
DEBUGGING = True
|
||||
|
|
Loading…
Add table
Reference in a new issue