#NEWLINE# def chpgrp( path , group ) : #NEWLINE# #INDENT# '\n    Change the group of a file\n\n    Under Windows, this will set the rarely used primary group of a file.\n    This generally has no bearing on permissions unless intentionally\n    configured and is most commonly used to provide Unix compatibility (e.g.\n    Services For Unix, NFS services).\n\n    Ensure you know what you are doing before using this function.\n\n    To set the primary group to \'None\', it must be specified in quotes.\n    Otherwise Salt will interpret it as the Python value of None and no primary\n    group changes will occur. See the example below.\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt \'*\' file.chpgrp c:\\temp\\test.txt Administrators\n        salt \'*\' file.chpgrp c:\\temp\\test.txt "\'None\'"\n    ' #NEWLINE# if ( group is None ) : #NEWLINE# #INDENT# raise SaltInvocationError ( "The group value was specified as None and is invalid. If you mean the built-in None group, specify the group in lowercase, e.g. 'none'." ) #NEWLINE# #UNINDENT# err = '' #NEWLINE# try : #NEWLINE# #INDENT# ( groupSID , domainName , objectType ) = win32security . LookupAccountName ( None , group ) #NEWLINE# #UNINDENT# except pywinerror : #NEWLINE# #INDENT# err += 'Group does not exist\n' #NEWLINE# #UNINDENT# if ( not os . path . exists ( path ) ) : #NEWLINE# #INDENT# err += 'File not found\n' #NEWLINE# #UNINDENT# if privilege_enabled : #NEWLINE# #INDENT# return err #NEWLINE# #UNINDENT# privilege_enabled = False #NEWLINE# try : #NEWLINE# #INDENT# privilege_enabled = _enable_privilege ( win32security . SE_RESTORE_NAME ) #NEWLINE# win32security . SetNamedSecurityInfo ( path , win32security . SE_FILE_OBJECT , win32security . GROUP_SECURITY_INFORMATION , None , groupSID , None , None ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if privilege_enabled : #NEWLINE# #INDENT# _disable_privilege ( win32security . SE_RESTORE_NAME ) #NEWLINE# #UNINDENT# #UNINDENT# return None