def set_keyfile_access(file_path): #shutil.chown is not in python2 try: uid = pwd.getpwnam(settings.pacemaker_uname).pw_uid except KeyError: raise LibraryError( common_reports.unable_to_determine_user_uid( settings.pacemaker_uname)) try: gid = grp.getgrnam(settings.pacemaker_gname).gr_gid except KeyError: raise LibraryError( common_reports.unable_to_determine_group_gid( settings.pacemaker_gname)) try: os.chown(file_path, uid, gid) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chown", e) try: # According to booth documentation, user and group of booth authfile # should be set to hacluster/haclient (created and used by pacemaker) # but mode of file doesn't need to be same as pacemaker authfile. os.chmod(file_path, settings.booth_authkey_file_mode) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chmod", e)
def set_keyfile_access(file_path): #shutil.chown is not in python2 try: uid = pwd.getpwnam(settings.pacemaker_uname).pw_uid except KeyError: raise LibraryError(common_reports.unable_to_determine_user_uid( settings.pacemaker_uname )) try: gid = grp.getgrnam(settings.pacemaker_gname).gr_gid except KeyError: raise LibraryError(common_reports.unable_to_determine_group_gid( settings.pacemaker_gname )) try: os.chown(file_path, uid, gid) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chown", e) try: # According to booth documentation, user and group of booth authfile # should be set to hacluster/haclient (created and used by pacemaker) # but mode of file doesn't need to be same as pacemaker authfile. os.chmod(file_path, settings.booth_authkey_file_mode) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chmod", e)
def set_keyfile_access(file_path): # shutil.chown is not in python2 try: uid = pwd.getpwnam(settings.pacemaker_uname).pw_uid except KeyError: raise LibraryError(common_reports.unable_to_determine_user_uid(settings.pacemaker_uname)) try: gid = grp.getgrnam(settings.pacemaker_gname).gr_gid except KeyError: raise LibraryError(common_reports.unable_to_determine_group_gid(settings.pacemaker_gname)) try: os.chown(file_path, uid, gid) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chown", e) try: os.chmod(file_path, 0o600) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chmod", e)
def set_keyfile_access(file_path): #shutil.chown is not in python2 try: uid = pwd.getpwnam(settings.pacemaker_uname).pw_uid except KeyError: raise LibraryError( common_reports.unable_to_determine_user_uid( settings.pacemaker_uname)) try: gid = grp.getgrnam(settings.pacemaker_gname).gr_gid except KeyError: raise LibraryError( common_reports.unable_to_determine_group_gid( settings.pacemaker_gname)) try: os.chown(file_path, uid, gid) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chown", e) try: os.chmod(file_path, 0o600) except EnvironmentError as e: raise report_keyfile_io_error(file_path, "chmod", e)