summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Stanley <jonstanley@gmail.com>2009-12-09 21:59:43 -0500
committerJon Stanley <jonstanley@gmail.com>2009-12-09 21:59:43 -0500
commit4f36d336f2829aa8e79810f158839304299a60ca (patch)
treecc1a16cd571dbc603b5fddea4dfe3f39670fafae
parentaf639cd0b0602eb114dee74c65169c9757fcb6c5 (diff)
downloadcvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.tar.gz
cvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.tar.xz
cvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.zip
Add dry run logic
-rwxr-xr-xsetacls.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/setacls.py b/setacls.py
index bddb34c..a34841c 100755
--- a/setacls.py
+++ b/setacls.py
@@ -129,7 +129,7 @@ def build_acl(acl_text):
#print '%s/%s' % ( CVSBASE, pkg )
return acl
-def apply_acls(acl_dict):
+def apply_acls(acl_dict, dry_run=False):
'''Applies ACL's to the filesystem. Take a dictionary of ACL's, with the
keys being the path that you would like to ACL's on. The global variable
CVSBASE will be prepended to the keys of the dict. Ownership of the
@@ -141,16 +141,25 @@ def apply_acls(acl_dict):
for dir in acl_dict.keys():
real_dir = os.path.join(CVSBASE, dir)
- acl_dict[dir].applyto(real_dir, posix1e.ACL_TYPE_DEFAULT)
- acl_dict[dir].applyto(real_dir, posix1e.ACL_TYPE_ACCESS)
+ if not dry_run:
+ acl_dict[dir].applyto(real_dir, posix1e.ACL_TYPE_DEFAULT)
+ acl_dict[dir].applyto(real_dir, posix1e.ACL_TYPE_ACCESS)
+ else:
+ print 'would apply the following ACL to %s' % real_dir
+ print acl_dict[dir]
os.chown(real_path, 0, scm_admin_gid)
for file in os.listdir(real_dir):
real_file = os.path.join(real_dir, file)
- if os.path.isdir(real_file):
- acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_DEFAULT)
- acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_ACCESS)
- if os.path.isfile(real_file):
- acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_ACCESS)
+ if not dry_run:
+ if os.path.isdir(real_file):
+ acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_DEFAULT)
+ acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_ACCESS)
+ if os.path.isfile(real_file):
+ acl_dict[dir].applyto(real_file, posix1e.ACL_TYPE_ACCESS)
+ else:
+ print 'would apply the following ACL to %s' % real_file
+ print acl_dict[dir]
+
def main():
usage = '%prog [options] [pkgs...]'