diff options
author | Jon Stanley <jonstanley@gmail.com> | 2009-12-09 21:59:43 -0500 |
---|---|---|
committer | Jon Stanley <jonstanley@gmail.com> | 2009-12-09 21:59:43 -0500 |
commit | 4f36d336f2829aa8e79810f158839304299a60ca (patch) | |
tree | cc1a16cd571dbc603b5fddea4dfe3f39670fafae | |
parent | af639cd0b0602eb114dee74c65169c9757fcb6c5 (diff) | |
download | cvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.tar.gz cvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.tar.xz cvssetfacl-4f36d336f2829aa8e79810f158839304299a60ca.zip |
Add dry run logic
-rwxr-xr-x | setacls.py | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -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...]' |