1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Fix Scripts appliers prepare running

This commit is contained in:
Evgeny Sinelnikov 2022-05-08 16:56:33 +04:00
parent 6283d72ccc
commit 70bc4faea3
2 changed files with 56 additions and 51 deletions

View File

@ -40,44 +40,43 @@ class scripts_applier(applier_frontend):
self.sid = sid
self.scripts = self.storage.get_scripts(self.sid)
self.folder_path = Path(self.__cache_scripts)
machine_name = os.uname()[1] + '$'
check_sid = pysss_nss_idmap.getsidbyname(machine_name)
self.__module_enabled = check_enabled(self.storage
, self.__module_name
, self.__module_experimental
)
self.filling_cache()
def cleaning_cache(self):
try:
remove_dir_tree(self.folder_path, True, True, True,)
except FileNotFoundError as exc:
log('D154')
except Exception as exc:
logdata = dict()
logdata['exc'] = exc
log('E64', logdata)
def filling_cache(self):
'''
Creating and updating folder directories for scripts and copying them
'''
machine_name = os.uname()[1] + '$'
check_sid = pysss_nss_idmap.getsidbyname(machine_name)
if self.sid in check_sid[machine_name]['sid']:
try:
remove_dir_tree(self.folder_path, True, True, True,)
except FileNotFoundError as exc:
log('D154')
except Exception as exc:
logdata = dict()
logdata['exc'] = exc
log('E64', logdata)
self.folder_path.mkdir(parents=True, exist_ok=True)
if self.__module_enabled:
for ts in self.scripts:
if ts.path.split('/')[-4] == 'MACHINE':
script_path = (self.__cache_scripts +
ts.policy_num + '/' +
'/'.join(ts.path.split('/')[ts.path.split('/').index('POLICIES')+4:-1]))
install_script(ts, script_path, '700')
self.folder_path.mkdir(parents=True, exist_ok=True)
for ts in self.scripts:
if ts.path.split('/')[-4] == 'MACHINE':
script_path = (self.__cache_scripts +
ts.policy_num + '/' +
'/'.join(ts.path.split('/')[ts.path.split('/').index('POLICIES')+4:-1]))
install_script(ts, script_path, '700')
def run(self):
pass
self.filling_cache()
def apply(self):
pass
self.cleaning_cache()
if self.__module_enabled:
log('D156')
self.run()
else:
log('D157')
class scripts_applier_user(applier_frontend):
__module_name = 'ScriptsApplierUser'
@ -97,41 +96,43 @@ class scripts_applier_user(applier_frontend):
)
self.filling_cache()
def cleaning_cache(self):
try:
remove_dir_tree(self.folder_path, True, True, True,)
except FileNotFoundError as exc:
log('D155')
except Exception as exc:
logdata = dict()
logdata['exc'] = exc
log('E65', logdata)
def filling_cache(self):
'''
Creating and updating folder directories for scripts and copying them
'''
if self.username[:-1] != os.uname()[1].upper():
try:
remove_dir_tree(self.folder_path, True, True, True,)
except FileNotFoundError as exc:
log('D155')
except Exception as exc:
logdata = dict()
logdata['exc'] = exc
log('E65', logdata)
self.folder_path.mkdir(parents=True, exist_ok=True)
if self.__module_enabled:
for ts in self.scripts:
if ts.path.split('/')[-4] == 'USER':
script_path = (self.__cache_scripts +
self.username + '/' +
ts.policy_num + '/' +
'/'.join(ts.path.split('/')[ts.path.split('/').index('POLICIES')+4:-1]))
install_script(ts, script_path, '755')
self.folder_path.mkdir(parents=True, exist_ok=True)
if self.__module_enabled:
for ts in self.scripts:
if ts.path.split('/')[-4] == 'USER':
script_path = (self.__cache_scripts +
self.username + '/' +
ts.policy_num + '/' +
'/'.join(ts.path.split('/')[ts.path.split('/').index('POLICIES')+4:-1]))
install_script(ts, script_path, '755')
def user_context_apply(self):
pass
def run(self):
pass
self.filling_cache()
def admin_context_apply(self):
'''
Install software assigned to specified username regardless
which computer he uses to log into system.
'''
pass
self.cleaning_cache()
if self.__module_enabled:
log('D158')
self.run()
else:
log('D159')
def install_script(storage_script_entry, script_path, access_permissions):
'''

View File

@ -261,6 +261,10 @@ def debug_code(code):
debug_ids[153] = 'Saving information about script'
debug_ids[154] = 'No machine scripts directory to clean up'
debug_ids[155] = 'No user scripts directory to clean up'
debug_ids[156] = 'Prepare Scripts applier for machine'
debug_ids[157] = 'Scripts applier for machine will not be started'
debug_ids[158] = 'Prepare Scripts applier for user in user context'
debug_ids[159] = 'Scripts applier for user in user context will not be started'
return debug_ids.get(code, 'Unknown debug code')