summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Stanley <jonstanley@gmail.com>2009-12-09 22:20:50 -0500
committerJon Stanley <jonstanley@gmail.com>2009-12-09 22:20:50 -0500
commit56d5fba149e95ccfb07f185a3778d22260454a50 (patch)
tree59b9875b4bbb3b325ead68fe5965d32c5d1477a1
parent4f36d336f2829aa8e79810f158839304299a60ca (diff)
downloadcvssetfacl-56d5fba149e95ccfb07f185a3778d22260454a50.tar.gz
cvssetfacl-56d5fba149e95ccfb07f185a3778d22260454a50.tar.xz
cvssetfacl-56d5fba149e95ccfb07f185a3778d22260454a50.zip
Add appropriate functionality into main()
-rwxr-xr-xsetacls.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/setacls.py b/setacls.py
index a34841c..de1b576 100755
--- a/setacls.py
+++ b/setacls.py
@@ -171,16 +171,46 @@ def main():
parser.add_option('-d', '--dry-run', action='store_true', dest='dr', help=
'Just print what would be done')
options, args = parser.parse_args()
+
+ # read the avail file into memory to make things faster
+
for line in avail_file.readlines():
parsed, pkg = line.strip().split(' | ')[1].split(','), \
line.strip().split(' | ')[2]
pkgs[pkg] = parsed
- #print pkgs
+ if not options.all and not args:
+ sys.stderr.write('either the -a option or some packages must be given')
+
+ if options.all and args:
+ sys.stderr.write('You cannot specify both -a and a list of packages')
+
+ if options.all:
+ acl_list = get_all()
+
+ if options.dr:
+ dry_run = True
+ else:
+ dry_run = False
+
+ # this is something of a hack in order to support multiple packages being
+ # specified on the command line. What this does is build a list of dicts
+ # of ACL object. Later we'll check if acl_list is a dict or a list, and
+ # DTRT.
+
+ if args:
+ acl_list = []
+ for arg in args:
+ acl_list.append(get_one(arg))
+
+ if type(acl_list) == 'list':
+ for acl_dict in acl_list:
+ apply_acls(acl_dict, dry_run)
+ else:
+ apply_acls(acl_list, dry_run)
if __name__ == '__main__':
main()
- get_one('389')
#print newacls
#for acl in newacls.keys():
# print newacls[acl]