forked from mk-fg/fgtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyacl
executable file
·34 lines (30 loc) · 1.13 KB
/
pyacl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python2
from __future__ import unicode_literals, print_function
from optparse import OptionParser
parser = OptionParser(usage='%prog [options] [PATH1 PATH2 ...]',
description="Update ACLs on given paths, so that they'd match"
' default ACLs and all entries will be effective (recalculate mask).'
' Usually needed after a chmod.')
parser.add_option('-p', '--dry-run', action='store_true',
help='Just show what needs to be done.')
parser.add_option('--debug', action='store_true',
help='Give extra info on whats going on.')
optz,argz = parser.parse_args()
import itertools as it, operator as op, functools as ft
from fgc import acl
import os, sys
import logging
if optz.debug: log = logging.DEBUG
elif optz.dry_run: log = logging.INFO
else: log = logging.WARNING
logging.basicConfig(level=log)
log = logging.getLogger()
for path in argz:
acl_src = set(acl.get(path))
acl_dst = set(
acl.update_from_default(
acl.get(path, effective=False) ) )
if acl_src != acl_dst:
log.info( 'Updating ACL for path: {0}\n old: {1}\n new: {2}'\
.format(path, sorted(acl_src), sorted(acl_dst)) )
if not optz.dry_run: acl.apply(acl_dst, path)