mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-10-17 19:33:10 +03:00
Compare commits
102 Commits
fix_check_
...
dconf_regi
Author | SHA1 | Date | |
---|---|---|---|
|
1ed181e765 | ||
|
532ca8a420 | ||
|
3efde56398 | ||
|
9567134ea0 | ||
|
5c7c8b4b63 | ||
|
10515c2152 | ||
|
3013ddb1bd | ||
|
ab8d0121f2 | ||
|
45eaf0dffa | ||
|
deea1d2891 | ||
|
1f224fe39c | ||
|
1f55115440 | ||
|
62bcd9cbea | ||
|
4a416c9bee | ||
|
c306876b22 | ||
|
a7e02f80eb | ||
|
3c5c68f65d | ||
|
5d7a33e67d | ||
|
ed4520c335 | ||
|
673b94d350 | ||
|
34b8a7e0e6 | ||
|
2f399f89ce | ||
ead238bbd2 | |||
8ddf22466d | |||
b4a2e35b8e | |||
8d715f4927 | |||
390b1cf563 | |||
135c54314b | |||
b1f852046c | |||
f9ef6a8b2c | |||
893ca07216 | |||
0cd33b361a | |||
6f8541c3e0 | |||
83fede7710 | |||
dea7b7c301 | |||
|
87610cf90a | ||
|
a0685322f9 | ||
|
1e87993b66 | ||
|
994690b4a0 | ||
|
36ea46168f | ||
|
3beee96ca2 | ||
|
0ca6feee03 | ||
|
93bb35ecef | ||
|
cc2dac6619 | ||
|
eba69dca1a | ||
|
d991e5cb00 | ||
|
2b4e79bd49 | ||
|
deabadce4a | ||
|
4027a01605 | ||
|
ffef4fb3c4 | ||
|
6c2fbb4d97 | ||
|
b247e2ff73 | ||
|
406e2149df | ||
|
640fb9e0d0 | ||
|
d60d1af36d | ||
|
a3db43f872 | ||
|
81423a3fe2 | ||
|
bcbe11a205 | ||
|
04836f8a04 | ||
|
bf6c95bdd7 | ||
|
2f5076cac0 | ||
|
dec123f008 | ||
|
87223d2a58 | ||
|
ef67df2a31 | ||
|
26532d039a | ||
|
2843d5eaec | ||
|
3898a838df | ||
|
972450d870 | ||
|
f75a1ae5f2 | ||
|
410f08f43b | ||
|
8551f4f0ce | ||
|
524a6006ed | ||
|
9648cca833 | ||
|
d82f687f29 | ||
|
2e0d735618 | ||
|
fd3bc61e5d | ||
|
24a9e30f10 | ||
|
f7c8491fe7 | ||
|
a3e24f2693 | ||
|
a3c0eb8f68 | ||
|
80003c556e | ||
|
24d1c6a669 | ||
|
1e82576ddb | ||
|
a32238e174 | ||
|
1bc13bbd77 | ||
|
069cd8f5b7 | ||
|
cd617119f5 | ||
|
714976dbac | ||
|
e4369cd087 | ||
|
4aac338ecd | ||
|
6c47a8c72e | ||
|
9a84305b89 | ||
|
9757d32d65 | ||
|
52754f921d | ||
|
c66ba0f799 | ||
|
c33f4cbad3 | ||
|
5f92df44c7 | ||
|
8993492b61 | ||
|
b1e947def1 | ||
|
0fdc8c476f | ||
|
a6a4d60177 | ||
|
64a78235f4 |
@@ -1,22 +0,0 @@
|
||||
_gpoa()
|
||||
{
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
case $prev in
|
||||
--dc)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--loglevel)
|
||||
COMPREPLY=($(compgen -W '0 1 2 3 4 5' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W '--dc --nodomain --noupdate --noplugins --list-backends --loglevel --help' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _gpoa gpoa
|
@@ -1,27 +0,0 @@
|
||||
_gpupdate()
|
||||
{
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
case $prev in
|
||||
-u|--user)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
-t|--target)
|
||||
COMPREPLY=($(compgen -W 'ALL USER COMPUTER' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
-l|--loglevel)
|
||||
COMPREPLY=($(compgen -W '0 1 2 3 4 5' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W '--user --target --loglevel --system --help' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _gpupdate gpupdate
|
||||
|
@@ -1,18 +0,0 @@
|
||||
_gpupdate-setup()
|
||||
{
|
||||
local cur prev words cword split
|
||||
_init_completion -s || return
|
||||
|
||||
case $prev in
|
||||
set-backend)
|
||||
COMPREPLY=($(compgen -W 'local samba' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W 'list list-backends status enable disable update write set-backend default-policy active-policy active-backend' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _gpupdate-setup gpupdate-setup
|
@@ -40,7 +40,6 @@ from util.logging import log
|
||||
|
||||
class samba_backend(applier_backend):
|
||||
__user_policy_mode_key = '/SOFTWARE/Policies/Microsoft/Windows/System/UserPolicyMode'
|
||||
__user_policy_mode_key_win = '/Software/Policies/Microsoft/Windows/System/UserPolicyMode'
|
||||
|
||||
def __init__(self, sambacreds, username, domain, is_machine):
|
||||
self.cache_path = '/var/cache/gpupdate/creds/krb5cc_{}'.format(os.getpid())
|
||||
@@ -79,9 +78,7 @@ class samba_backend(applier_backend):
|
||||
is possible to work with user's part of GPT. This value is
|
||||
checked only if working for user's SID.
|
||||
'''
|
||||
upm_key = self.storage.get_key_value(self.__user_policy_mode_key)
|
||||
upm_win_key = self.storage.get_key_value(self.__user_policy_mode_key_win)
|
||||
upm = upm_key if upm_key else upm_win_key
|
||||
upm = self.storage.get_key_value(self.__user_policy_mode_key)
|
||||
if upm:
|
||||
upm = int(upm)
|
||||
if upm < 0 or upm > 2:
|
||||
@@ -176,16 +173,10 @@ class samba_backend(applier_backend):
|
||||
slogdata = dict({'sysvol_path': gpo.file_sys_path, 'gpo_name': gpo.display_name, 'gpo_path': path})
|
||||
log('D30', slogdata)
|
||||
gpt_abspath = os.path.join(self.cache_dir, 'gpo_cache', path)
|
||||
gpo_version=None
|
||||
try:
|
||||
gpo_version=gpo.version
|
||||
except:
|
||||
log('D210')
|
||||
|
||||
if self._is_machine_username:
|
||||
obj = gpt(gpt_abspath, sid, None, version=gpo_version)
|
||||
obj = gpt(gpt_abspath, sid, None)
|
||||
else:
|
||||
obj = gpt(gpt_abspath, sid, self.username, version=gpo_version)
|
||||
obj = gpt(gpt_abspath, sid, self.username)
|
||||
obj.set_name(gpo.display_name)
|
||||
gpts.append(obj)
|
||||
else:
|
||||
|
@@ -36,8 +36,8 @@ def check_windows_mapping_enabled(storage):
|
||||
flag = storage.get_key_value(windows_mapping_enable_flag)
|
||||
|
||||
result = True
|
||||
flag = str(flag)
|
||||
if flag and '0' == flag:
|
||||
|
||||
if flag and '0' == str(flag):
|
||||
result = False
|
||||
|
||||
return result
|
||||
@@ -48,9 +48,9 @@ def check_module_enabled(storage, module_name):
|
||||
flag = storage.get_key_value(gpupdate_module_flag)
|
||||
|
||||
result = None
|
||||
flag = str(flag)
|
||||
|
||||
if flag:
|
||||
if '1' == flag:
|
||||
if '1' == str(flag):
|
||||
result = True
|
||||
else:
|
||||
result = False
|
||||
|
@@ -92,8 +92,6 @@ class Envvar:
|
||||
value = value.replace('\\', '/')
|
||||
exist_line = None
|
||||
for line in lines:
|
||||
if line == '\n':
|
||||
continue
|
||||
if line.split()[0] == name:
|
||||
exist_line = line
|
||||
break
|
||||
|
@@ -53,7 +53,7 @@ def str2bool(boolstr):
|
||||
|
||||
class Folder:
|
||||
def __init__(self, folder_object, username=None):
|
||||
folder_path = expand_windows_var(folder_object.path, username).replace('\\', '/').replace('//', '/')
|
||||
folder_path = expand_windows_var(folder_object.path, username).replace('\\', '/')
|
||||
if username:
|
||||
folder_path = folder_path.replace(get_homedir(username), '')
|
||||
self.folder_path = Path(get_homedir(username)).joinpath(folder_path if folder_path [0] != '/' else folder_path [1:])
|
||||
|
@@ -33,7 +33,7 @@ from .applier_frontend import (
|
||||
, check_enabled
|
||||
)
|
||||
from util.logging import log
|
||||
from util.util import is_machine_name, try_dict_to_literal_eval
|
||||
from util.util import is_machine_name
|
||||
|
||||
class firefox_applier(applier_frontend):
|
||||
__module_name = 'FirefoxApplier'
|
||||
@@ -83,10 +83,6 @@ class firefox_applier(applier_frontend):
|
||||
try:
|
||||
if type(it_data.data) is bytes:
|
||||
it_data.data = it_data.data.decode(encoding='utf-16').replace('\x00','')
|
||||
json_data = try_dict_to_literal_eval(it_data.data)
|
||||
if json_data:
|
||||
it_data.data = json_data
|
||||
it_data.type = 7
|
||||
#Cases when it is necessary to create nested dictionaries
|
||||
if it_data.valuename != it_data.data:
|
||||
parts = self.get_parts(it_data.hive_key)
|
||||
@@ -99,8 +95,6 @@ class firefox_applier(applier_frontend):
|
||||
branch[parts[-1]] = int(it_data.data)
|
||||
else:
|
||||
branch[parts[-1]] = self.get_boolean(it_data.data)
|
||||
elif it_data.type == 7:
|
||||
branch[parts[-1]] = it_data.data
|
||||
else:
|
||||
branch[parts[-1]] = str(it_data.data).replace('\\', '/')
|
||||
#Cases when it is necessary to create lists in a dictionary
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# GPOA - GPO Applier for Linux
|
||||
#
|
||||
# Copyright (C) 2019-2024 BaseALT Ltd.
|
||||
# Copyright (C) 2019-2023 BaseALT Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -124,24 +124,10 @@ def create_dict(kde_settings, all_kde_settings, locks_settings, locks_dict, file
|
||||
def apply(all_kde_settings, locks_dict, username = None):
|
||||
logdata = dict()
|
||||
if username is None:
|
||||
system_path_settings = '/etc/xdg/'
|
||||
system_files = [
|
||||
"baloofilerc",
|
||||
"kcminputrc",
|
||||
"kded_device_automounterrc",
|
||||
"kdeglobals",
|
||||
"ksplashrc",
|
||||
"kwinrc",
|
||||
"plasma-localerc",
|
||||
"plasmarc",
|
||||
"powermanagementprofilesrc"
|
||||
]
|
||||
for file in system_files:
|
||||
file_to_remove = f'{system_path_settings}{file}'
|
||||
if os.path.exists(file_to_remove):
|
||||
os.remove(file_to_remove)
|
||||
for file_name, sections in all_kde_settings.items():
|
||||
file_path = f'{system_path_settings}{file_name}'
|
||||
file_path = f'/etc/xdg/{file_name}'
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
with open(file_path, 'w') as file:
|
||||
for section, keys in sections.items():
|
||||
section = section.replace(')(', '][')
|
||||
@@ -289,4 +275,4 @@ def get_id_desktop(path_to_wallpaper):
|
||||
else:
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
return None
|
@@ -62,7 +62,8 @@ class package_applier(applier_frontend):
|
||||
)
|
||||
def run(self):
|
||||
for flag in self.sync_packages_setting:
|
||||
self.flagSync = bool(flag.data)
|
||||
if flag.data:
|
||||
self.flagSync = bool(int(flag.data))
|
||||
|
||||
if 0 < self.install_packages_setting.count() or 0 < self.remove_packages_setting.count():
|
||||
if self.flagSync:
|
||||
|
@@ -26,8 +26,8 @@ from util.logging import log
|
||||
|
||||
class polkit_applier(applier_frontend):
|
||||
__module_name = 'PolkitApplier'
|
||||
__module_experimental = False
|
||||
__module_enabled = True
|
||||
__module_experimental = True
|
||||
__module_enabled = False
|
||||
__deny_all_win = 'Software\\Policies\\Microsoft\\Windows\\RemovableStorageDevices\\Deny_All'
|
||||
__registry_branch = 'Software\\BaseALT\\Policies\\Polkit\\'
|
||||
__registry_locks_branch = 'Software\\BaseALT\\Policies\\PolkitLocks\\'
|
||||
@@ -106,8 +106,8 @@ class polkit_applier(applier_frontend):
|
||||
|
||||
class polkit_applier_user(applier_frontend):
|
||||
__module_name = 'PolkitApplierUser'
|
||||
__module_experimental = False
|
||||
__module_enabled = True
|
||||
__module_experimental = True
|
||||
__module_enabled = False
|
||||
__deny_all_win = 'Software\\Policies\\Microsoft\\Windows\\RemovableStorageDevices\\Deny_All'
|
||||
__registry_branch = 'Software\\BaseALT\\Policies\\Polkit\\'
|
||||
__polkit_map = {
|
||||
|
@@ -153,13 +153,12 @@ def get_merger(preference_type):
|
||||
return mergers[preference_type]
|
||||
|
||||
class gpt:
|
||||
def __init__(self, gpt_path, sid, username='Machine', version=None):
|
||||
def __init__(self, gpt_path, sid, username='Machine'):
|
||||
self.path = gpt_path
|
||||
self.username = username
|
||||
self.sid = sid
|
||||
self.storage = registry_factory()
|
||||
self.storage._gpt_read_flag = True
|
||||
self.version = version
|
||||
self.name = ''
|
||||
self.guid = self.path.rpartition('/')[2]
|
||||
if 'default' == self.guid:
|
||||
@@ -217,7 +216,7 @@ class gpt:
|
||||
if self.settings['machine']['regpol']:
|
||||
mlogdata = dict({'polfile': self.settings['machine']['regpol']})
|
||||
log('D34', mlogdata)
|
||||
util.preg.merge_polfile(self.settings['machine']['regpol'], policy_name=self.name, version=self.version)
|
||||
util.preg.merge_polfile(self.settings['machine']['regpol'], policy_name=self.name)
|
||||
# Merge machine preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['machine'].items():
|
||||
if preference_path:
|
||||
@@ -246,8 +245,7 @@ class gpt:
|
||||
util.preg.merge_polfile(self.settings['user']['regpol'],
|
||||
sid=self.sid,
|
||||
policy_name=self.name,
|
||||
username=self.username,
|
||||
version=self.version)
|
||||
username=self.username)
|
||||
# Merge user preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['user'].items():
|
||||
if preference_path:
|
||||
|
@@ -149,7 +149,6 @@ class shortcut:
|
||||
self.comment = ''
|
||||
self.is_in_user_context = self.set_usercontext()
|
||||
self.type = ttype
|
||||
self.desktop_file_template = None
|
||||
|
||||
def replace_slashes(self, input_path):
|
||||
if input_path.startswith('%'):
|
||||
@@ -248,10 +247,11 @@ class shortcut:
|
||||
if dest:
|
||||
self.desktop_file = DesktopEntry(dest)
|
||||
else:
|
||||
self.desktop_file_template = find_desktop_entry(self.path)
|
||||
self.desktop_file = DesktopEntry()
|
||||
self.desktop_file.addGroup('Desktop Entry')
|
||||
self.desktop_file.set('Version', '1.0')
|
||||
self.desktop_file = find_desktop_entry(self.path)
|
||||
if not self.desktop_file:
|
||||
self.desktop_file = DesktopEntry()
|
||||
self.desktop_file.addGroup('Desktop Entry')
|
||||
self.desktop_file.set('Version', '1.0')
|
||||
self._update_desktop()
|
||||
|
||||
return self.desktop_file
|
||||
@@ -273,18 +273,13 @@ class shortcut:
|
||||
if self.type == TargetType.URL:
|
||||
self.desktop_file.set('URL', desktop_path)
|
||||
else:
|
||||
str2bool_lambda = (lambda boolstr: boolstr if isinstance(boolstr, bool)
|
||||
else boolstr and boolstr.lower() in ['True', 'true', 'yes', '1'])
|
||||
if self.desktop_file_template:
|
||||
terminal_state = str2bool_lambda(self.desktop_file_template.get('Terminal'))
|
||||
self.desktop_file.set('Terminal', 'true' if terminal_state else 'false')
|
||||
terminal_state = bool(self.desktop_file.get('Terminal'))
|
||||
self.desktop_file.set('Terminal', 'true' if terminal_state else 'false')
|
||||
self.desktop_file.set('Exec', '{} {}'.format(desktop_path, self.arguments))
|
||||
self.desktop_file.set('Comment', self.comment)
|
||||
|
||||
if self.icon:
|
||||
self.desktop_file.set('Icon', self.icon)
|
||||
elif self.desktop_file_template and self.desktop_file_template.get('Icon', False):
|
||||
self.desktop_file.set('Icon', self.desktop_file_template.get('Icon'))
|
||||
|
||||
def _write_desktop(self, dest, create_only=False, read_firstly=False):
|
||||
'''
|
||||
|
@@ -865,10 +865,7 @@ msgid "No entry found for the specified path"
|
||||
msgstr "Не найдено записей по указанному пути"
|
||||
|
||||
msgid "Creating an ini file with policies for dconf"
|
||||
msgstr "Создание ini-файла с политиками для dconf"
|
||||
|
||||
msgid "GPO version was not found"
|
||||
msgstr "Версия GPO не найдена"
|
||||
msgstr "Создание ini-фала с политиками для dconf"
|
||||
|
||||
# Debug_end
|
||||
|
||||
|
@@ -320,7 +320,6 @@ def debug_code(code):
|
||||
debug_ids[207] = 'Creating a dictionary with keys and values from the dconf database'
|
||||
debug_ids[208] = 'No entry found for the specified path'
|
||||
debug_ids[209] = 'Creating an ini file with policies for dconf'
|
||||
debug_ids[210] = 'GPO version was not found'
|
||||
|
||||
return debug_ids.get(code, 'Unknown debug code')
|
||||
|
||||
|
@@ -21,8 +21,6 @@ import subprocess
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import psutil
|
||||
import time
|
||||
|
||||
class Scripts_runner:
|
||||
'''
|
||||
@@ -106,39 +104,12 @@ class Scripts_runner:
|
||||
|
||||
def run_cmd_subprocess(self, cmd):
|
||||
try:
|
||||
subprocess.run(cmd)
|
||||
subprocess.Popen(cmd)
|
||||
return 'Script run: {}'.format(cmd)
|
||||
except Exception as exc:
|
||||
return exc
|
||||
|
||||
def find_process_by_name_and_script(name, script_path):
|
||||
|
||||
for proc in psutil.process_iter(['pid', 'name', 'cmdline']):
|
||||
try:
|
||||
# Check if the process name matches and the script path is in the command line arguments
|
||||
if proc.info['name'] == name and script_path in proc.info['cmdline']:
|
||||
return proc
|
||||
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
||||
continue
|
||||
return None
|
||||
|
||||
def wait_for_process(name, script_path, check_interval=1):
|
||||
|
||||
process = find_process_by_name_and_script(name, script_path)
|
||||
if not process:
|
||||
print(f"Process with name {name} and script path {script_path} not found.")
|
||||
return
|
||||
|
||||
try:
|
||||
# Loop to wait for the process to finish
|
||||
while process.is_running():
|
||||
print(f"Waiting for process {name} with PID {process.pid} to finish...")
|
||||
time.sleep(check_interval)
|
||||
print(f"Process {name} with PID {process.pid} has finished.")
|
||||
return
|
||||
except (psutil.NoSuchProcess, psutil.AccessDenied):
|
||||
print(f"Process {name} with PID {process.pid} is no longer accessible.")
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Scripts runner')
|
||||
@@ -146,9 +117,6 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--user', type = str, help = 'User name ', nargs = '?', default = None)
|
||||
parser.add_argument('--action', type = str, help = 'MACHINE : [STARTUP or SHUTDOWN], USER : [LOGON or LOGOFF]', nargs = '?', default = None)
|
||||
|
||||
process_name = "python3"
|
||||
script_path = "/usr/sbin/gpoa"
|
||||
wait_for_process(process_name, script_path)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
Scripts_runner(args.mode, args.user, args.action)
|
||||
|
@@ -22,10 +22,11 @@ from storage.dconf_registry import Dconf_registry
|
||||
def registry_factory(registry_name='', envprofile=None , username=None):
|
||||
if username:
|
||||
Dconf_registry._username = username
|
||||
else:
|
||||
Dconf_registry._envprofile = 'system'
|
||||
if envprofile:
|
||||
Dconf_registry._envprofile = envprofile
|
||||
if envprofile == 'local':
|
||||
Dconf_registry._local_envprofile = True
|
||||
elif envprofile == 'default':
|
||||
Dconf_registry._default_envprofile = True
|
||||
|
||||
if registry_name == 'dconf':
|
||||
return Dconf_registry()
|
||||
|
@@ -58,7 +58,8 @@ class Dconf_registry():
|
||||
__dconf_dict_flag = False
|
||||
__dconf_dict = dict()
|
||||
_username = None
|
||||
_envprofile = None
|
||||
_default_envprofile = None
|
||||
_local_envprofile = None
|
||||
|
||||
list_keys = list()
|
||||
_info = dict()
|
||||
@@ -92,7 +93,9 @@ class Dconf_registry():
|
||||
if path[0] != '/':
|
||||
path = '/' + path
|
||||
logdata = dict()
|
||||
envprofile = get_dconf_envprofile()
|
||||
envprofile = get_dconf_envprofile(Dconf_registry._username,
|
||||
Dconf_registry._default_envprofile,
|
||||
Dconf_registry._local_envprofile)
|
||||
try:
|
||||
process = subprocess.Popen(['dconf', 'list', path],
|
||||
env=envprofile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
@@ -123,7 +126,9 @@ class Dconf_registry():
|
||||
@staticmethod
|
||||
def get_key_value(key):
|
||||
logdata = dict()
|
||||
envprofile = get_dconf_envprofile()
|
||||
envprofile = get_dconf_envprofile(Dconf_registry._username,
|
||||
Dconf_registry._default_envprofile,
|
||||
Dconf_registry._local_envprofile)
|
||||
try:
|
||||
process = subprocess.Popen(['dconf', 'read', key],
|
||||
env=envprofile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
@@ -446,7 +451,7 @@ def update_dict(dict1, dict2):
|
||||
dict1[key] = value
|
||||
|
||||
|
||||
def add_to_dict(string, policy_name, username, version):
|
||||
def add_to_dict(string, policy_name, username):
|
||||
if username is None:
|
||||
correct_path = '/'.join(string.split('/')[:-2])
|
||||
machine= '{}/Machine'.format(Dconf_registry._ReadQueue)
|
||||
@@ -456,47 +461,40 @@ def add_to_dict(string, policy_name, username, version):
|
||||
user = '{}/User'.format(Dconf_registry._ReadQueue)
|
||||
dictionary = Dconf_registry.global_registry_dict.setdefault(user, dict())
|
||||
|
||||
dictionary[len(dictionary)] = (policy_name, correct_path, version)
|
||||
dictionary[len(dictionary)] = (policy_name, correct_path)
|
||||
|
||||
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username, version=None):
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username):
|
||||
'''
|
||||
Loads the configuration from preg registry into a dictionary
|
||||
'''
|
||||
dd = dict()
|
||||
dd_win_style = dict()
|
||||
for i in pregfile.entries:
|
||||
# Skip this entry if the valuename starts with '**del'
|
||||
if i.valuename.startswith('**del'):
|
||||
continue
|
||||
valuename = convert_string_dconf(i.valuename)
|
||||
data = check_data(i.data, i.type)
|
||||
if i.valuename != i.data and i.valuename:
|
||||
if i.valuename != i.data:
|
||||
if i.keyname.replace('\\', '/') in dd:
|
||||
# If the key exists in dd, update its value with the new key-value pair
|
||||
dd[i.keyname.replace('\\', '/')].update({valuename.replace('\\', '/'):data})
|
||||
dd[i.keyname.replace('\\', '/')].update({valuename.replace('\\', '/'):i.data})
|
||||
dd_win_style[i.keyname].update({valuename:i.data})
|
||||
else:
|
||||
# If the key does not exist in dd, create a new key-value pair
|
||||
dd[i.keyname.replace('\\', '/')] = {valuename.replace('\\', '/'):data}
|
||||
|
||||
elif not i.valuename:
|
||||
keyname_tmp = i.keyname.replace('\\', '/').split('/')
|
||||
keyname = '/'.join(keyname_tmp[:-1])
|
||||
if keyname in dd:
|
||||
# If the key exists in dd, update its value with the new key-value pair
|
||||
dd[keyname].update({keyname_tmp[-1]:data})
|
||||
else:
|
||||
# If the key does not exist in dd, create a new key-value pair
|
||||
dd[keyname] = {keyname_tmp[-1]:data}
|
||||
|
||||
dd[i.keyname.replace('\\', '/')] = {valuename.replace('\\', '/'):i.data}
|
||||
dd_win_style[i.keyname] = {valuename:i.data}
|
||||
else:
|
||||
# If the value name is the same as the data,
|
||||
# split the keyname and add the data to the appropriate location in dd.
|
||||
all_list_key = i.keyname.split('\\')
|
||||
dd_target = dd.setdefault('/'.join(all_list_key[:-1]),{})
|
||||
dd_target.setdefault(all_list_key[-1], []).append(data)
|
||||
dd_target.setdefault(all_list_key[-1], []).append(i.data)
|
||||
|
||||
dd_target_win = dd_win_style.setdefault('\\'.join(all_list_key[:-1]),{})
|
||||
dd_target_win.setdefault(all_list_key[-1], []).append(i.data)
|
||||
# Update the global registry dictionary with the contents of dd
|
||||
add_to_dict(pathfile, policy_name, username, version)
|
||||
add_to_dict(pathfile, policy_name, username)
|
||||
update_dict(Dconf_registry.global_registry_dict, dd)
|
||||
|
||||
|
||||
@@ -525,36 +523,14 @@ def create_dconf_ini_file(filename, data):
|
||||
log('D209', logdata)
|
||||
Dconf_registry.dconf_update()
|
||||
|
||||
def clean_data(data):
|
||||
try:
|
||||
cleaned_string = data.replace('\n', '').replace('\r', '')
|
||||
cleaned_string = cleaned_string.replace('"', "'")
|
||||
return cleaned_string
|
||||
except:
|
||||
return None
|
||||
|
||||
def check_data(data, t_data):
|
||||
if isinstance(data, bytes):
|
||||
if t_data == 7:
|
||||
return clean_data(data.decode('utf-16').replace('\x00',''))
|
||||
else:
|
||||
return None
|
||||
elif t_data == 4:
|
||||
return data
|
||||
return clean_data(data)
|
||||
|
||||
def convert_string_dconf(input_string):
|
||||
macros = {
|
||||
'#': '%sharp%',
|
||||
';': '%semicolon%',
|
||||
'//': '%doubleslash%'
|
||||
}
|
||||
output_string = input_string
|
||||
for key, value in macros.items():
|
||||
if key in input_string:
|
||||
output_string = input_string.replace(key, value)
|
||||
elif value in input_string:
|
||||
output_string = input_string.replace(value, key)
|
||||
# Check if the input string contains '%semicolon%'
|
||||
if '%semicolon%' in input_string:
|
||||
# If it contains, replace '%semicolon%' with ';'
|
||||
output_string = input_string.replace('%semicolon%', ';')
|
||||
else:
|
||||
# If it doesn't contain, replace ';' with '%semicolon%'
|
||||
output_string = input_string.replace(';', '%semicolon%')
|
||||
|
||||
return output_string
|
||||
|
||||
@@ -575,17 +551,15 @@ def flatten_dictionary(input_dict, result=None, current_key=''):
|
||||
|
||||
return result
|
||||
|
||||
def get_dconf_envprofile():
|
||||
dconf_envprofile = {'default': {'DCONF_PROFILE': 'default'},
|
||||
'local': {'DCONF_PROFILE': 'local'},
|
||||
'system': {'DCONF_PROFILE': 'system'}
|
||||
}
|
||||
def get_dconf_envprofile(user=None, default=None, local=None):
|
||||
if default:
|
||||
return {'DCONF_PROFILE': 'default'}
|
||||
|
||||
if Dconf_registry._envprofile:
|
||||
return dconf_envprofile.get(Dconf_registry._envprofile, dconf_envprofile['system'])
|
||||
if local:
|
||||
return {'DCONF_PROFILE': 'local'}
|
||||
|
||||
if not Dconf_registry._username:
|
||||
return dconf_envprofile['system']
|
||||
if not user:
|
||||
return {'DCONF_PROFILE': 'system'}
|
||||
|
||||
profile = '/run/dconf/user/{}'.format(get_uid_by_username(Dconf_registry._username))
|
||||
profile = '/run/dconf/user/{}'.format(get_uid_by_username(user))
|
||||
return {'DCONF_PROFILE': profile}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{% if Deny_All == 1 %}
|
||||
{% if Deny_All == '1' %}
|
||||
polkit.addRule(function (action, subject) {
|
||||
if ((action.id == "org.freedesktop.udisks2.filesystem-mount" ||
|
||||
action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#}
|
||||
|
||||
{% if Deny_All == 1 %}
|
||||
{% if Deny_All == '1' %}
|
||||
polkit.addRule(function (action, subject) {
|
||||
if (action.id == "org.freedesktop.udisks2.filesystem-mount" ||
|
||||
action.id == "org.freedesktop.udisks2.filesystem-mount-system" ||
|
||||
|
@@ -81,12 +81,12 @@ def preg_keymap(preg):
|
||||
return keymap
|
||||
|
||||
|
||||
def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None, policy_name='Unknown', username='Machine', version=None):
|
||||
def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None, policy_name='Unknown', username='Machine'):
|
||||
pregfile = load_preg(preg)
|
||||
if sid is None and username == 'Machine':
|
||||
load_preg_dconf(pregfile, preg, policy_name, None, version)
|
||||
load_preg_dconf(pregfile, preg, policy_name, None)
|
||||
else:
|
||||
load_preg_dconf(pregfile, preg, policy_name, username, version)
|
||||
load_preg_dconf(pregfile, preg, policy_name, username)
|
||||
logdata = dict({'pregfile': preg})
|
||||
log('D32', logdata)
|
||||
#log dconf
|
||||
|
@@ -175,16 +175,6 @@ def string_to_literal_eval(string):
|
||||
literaleval = string
|
||||
return literaleval
|
||||
|
||||
def try_dict_to_literal_eval(string):
|
||||
try:
|
||||
literaleval = ast.literal_eval(string)
|
||||
if isinstance(literaleval ,dict):
|
||||
return literaleval
|
||||
else:
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
|
||||
def touch_file(filename):
|
||||
path = Path(filename)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
@@ -317,7 +317,7 @@ def expand_windows_var(text, username=None):
|
||||
for var in variables.keys():
|
||||
result = result.replace('%{}%'.format(var),
|
||||
variables[var] if variables[var][-1] == '/'
|
||||
else variables[var] +'/')
|
||||
else variables[var] +'/').replace('//','/')
|
||||
|
||||
return result
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
%add_python3_req_skip util.gpoa_ini_parsing
|
||||
|
||||
Name: gpupdate
|
||||
Version: 0.10.3
|
||||
Version: 0.9.13.8
|
||||
Release: alt1
|
||||
|
||||
Summary: GPT applier
|
||||
@@ -54,7 +54,6 @@ Requires: libnss-role >= 0.5.0
|
||||
Requires: local-policy >= 0.4.9
|
||||
Requires: pam-config >= 1.9.0
|
||||
Requires: autofs
|
||||
Requires: dconf-profile
|
||||
# This is needed by shortcuts_applier
|
||||
Requires: desktop-file-utils
|
||||
# This is needed for smb file cache support
|
||||
@@ -121,9 +120,6 @@ install -Dm0644 dist/%name-remote-policy %buildroot%_sysconfdir/pam.d/%name-remo
|
||||
install -Dm0644 dist/%name.ini %buildroot%_sysconfdir/%name/%name.ini
|
||||
install -Dm0644 doc/gpoa.1 %buildroot/%_man1dir/gpoa.1
|
||||
install -Dm0644 doc/gpupdate.1 %buildroot/%_man1dir/gpupdate.1
|
||||
install -Dm0644 completions/gpoa %buildroot/%_datadir/bash-completion/completions/gpoa
|
||||
install -Dm0644 completions/gpupdate %buildroot/%_datadir/bash-completion/completions/gpupdate
|
||||
install -Dm0644 completions/gpupdate-setup %buildroot/%_datadir/bash-completion/completions/gpupdate-setup
|
||||
|
||||
for i in gpupdate-localusers \
|
||||
gpupdate-group-users \
|
||||
@@ -170,12 +166,9 @@ fi
|
||||
%_unitdir/%name.timer
|
||||
%_man1dir/gpoa.1.*
|
||||
%_man1dir/gpupdate.1.*
|
||||
%_datadir/bash-completion/completions/gpoa
|
||||
%_datadir/bash-completion/completions/gpupdate
|
||||
%_datadir/bash-completion/completions/gpupdate-setup
|
||||
%_user_unitdir/%name-user.service
|
||||
%_user_unitdir/%name-user.timer
|
||||
%_user_unitdir/%name-scripts-run-user.service
|
||||
/usr/lib/systemd/user/%name-user.service
|
||||
/usr/lib/systemd/user/%name-user.timer
|
||||
/usr/lib/systemd/user/%name-scripts-run-user.service
|
||||
%dir %_sysconfdir/%name
|
||||
%_sysconfdir/control.d/facilities/*
|
||||
%config(noreplace) %_sysconfdir/%name/environment
|
||||
@@ -191,29 +184,6 @@ fi
|
||||
%exclude %python3_sitelibdir/gpoa/test
|
||||
|
||||
%changelog
|
||||
* Wed Jun 19 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.3-alt1
|
||||
- Added autocompletion for gpoa, gpupdate, gpupdate-setup
|
||||
- Added correct work with json data in keys for the Firefox browser
|
||||
- Polkit_appliers changed to non-experimental
|
||||
- Fixed bug of not clearing kde applier settings (closes: 50336)
|
||||
- Fixed registry key reading (closes: 50553)
|
||||
- Added waiting for data generation for scripts (closes: 50667)
|
||||
|
||||
* Fri Jun 07 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.2-alt1
|
||||
- Added some fixes to dconf_registry and scripts
|
||||
- Fixed windows registry key reading for loopback
|
||||
|
||||
* Tue Jun 04 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.1-alt1
|
||||
- Added handling of unexpected data types when writing to dconf
|
||||
|
||||
* Mon May 13 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.0-alt1
|
||||
- A method for storing registry keys obtained from GPOs (Group Policy Objects)
|
||||
has undergone significant repairs. We have switched from using SQLite
|
||||
to using Dconf to improve data storage efficiency
|
||||
|
||||
* Wed Mar 13 2024 Valery Sinelnikov <greh@altlinux.org> 0.9.13.9-alt1
|
||||
- Fixed premature removal of double slash
|
||||
|
||||
* Thu Feb 22 2024 Valery Sinelnikov <greh@altlinux.org> 0.9.13.8-alt1
|
||||
- Added search for dc on the site
|
||||
- Added compatibility support for the oldest versions of SQLAlchemy
|
||||
|
Reference in New Issue
Block a user