mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-10-18 19:33:32 +03:00
Compare commits
144 Commits
dconf_regi
...
fix_check_
Author | SHA1 | Date | |
---|---|---|---|
527c4f8172 | |||
|
c57d1bac9e | ||
b9b5239448 | |||
aae2776790 | |||
|
a20aa841d6 | ||
|
8c7819d96f | ||
|
3d9473f979 | ||
|
01f48be853 | ||
|
1638098fd4 | ||
|
047e5459af | ||
|
5baa4245e3 | ||
ec6b9f7887 | |||
22d0d23b89 | |||
fd3a32e8e1 | |||
|
9e849e8fe3 | ||
|
d65f3ed942 | ||
|
31298be840 | ||
|
5c889fd57e | ||
|
4e2874c972 | ||
|
63e50ac2df | ||
|
ad2a87e20d | ||
|
e9c3a4262a | ||
|
b5706ec6e1 | ||
|
61e7350429 | ||
|
c9a274fc79 | ||
|
127c9f7183 | ||
|
a27f8ba5dd | ||
|
fafe2c34b4 | ||
|
9c91ddc7ba | ||
|
1f02ed650b | ||
|
fc47df4649 | ||
|
42b8bdb82a | ||
|
2a174edeef | ||
|
9b8529b39b | ||
|
062ff742c3 | ||
|
1764560c49 | ||
|
b439e04a2f | ||
|
e413f95633 | ||
|
675f37ab85 | ||
|
9932c682ef | ||
|
018b30cdc4 | ||
|
249eb69ade | ||
|
1ab8c7aee0 | ||
|
400a5fab7d | ||
|
e7851e88b3 | ||
|
0761637666 | ||
|
dda4d987cb | ||
|
609ec0e8b8 | ||
|
c0b28a0655 | ||
|
78aad11e06 | ||
|
59bebbc45e | ||
|
e92656add0 | ||
|
5d24579d2f | ||
|
ce284b61be | ||
|
7a8118ac63 | ||
|
18d8e73acd | ||
|
58235cb1a1 | ||
|
e0d88cc076 | ||
|
c8b0927090 | ||
|
a4a79d8c99 | ||
|
408609fa58 | ||
|
6efebfad89 | ||
12865b0b43 | |||
9117dddcee | |||
1e267f5cb6 | |||
62ed015ea9 | |||
3e6b7cd040 | |||
209eb84d6d | |||
7f3b47a23c | |||
08ba87c8d8 | |||
f2a45a2a6d | |||
9c544adc94 | |||
a225c9aa7f | |||
51c8711da6 | |||
54eb4188a7 | |||
|
89d5e36d6c | ||
|
6cd5ab4ee2 | ||
|
0c913c68e3 | ||
|
12d746a1dc | ||
|
0a25f3a1d6 | ||
|
1eaab893c8 | ||
|
05ea872831 | ||
|
d0506dba29 | ||
|
dd28587b20 | ||
|
1a288c84f5 | ||
|
cadc3eda52 | ||
|
8d3e6691d4 | ||
|
cb54fa5d78 | ||
|
53ffc072f0 | ||
|
7a59bcb65b | ||
|
b81a727cd4 | ||
|
11b33dd148 | ||
|
1ccc18a31f | ||
|
9a3afeebdf | ||
|
0720471cca | ||
|
dd43ddaad6 | ||
|
6fc059aaac | ||
|
8cfb6f0bb3 | ||
|
ddcdc322f8 | ||
|
4ee52f06d6 | ||
|
603efc2deb | ||
|
9fc5007590 | ||
|
a6210f8b29 | ||
|
175f244a5f | ||
|
0d4ce533bc | ||
|
8e22235df2 | ||
|
0519d2703c | ||
|
1ca9b006e1 | ||
|
8cc5a8904b | ||
|
70cdef2e71 | ||
|
3baffeb12d | ||
|
a0d9dc585f | ||
|
388125415b | ||
|
14c7e5db21 | ||
|
582a85df88 | ||
|
18ddc54626 | ||
|
6bad9a331d | ||
|
16b5747620 | ||
|
47015ec312 | ||
|
666c88bdf1 | ||
|
bd5262353b | ||
|
e1d5712b83 | ||
|
bcb9108424 | ||
|
82bb88ca34 | ||
|
518685f361 | ||
|
39e3d15fa8 | ||
|
7a755bbb3e | ||
|
41260df1a1 | ||
|
0d1b60158a | ||
|
b244df8f2d | ||
|
e48ca4fc8e | ||
|
82d52d1c9f | ||
|
e6a51d02fb | ||
|
28e2d9c94b | ||
|
60137feed0 | ||
|
a86c49e471 | ||
|
8c5d0bbb06 | ||
|
c26fbf8042 | ||
|
83e70d5e7a | ||
|
c383b8df9b | ||
|
fc810c3362 | ||
|
7e225c837a | ||
|
b053544512 | ||
|
9b4527d334 |
22
completions/gpoa
Normal file
22
completions/gpoa
Normal file
@@ -0,0 +1,22 @@
|
||||
_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
|
27
completions/gpupdate
Normal file
27
completions/gpupdate
Normal file
@@ -0,0 +1,27 @@
|
||||
_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
|
||||
|
18
completions/gpupdate-setup
Normal file
18
completions/gpupdate-setup
Normal file
@@ -0,0 +1,18 @@
|
||||
_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,6 +40,7 @@ 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())
|
||||
@@ -78,7 +79,9 @@ 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 = self.storage.get_key_value(self.__user_policy_mode_key)
|
||||
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
|
||||
if upm:
|
||||
upm = int(upm)
|
||||
if upm < 0 or upm > 2:
|
||||
@@ -173,10 +176,16 @@ 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)
|
||||
obj = gpt(gpt_abspath, sid, None, version=gpo_version)
|
||||
else:
|
||||
obj = gpt(gpt_abspath, sid, self.username)
|
||||
obj = gpt(gpt_abspath, sid, self.username, version=gpo_version)
|
||||
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
|
||||
|
||||
if flag and '0' == str(flag):
|
||||
flag = str(flag)
|
||||
if flag and '0' == 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' == str(flag):
|
||||
if '1' == flag:
|
||||
result = True
|
||||
else:
|
||||
result = False
|
||||
|
@@ -92,6 +92,8 @@ 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('\\', '/')
|
||||
folder_path = expand_windows_var(folder_object.path, username).replace('\\', '/').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
|
||||
from util.util import is_machine_name, try_dict_to_literal_eval
|
||||
|
||||
class firefox_applier(applier_frontend):
|
||||
__module_name = 'FirefoxApplier'
|
||||
@@ -83,6 +83,10 @@ 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)
|
||||
@@ -95,6 +99,8 @@ 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-2023 BaseALT Ltd.
|
||||
# Copyright (C) 2019-2024 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,10 +124,24 @@ 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'/etc/xdg/{file_name}'
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
file_path = f'{system_path_settings}{file_name}'
|
||||
with open(file_path, 'w') as file:
|
||||
for section, keys in sections.items():
|
||||
section = section.replace(')(', '][')
|
||||
@@ -275,4 +289,4 @@ def get_id_desktop(path_to_wallpaper):
|
||||
else:
|
||||
return None
|
||||
except:
|
||||
return None
|
||||
return None
|
||||
|
@@ -62,8 +62,7 @@ class package_applier(applier_frontend):
|
||||
)
|
||||
def run(self):
|
||||
for flag in self.sync_packages_setting:
|
||||
if flag.data:
|
||||
self.flagSync = bool(int(flag.data))
|
||||
self.flagSync = bool(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 = True
|
||||
__module_enabled = False
|
||||
__module_experimental = False
|
||||
__module_enabled = True
|
||||
__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 = True
|
||||
__module_enabled = False
|
||||
__module_experimental = False
|
||||
__module_enabled = True
|
||||
__deny_all_win = 'Software\\Policies\\Microsoft\\Windows\\RemovableStorageDevices\\Deny_All'
|
||||
__registry_branch = 'Software\\BaseALT\\Policies\\Polkit\\'
|
||||
__polkit_map = {
|
||||
|
@@ -153,12 +153,13 @@ def get_merger(preference_type):
|
||||
return mergers[preference_type]
|
||||
|
||||
class gpt:
|
||||
def __init__(self, gpt_path, sid, username='Machine'):
|
||||
def __init__(self, gpt_path, sid, username='Machine', version=None):
|
||||
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:
|
||||
@@ -216,7 +217,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)
|
||||
util.preg.merge_polfile(self.settings['machine']['regpol'], policy_name=self.name, version=self.version)
|
||||
# Merge machine preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['machine'].items():
|
||||
if preference_path:
|
||||
@@ -245,7 +246,8 @@ class gpt:
|
||||
util.preg.merge_polfile(self.settings['user']['regpol'],
|
||||
sid=self.sid,
|
||||
policy_name=self.name,
|
||||
username=self.username)
|
||||
username=self.username,
|
||||
version=self.version)
|
||||
# Merge user preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['user'].items():
|
||||
if preference_path:
|
||||
|
@@ -149,6 +149,7 @@ 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('%'):
|
||||
@@ -247,11 +248,10 @@ class shortcut:
|
||||
if dest:
|
||||
self.desktop_file = DesktopEntry(dest)
|
||||
else:
|
||||
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.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._update_desktop()
|
||||
|
||||
return self.desktop_file
|
||||
@@ -273,13 +273,18 @@ class shortcut:
|
||||
if self.type == TargetType.URL:
|
||||
self.desktop_file.set('URL', desktop_path)
|
||||
else:
|
||||
terminal_state = bool(self.desktop_file.get('Terminal'))
|
||||
self.desktop_file.set('Terminal', 'true' if terminal_state else 'false')
|
||||
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')
|
||||
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,7 +865,10 @@ msgid "No entry found for the specified path"
|
||||
msgstr "Не найдено записей по указанному пути"
|
||||
|
||||
msgid "Creating an ini file with policies for dconf"
|
||||
msgstr "Создание ini-фала с политиками для dconf"
|
||||
msgstr "Создание ini-файла с политиками для dconf"
|
||||
|
||||
msgid "GPO version was not found"
|
||||
msgstr "Версия GPO не найдена"
|
||||
|
||||
# Debug_end
|
||||
|
||||
|
@@ -320,6 +320,7 @@ 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,6 +21,8 @@ import subprocess
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import psutil
|
||||
import time
|
||||
|
||||
class Scripts_runner:
|
||||
'''
|
||||
@@ -104,12 +106,39 @@ class Scripts_runner:
|
||||
|
||||
def run_cmd_subprocess(self, cmd):
|
||||
try:
|
||||
subprocess.Popen(cmd)
|
||||
subprocess.run(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')
|
||||
@@ -117,6 +146,9 @@ 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,11 +22,10 @@ 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:
|
||||
if envprofile == 'local':
|
||||
Dconf_registry._local_envprofile = True
|
||||
elif envprofile == 'default':
|
||||
Dconf_registry._default_envprofile = True
|
||||
Dconf_registry._envprofile = envprofile
|
||||
|
||||
if registry_name == 'dconf':
|
||||
return Dconf_registry()
|
||||
|
@@ -58,8 +58,7 @@ class Dconf_registry():
|
||||
__dconf_dict_flag = False
|
||||
__dconf_dict = dict()
|
||||
_username = None
|
||||
_default_envprofile = None
|
||||
_local_envprofile = None
|
||||
_envprofile = None
|
||||
|
||||
list_keys = list()
|
||||
_info = dict()
|
||||
@@ -93,9 +92,7 @@ class Dconf_registry():
|
||||
if path[0] != '/':
|
||||
path = '/' + path
|
||||
logdata = dict()
|
||||
envprofile = get_dconf_envprofile(Dconf_registry._username,
|
||||
Dconf_registry._default_envprofile,
|
||||
Dconf_registry._local_envprofile)
|
||||
envprofile = get_dconf_envprofile()
|
||||
try:
|
||||
process = subprocess.Popen(['dconf', 'list', path],
|
||||
env=envprofile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
@@ -126,9 +123,7 @@ class Dconf_registry():
|
||||
@staticmethod
|
||||
def get_key_value(key):
|
||||
logdata = dict()
|
||||
envprofile = get_dconf_envprofile(Dconf_registry._username,
|
||||
Dconf_registry._default_envprofile,
|
||||
Dconf_registry._local_envprofile)
|
||||
envprofile = get_dconf_envprofile()
|
||||
try:
|
||||
process = subprocess.Popen(['dconf', 'read', key],
|
||||
env=envprofile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
@@ -451,7 +446,7 @@ def update_dict(dict1, dict2):
|
||||
dict1[key] = value
|
||||
|
||||
|
||||
def add_to_dict(string, policy_name, username):
|
||||
def add_to_dict(string, policy_name, username, version):
|
||||
if username is None:
|
||||
correct_path = '/'.join(string.split('/')[:-2])
|
||||
machine= '{}/Machine'.format(Dconf_registry._ReadQueue)
|
||||
@@ -461,40 +456,47 @@ def add_to_dict(string, policy_name, username):
|
||||
user = '{}/User'.format(Dconf_registry._ReadQueue)
|
||||
dictionary = Dconf_registry.global_registry_dict.setdefault(user, dict())
|
||||
|
||||
dictionary[len(dictionary)] = (policy_name, correct_path)
|
||||
dictionary[len(dictionary)] = (policy_name, correct_path, version)
|
||||
|
||||
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username):
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username, version=None):
|
||||
'''
|
||||
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)
|
||||
if i.valuename != i.data:
|
||||
data = check_data(i.data, i.type)
|
||||
if i.valuename != i.data and i.valuename:
|
||||
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('\\', '/'):i.data})
|
||||
dd_win_style[i.keyname].update({valuename:i.data})
|
||||
dd[i.keyname.replace('\\', '/')].update({valuename.replace('\\', '/'):data})
|
||||
else:
|
||||
# If the key does not exist in dd, create a new key-value pair
|
||||
dd[i.keyname.replace('\\', '/')] = {valuename.replace('\\', '/'):i.data}
|
||||
dd_win_style[i.keyname] = {valuename:i.data}
|
||||
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}
|
||||
|
||||
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(i.data)
|
||||
dd_target.setdefault(all_list_key[-1], []).append(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)
|
||||
add_to_dict(pathfile, policy_name, username, version)
|
||||
update_dict(Dconf_registry.global_registry_dict, dd)
|
||||
|
||||
|
||||
@@ -523,14 +525,36 @@ 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):
|
||||
# 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%')
|
||||
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)
|
||||
|
||||
return output_string
|
||||
|
||||
@@ -551,15 +575,17 @@ def flatten_dictionary(input_dict, result=None, current_key=''):
|
||||
|
||||
return result
|
||||
|
||||
def get_dconf_envprofile(user=None, default=None, local=None):
|
||||
if default:
|
||||
return {'DCONF_PROFILE': 'default'}
|
||||
def get_dconf_envprofile():
|
||||
dconf_envprofile = {'default': {'DCONF_PROFILE': 'default'},
|
||||
'local': {'DCONF_PROFILE': 'local'},
|
||||
'system': {'DCONF_PROFILE': 'system'}
|
||||
}
|
||||
|
||||
if local:
|
||||
return {'DCONF_PROFILE': 'local'}
|
||||
if Dconf_registry._envprofile:
|
||||
return dconf_envprofile.get(Dconf_registry._envprofile, dconf_envprofile['system'])
|
||||
|
||||
if not user:
|
||||
return {'DCONF_PROFILE': 'system'}
|
||||
if not Dconf_registry._username:
|
||||
return dconf_envprofile['system']
|
||||
|
||||
profile = '/run/dconf/user/{}'.format(get_uid_by_username(user))
|
||||
profile = '/run/dconf/user/{}'.format(get_uid_by_username(Dconf_registry._username))
|
||||
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'):
|
||||
def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None, policy_name='Unknown', username='Machine', version=None):
|
||||
pregfile = load_preg(preg)
|
||||
if sid is None and username == 'Machine':
|
||||
load_preg_dconf(pregfile, preg, policy_name, None)
|
||||
load_preg_dconf(pregfile, preg, policy_name, None, version)
|
||||
else:
|
||||
load_preg_dconf(pregfile, preg, policy_name, username)
|
||||
load_preg_dconf(pregfile, preg, policy_name, username, version)
|
||||
logdata = dict({'pregfile': preg})
|
||||
log('D32', logdata)
|
||||
#log dconf
|
||||
|
@@ -175,6 +175,16 @@ 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] +'/').replace('//','/')
|
||||
else variables[var] +'/')
|
||||
|
||||
return result
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
%add_python3_req_skip util.gpoa_ini_parsing
|
||||
|
||||
Name: gpupdate
|
||||
Version: 0.9.13.8
|
||||
Version: 0.10.3
|
||||
Release: alt1
|
||||
|
||||
Summary: GPT applier
|
||||
@@ -54,6 +54,7 @@ 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
|
||||
@@ -120,6 +121,9 @@ 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 \
|
||||
@@ -166,9 +170,12 @@ fi
|
||||
%_unitdir/%name.timer
|
||||
%_man1dir/gpoa.1.*
|
||||
%_man1dir/gpupdate.1.*
|
||||
/usr/lib/systemd/user/%name-user.service
|
||||
/usr/lib/systemd/user/%name-user.timer
|
||||
/usr/lib/systemd/user/%name-scripts-run-user.service
|
||||
%_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
|
||||
%dir %_sysconfdir/%name
|
||||
%_sysconfdir/control.d/facilities/*
|
||||
%config(noreplace) %_sysconfdir/%name/environment
|
||||
@@ -184,6 +191,29 @@ 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