@ -333,23 +333,24 @@ def adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list,
return changed
return changed
def chown_path ( module , path , owner , group ) :
""" Update the owner/group if specified and different from the current owner/group. """
changed = module . set_owner_if_different ( path , owner , False )
return module . set_group_if_different ( path , group , changed )
def chown_recursive ( path , module ) :
def chown_recursive ( path , module ) :
changed = False
changed = False
owner = module . params [ ' owner ' ]
owner = module . params [ ' owner ' ]
group = module . params [ ' group ' ]
group = module . params [ ' group ' ]
# TODO: Consolidate with the other methods calling set_*_if_different methods.
# TODO: Consolidate with the other methods calling set_*_if_different method, this is inefficient.
# Recursing the path for every attribute like this, is inefficient.
file_args = { ' owner ' : owner , ' group ' : group , ' secontext ' : None , ' mode ' : None , ' attributes ' : None }
for dirpath , dirnames , filenames in os . walk ( path ) :
for dirpath , dirnames , filenames in os . walk ( path ) :
file_args [ ' path ' ] = dirpath
changed | = chown_path ( module , dirpath , owner , group )
changed = module . set_fs_attributes_if_different ( file_args , changed )
for subdir in [ os . path . join ( dirpath , d ) for d in dirnames ] :
for subdir in [ os . path . join ( dirpath , d ) for d in dirnames ] :
file_args [ ' path ' ] = subdir
changed | = chown_path ( module , subdir , owner , group )
changed = module . set_fs_attributes_if_different ( file_args , changed )
for filepath in [ os . path . join ( dirpath , f ) for f in filenames ] :
for filepath in [ os . path . join ( dirpath , f ) for f in filenames ] :
file_args [ ' path ' ] = filepath
changed | = chown_path ( module , filepath , owner , group )
changed = module . set_fs_attributes_if_different ( file_args , changed )
return changed
return changed