mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-10-15 07:33:26 +03:00
Compare commits
70 Commits
fix_check_
...
fix_kde_ap
Author | SHA1 | Date | |
---|---|---|---|
1896664711 | |||
|
3960c4b094 | ||
|
5f178651f7 | ||
|
674e1d176b | ||
|
afe6ef04d4 | ||
|
fa98fef5a3 | ||
|
c6c34accff | ||
|
dba6a58c6a | ||
|
a02969c686 | ||
|
e040bbbd69 | ||
|
1775bfa08c | ||
|
165f4bfc83 | ||
|
316f5d1e49 | ||
|
150f3441fd | ||
|
769b520d47 | ||
|
517ed6d56b | ||
|
40635f9a01 | ||
|
2eb6e0c632 | ||
|
710b78b79f | ||
|
f308539a5a | ||
|
ca8cb9ce78 | ||
|
3c7d45cd52 | ||
|
6e77d54aa3 | ||
|
3c72786bd8 | ||
|
8a36e01fbb | ||
|
32cb959f0b | ||
|
3fb24dbd99 | ||
|
b737c9f0aa | ||
|
48d94ae046 | ||
|
4ed05cb481 | ||
|
cddc7d70fb | ||
|
64c305c544 | ||
|
4ee10c1560 | ||
|
5e5c5d45a6 | ||
|
56ee1334af | ||
|
de5ef65c16 | ||
|
453934621d | ||
|
2132c3676f | ||
|
e9adb9b298 | ||
|
3e3957d693 | ||
|
554147b57f | ||
|
6b632e851c | ||
|
3e99bfcb60 | ||
|
2c48b3a6a4 | ||
|
2e22d7abc9 | ||
|
e645fa4e86 | ||
|
cdcac9e4db | ||
|
d3a316c1c0 | ||
|
f081ec6454 | ||
|
60d6996db2 | ||
|
ea52e9671b | ||
|
92df692559 | ||
|
3b4f92997e | ||
|
98d02a4da0 | ||
|
eb951cbd5e | ||
|
9ce68f2acc | ||
|
54239c339c | ||
|
2b108e2029 | ||
|
2a21983b13 | ||
|
b6e84b3d9e | ||
|
bb314fb553 | ||
|
28718e8ad6 | ||
|
2857cfb899 | ||
8717e1b9a3 | |||
d3c9b95331 | |||
|
4d6a5d750c | ||
|
84e1340362 | ||
5ee05df574 | |||
|
2a993f0400 | ||
|
b878b7e1b3 |
@@ -13,7 +13,7 @@ _gpoa()
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W '--dc --nodomain --noupdate --noplugins --list-backends --loglevel --help' -- "$cur"))
|
||||
COMPREPLY=($(compgen -W '--dc --nodomain --noupdate --noplugins --list-backends --loglevel --help --force' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
@@ -17,7 +17,7 @@ _gpupdate()
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=($(compgen -W '--user --target --loglevel --system --help' -- "$cur"))
|
||||
COMPREPLY=($(compgen -W '--user --target --loglevel --system --help --force' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
@@ -45,6 +45,9 @@ Don't run plugins.
|
||||
.TP
|
||||
\fB--loglevel \fILOGLEVEL\fP
|
||||
Set logging verbosity from 0 to 5.
|
||||
.TP
|
||||
\fB--force\fP
|
||||
Force GPT download.
|
||||
.
|
||||
.SH FILES
|
||||
\fB/usr/sbin/gpoa\fR utility uses \fB/usr/share/local-policy/default\fR
|
||||
@@ -55,8 +58,10 @@ All data is located in \fB/var/cache/gpupdate\fR. Also domain GPTs are
|
||||
taken from Samba's \fB/var/cache/samba\fR.
|
||||
.
|
||||
The settings read from Samba are stored in
|
||||
\fB/var/cache/gpupdate/registry.sqlite\fR and "Local Policy" settings
|
||||
read from \fB/usr/local/share/local-policy/default\fR are converted
|
||||
Dconf. Machine policies are stored in the \fB/etc/dconf/db/policy.d/policy.ini\fR file,
|
||||
user policies are stored in the \fB/etc/dconf/db/policy<UID>.d/policy<UID>.ini\fR file
|
||||
(where UID is the user ID in the system)."Local Policy" settings
|
||||
read from \fB/usr/share/local-policy/\fR are converted
|
||||
into GPT and stored as \fB/var/cache/gpupdate/local-policy\fR.
|
||||
.SH "SEE ALSO"
|
||||
gpupdate(1)
|
||||
|
@@ -43,6 +43,9 @@ Show help.
|
||||
.TP
|
||||
\fB--user \fIusername\fR
|
||||
Run \fBgpupdate\fP for \fIusername\fP.
|
||||
.TP
|
||||
\fB--force\fP
|
||||
Force GPT download.
|
||||
.
|
||||
.SS "EXIT CODES"
|
||||
.TP
|
||||
|
@@ -23,8 +23,8 @@ from .nodomain_backend import nodomain_backend
|
||||
from util.logging import log
|
||||
from util.config import GPConfig
|
||||
from util.util import get_uid_by_username, touch_file
|
||||
from util.paths import get_dconf_config_path
|
||||
from storage.dconf_registry import Dconf_registry, create_dconf_ini_file
|
||||
from util.paths import get_dconf_config_file
|
||||
from storage.dconf_registry import Dconf_registry, create_dconf_ini_file, add_preferences_to_global_registry_dict
|
||||
|
||||
def backend_factory(dc, username, is_machine, no_domain = False):
|
||||
'''
|
||||
@@ -67,7 +67,8 @@ def save_dconf(username, is_machine):
|
||||
uid = None
|
||||
else:
|
||||
uid = get_uid_by_username(username) if not is_machine else None
|
||||
target_file = get_dconf_config_path(uid)
|
||||
target_file = get_dconf_config_file(uid)
|
||||
touch_file(target_file)
|
||||
Dconf_registry.apply_template(uid)
|
||||
create_dconf_ini_file(target_file,Dconf_registry.global_registry_dict)
|
||||
add_preferences_to_global_registry_dict(username, is_machine)
|
||||
create_dconf_ini_file(target_file,Dconf_registry.global_registry_dict, uid)
|
||||
|
@@ -26,6 +26,7 @@ except ImportError:
|
||||
from .applier_backend import applier_backend
|
||||
from storage import registry_factory
|
||||
from gpt.gpt import gpt, get_local_gpt
|
||||
from gpt.gpo_dconf_mapping import GpoInfoDconf
|
||||
from util.util import (
|
||||
get_machine_name,
|
||||
is_machine_name
|
||||
@@ -66,6 +67,9 @@ class samba_backend(applier_backend):
|
||||
self.sambacreds = sambacreds
|
||||
|
||||
self.cache_dir = self.sambacreds.get_cache_dir()
|
||||
self.gpo_cache_part ='gpo_cache'
|
||||
self._cached = False
|
||||
self.storage.set_info('cache_dir', os.path.join(self.cache_dir, self.gpo_cache_part))
|
||||
logdata = dict({'cachedir': self.cache_dir})
|
||||
log('D7', logdata)
|
||||
|
||||
@@ -154,10 +158,15 @@ class samba_backend(applier_backend):
|
||||
'''
|
||||
Check if there is SYSVOL path for GPO assigned
|
||||
'''
|
||||
self._cached = False
|
||||
if not gpo.file_sys_path:
|
||||
# GPO named "Local Policy" has no entry by its nature so
|
||||
# no reason to print warning.
|
||||
if 'Local Policy' != gpo.name:
|
||||
if gpo.display_name in self.storage._dict_gpo_name_version_cache.keys():
|
||||
gpo.file_sys_path = self.storage._dict_gpo_name_version_cache.get(gpo.display_name, {}).get('correct_path')
|
||||
self._cached = True
|
||||
return True
|
||||
elif 'Local Policy' != gpo.name:
|
||||
logdata = dict({'gponame': gpo.name})
|
||||
log('W4', logdata)
|
||||
return False
|
||||
@@ -172,20 +181,18 @@ class samba_backend(applier_backend):
|
||||
log('D46')
|
||||
for gpo in gpos:
|
||||
if self._check_sysvol_present(gpo):
|
||||
path = check_safe_path(gpo.file_sys_path).upper()
|
||||
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)
|
||||
if not self._cached:
|
||||
path = check_safe_path(gpo.file_sys_path).upper()
|
||||
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, self.gpo_cache_part, path)
|
||||
else:
|
||||
obj = gpt(gpt_abspath, sid, self.username, version=gpo_version)
|
||||
gpt_abspath = gpo.file_sys_path
|
||||
log('D211', {'sysvol_path': gpo.file_sys_path, 'gpo_name': gpo.display_name})
|
||||
if self._is_machine_username:
|
||||
obj = gpt(gpt_abspath, sid, None, GpoInfoDconf(gpo))
|
||||
else:
|
||||
obj = gpt(gpt_abspath, sid, self.username, GpoInfoDconf(gpo))
|
||||
obj.set_name(gpo.display_name)
|
||||
gpts.append(obj)
|
||||
else:
|
||||
|
@@ -49,7 +49,7 @@ def check_module_enabled(storage, module_name):
|
||||
|
||||
result = None
|
||||
flag = str(flag)
|
||||
if flag:
|
||||
if flag and flag!='None':
|
||||
if '1' == flag:
|
||||
result = True
|
||||
else:
|
||||
|
@@ -17,9 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import subprocess
|
||||
import threading
|
||||
import logging
|
||||
from util.logging import slogm, log
|
||||
from util.logging import log
|
||||
|
||||
def control_subst(preg_name):
|
||||
'''
|
||||
@@ -101,14 +99,14 @@ class control:
|
||||
if status == None:
|
||||
logdata = dict()
|
||||
logdata['control'] = self.control_name
|
||||
logdata['inpossible values'] = self.self.control_value
|
||||
logdata['inpossible values'] = self.control_value
|
||||
log('E42', logdata)
|
||||
return
|
||||
elif type(self.control_value) == str:
|
||||
if self.control_value not in self.possible_values:
|
||||
logdata = dict()
|
||||
logdata['control'] = self.control_name
|
||||
logdata['inpossible values'] = self.self.control_value
|
||||
logdata['inpossible values'] = self.control_value
|
||||
log('E59', logdata)
|
||||
return
|
||||
status = self.control_value
|
||||
|
@@ -17,18 +17,13 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from os.path import isfile
|
||||
from util.logging import slogm
|
||||
import logging
|
||||
|
||||
from gpt.envvars import (
|
||||
from util.arguments import (
|
||||
FileAction
|
||||
, action_letter2enum
|
||||
)
|
||||
from util.windows import expand_windows_var
|
||||
from util.util import (
|
||||
get_homedir,
|
||||
homedir_exists
|
||||
)
|
||||
from util.util import get_homedir
|
||||
|
||||
class Envvar:
|
||||
def __init__(self, envvars, username=''):
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from gpt.folders import (
|
||||
from util.arguments import (
|
||||
FileAction
|
||||
, action_letter2enum
|
||||
)
|
||||
|
@@ -20,7 +20,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from gpt.folders import (
|
||||
from util.arguments import (
|
||||
FileAction
|
||||
, action_letter2enum
|
||||
)
|
||||
|
@@ -18,10 +18,9 @@
|
||||
|
||||
import configparser
|
||||
import os
|
||||
import logging
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
from util.logging import slogm, log
|
||||
from util.logging import log
|
||||
|
||||
class system_gsetting:
|
||||
def __init__(self, schema, path, value, lock, helper_function=None):
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
|
||||
from gpt.folders import (
|
||||
from util.arguments import (
|
||||
FileAction
|
||||
, action_letter2enum
|
||||
)
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
import subprocess
|
||||
|
||||
from gpt.folders import (
|
||||
from util.arguments import (
|
||||
FileAction
|
||||
, action_letter2enum
|
||||
)
|
||||
|
@@ -122,6 +122,11 @@ class chromium_applier(applier_frontend):
|
||||
'ProxyServerMode',
|
||||
'ExtensionManifestV2Availability',
|
||||
'ExtensionUnpublishedAvailability',
|
||||
'CreateThemesSettings',
|
||||
'DevToolsGenAiSettings',
|
||||
'GenAILocalFoundationalModelSettings',
|
||||
'HelpMeWriteSettings',
|
||||
'TabOrganizerSettings',
|
||||
'BrowserSwitcherParsingMode',
|
||||
'CloudAPAuthEnabled',
|
||||
'AdsSettingForIntrusiveAdsSites',
|
||||
@@ -135,10 +140,14 @@ class chromium_applier(applier_frontend):
|
||||
'HeadlessMode',
|
||||
'IncognitoModeAvailability',
|
||||
'IntranetRedirectBehavior',
|
||||
'LensOverlaySettings',
|
||||
'MemorySaverModeSavings',
|
||||
'NetworkPredictionOptions',
|
||||
'ProfilePickerOnStartupAvailability',
|
||||
'ProfileReauthPrompt',
|
||||
'RelaunchNotification',
|
||||
'SafeSitesFilterBehavior',
|
||||
'ToolbarAvatarLabelSettings',
|
||||
'UserAgentReduction',
|
||||
'BatterySaverModeAvailability_recommended',
|
||||
'DownloadRestrictions_recommended',
|
||||
|
@@ -87,6 +87,9 @@ class firefox_applier(applier_frontend):
|
||||
if json_data:
|
||||
it_data.data = json_data
|
||||
it_data.type = 7
|
||||
else:
|
||||
if it_data.type == 1:
|
||||
it_data.data = clean_data_firefox(it_data.data)
|
||||
#Cases when it is necessary to create nested dictionaries
|
||||
if it_data.valuename != it_data.data:
|
||||
parts = self.get_parts(it_data.hive_key)
|
||||
@@ -180,3 +183,6 @@ def dict_item_to_list(dictionary:dict) -> dict:
|
||||
else:
|
||||
dict_item_to_list(dictionary[key])
|
||||
return dictionary
|
||||
|
||||
def clean_data_firefox(data):
|
||||
return data.replace("'", '\"')
|
||||
|
@@ -25,6 +25,7 @@ from gi.repository import (
|
||||
Gio
|
||||
, GLib
|
||||
)
|
||||
from storage.dconf_registry import Dconf_registry
|
||||
|
||||
from .applier_frontend import (
|
||||
applier_frontend
|
||||
@@ -137,10 +138,7 @@ class gsettings_applier(applier_frontend):
|
||||
log('E48')
|
||||
|
||||
# Update desktop configuration system backend
|
||||
try:
|
||||
proc = subprocess.run(args=['/usr/bin/dconf', "update"], capture_output=True, check=True)
|
||||
except Exception as exc:
|
||||
log('E49')
|
||||
Dconf_registry.dconf_update()
|
||||
|
||||
def apply(self):
|
||||
if self.__module_enabled:
|
||||
|
@@ -162,6 +162,7 @@ def apply(all_kde_settings, locks_dict, username = None):
|
||||
pass
|
||||
for section, keys in sections.items():
|
||||
for key, value in keys.items():
|
||||
value = str(value)
|
||||
lock = f"{file_name}.{section}.{key}"
|
||||
if lock in locks_dict and locks_dict[lock] == 1:
|
||||
command = [
|
||||
@@ -228,9 +229,9 @@ def apply_for_wallpaper(data, file_cache, username):
|
||||
try:
|
||||
try:
|
||||
file_cache.store(data)
|
||||
data = file_cache.get(data)
|
||||
data = str(ile_cache.get(data))
|
||||
except NotUNCPathError:
|
||||
data = data
|
||||
data = str(data)
|
||||
os.environ["XDG_DATA_DIRS"] = "/usr/share/kf5:"
|
||||
#Variable for system detection of directories before files with .colors extension
|
||||
os.environ["DISPLAY"] = ":0"
|
||||
|
@@ -95,7 +95,6 @@ class scripts_applier_user(applier_frontend):
|
||||
, self.__module_name
|
||||
, self.__module_experimental
|
||||
)
|
||||
self.filling_cache()
|
||||
|
||||
def cleaning_cache(self):
|
||||
log('D161')
|
||||
@@ -143,7 +142,9 @@ def install_script(storage_script_entry, script_dir, access_permissions):
|
||||
'''
|
||||
dir_cr = Path(script_dir)
|
||||
dir_cr.mkdir(parents=True, exist_ok=True)
|
||||
script_name = str(int(storage_script_entry.number)).zfill(5) + '_' + os.path.basename(storage_script_entry.path)
|
||||
if storage_script_entry.number is None:
|
||||
return
|
||||
script_name = str(storage_script_entry.number).zfill(5) + '_' + os.path.basename(storage_script_entry.path)
|
||||
script_file = os.path.join(script_dir, script_name)
|
||||
shutil.copyfile(storage_script_entry.path, script_file)
|
||||
|
||||
|
@@ -23,9 +23,8 @@ from .applier_frontend import (
|
||||
applier_frontend
|
||||
, check_enabled
|
||||
)
|
||||
from gpt.shortcuts import json2sc
|
||||
from util.windows import expand_windows_var
|
||||
from util.logging import slogm, log
|
||||
from util.logging import log
|
||||
from util.util import (
|
||||
get_homedir,
|
||||
homedir_exists
|
||||
|
@@ -27,6 +27,7 @@ from backend import backend_factory, save_dconf
|
||||
from frontend.frontend_manager import frontend_manager, determine_username
|
||||
from plugin import plugin_manager
|
||||
from messages import message_with_code
|
||||
from storage import Dconf_registry
|
||||
|
||||
from util.util import get_machine_name
|
||||
from util.users import (
|
||||
@@ -61,6 +62,9 @@ def parse_arguments():
|
||||
arguments.add_argument('--list-backends',
|
||||
action='store_true',
|
||||
help='Show list of available backends')
|
||||
arguments.add_argument('--force',
|
||||
action='store_true',
|
||||
help='Force GPT download')
|
||||
arguments.add_argument('--loglevel',
|
||||
type=int,
|
||||
default=4,
|
||||
@@ -120,6 +124,7 @@ class gpoa_controller:
|
||||
print('local')
|
||||
print('samba')
|
||||
return
|
||||
Dconf_registry._force = self.__args.force
|
||||
self.start_plugins()
|
||||
self.start_backend()
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
import json
|
||||
from base64 import b64decode
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
from util.xml import get_xml_root
|
||||
|
||||
def decrypt_pass(cpassword):
|
||||
@@ -93,7 +93,7 @@ def json2drive(json_str):
|
||||
|
||||
return drive_obj
|
||||
|
||||
class drivemap:
|
||||
class drivemap(DynamicAttributes):
|
||||
def __init__(self):
|
||||
self.login = None
|
||||
self.password = None
|
||||
|
45
gpoa/gpt/dynamic_attributes.py
Normal file
45
gpoa/gpt/dynamic_attributes.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# GPOA - GPO Applier for Linux
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
from enum import Enum
|
||||
|
||||
class DynamicAttributes:
|
||||
def __init__(self, **kwargs):
|
||||
self.policy_name = None
|
||||
for key, value in kwargs.items():
|
||||
self.__setattr__(key, value)
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
if isinstance(value, Enum):
|
||||
value = str(value)
|
||||
self.__dict__[key] = value
|
||||
|
||||
def items(self):
|
||||
return self.__dict__.items()
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.__dict__.items())
|
||||
|
||||
class RegistryKeyMetadata(DynamicAttributes):
|
||||
def __init__(self, policy_name, type, is_list=None):
|
||||
self.policy_name = policy_name
|
||||
self.type = type
|
||||
self.reloaded_with_policy_key = None
|
||||
self.is_list = is_list
|
||||
|
||||
def __repr__(self):
|
||||
return str(dict(self))
|
@@ -17,24 +17,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
from enum import Enum
|
||||
|
||||
class FileAction(Enum):
|
||||
CREATE = 'C'
|
||||
REPLACE = 'R'
|
||||
UPDATE = 'U'
|
||||
DELETE = 'D'
|
||||
|
||||
|
||||
def action_letter2enum(letter):
|
||||
if letter in ['C', 'R', 'U', 'D']:
|
||||
if letter == 'C': return FileAction.CREATE
|
||||
if letter == 'R': return FileAction.REPLACE
|
||||
if letter == 'U': return FileAction.UPDATE
|
||||
if letter == 'D': return FileAction.DELETE
|
||||
|
||||
return FileAction.CREATE
|
||||
|
||||
def read_envvars(envvars_file):
|
||||
variables = list()
|
||||
@@ -43,8 +27,8 @@ def read_envvars(envvars_file):
|
||||
props = var.find('Properties')
|
||||
name = props.get('name')
|
||||
value = props.get('value')
|
||||
var_obj = envvar(name, value)
|
||||
var_obj.set_action(action_letter2enum(props.get('action', default='C')))
|
||||
action = props.get('action', default='C')
|
||||
var_obj = envvar(name, value, action)
|
||||
|
||||
variables.append(var_obj)
|
||||
|
||||
@@ -54,12 +38,9 @@ def merge_envvars(storage, sid, envvar_objects, policy_name):
|
||||
for envv in envvar_objects:
|
||||
storage.add_envvar(sid, envv, policy_name)
|
||||
|
||||
class envvar:
|
||||
def __init__(self, name, value):
|
||||
class envvar(DynamicAttributes):
|
||||
def __init__(self, name, value, action):
|
||||
self.name = name
|
||||
self.value = value
|
||||
self.action = FileAction.CREATE
|
||||
|
||||
def set_action(self, action):
|
||||
self.action = action
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_files(filesxml):
|
||||
files = list()
|
||||
@@ -39,7 +40,7 @@ def merge_files(storage, sid, file_objects, policy_name):
|
||||
for fileobj in file_objects:
|
||||
storage.add_file(sid, fileobj, policy_name)
|
||||
|
||||
class fileentry:
|
||||
class fileentry(DynamicAttributes):
|
||||
def __init__(self, fromPath):
|
||||
self.fromPath = fromPath
|
||||
|
||||
|
@@ -18,27 +18,11 @@
|
||||
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
from util.xml import get_xml_root
|
||||
|
||||
|
||||
class FileAction(Enum):
|
||||
CREATE = 'C'
|
||||
REPLACE = 'R'
|
||||
UPDATE = 'U'
|
||||
DELETE = 'D'
|
||||
|
||||
|
||||
def action_letter2enum(letter):
|
||||
if letter in ['C', 'R', 'U', 'D']:
|
||||
if letter == 'C': return FileAction.CREATE
|
||||
if letter == 'R': return FileAction.REPLACE
|
||||
if letter == 'U': return FileAction.UPDATE
|
||||
if letter == 'D': return FileAction.DELETE
|
||||
|
||||
return FileAction.CREATE
|
||||
|
||||
|
||||
def action_enum2letter(enumitem):
|
||||
return enumitem.value
|
||||
@@ -61,8 +45,9 @@ def read_folders(folders_file):
|
||||
|
||||
for fld in get_xml_root(folders_file):
|
||||
props = fld.find('Properties')
|
||||
fld_obj = folderentry(props.get('path'))
|
||||
fld_obj.set_action(action_letter2enum(props.get('action', default='C')))
|
||||
path = props.get('path')
|
||||
action = props.get('action', default='C')
|
||||
fld_obj = folderentry(path, action)
|
||||
fld_obj.set_delete_folder(folder_int2bool(props.get('deleteFolder', default=1)))
|
||||
fld_obj.set_delete_sub_folders(folder_int2bool(props.get('deleteSubFolders', default=1)))
|
||||
fld_obj.set_delete_files(folder_int2bool(props.get('deleteFiles', default=1)))
|
||||
@@ -78,10 +63,10 @@ def merge_folders(storage, sid, folder_objects, policy_name):
|
||||
storage.add_folder(sid, folder, policy_name)
|
||||
|
||||
|
||||
class folderentry:
|
||||
def __init__(self, path):
|
||||
class folderentry(DynamicAttributes):
|
||||
def __init__(self, path, action):
|
||||
self.path = path
|
||||
self.action = FileAction.CREATE
|
||||
self.action = action
|
||||
self.delete_folder = False
|
||||
self.delete_sub_folders = False
|
||||
self.delete_files = False
|
||||
|
48
gpoa/gpt/gpo_dconf_mapping.py
Normal file
48
gpoa/gpt/gpo_dconf_mapping.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# GPOA - GPO Applier for Linux
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
class GpoInfoDconf(DynamicAttributes):
|
||||
_counter = 0
|
||||
def __init__(self, gpo) -> None:
|
||||
GpoInfoDconf._counter += 1
|
||||
self.counter = GpoInfoDconf._counter
|
||||
self.display_name = None
|
||||
self.name = None
|
||||
self.version = None
|
||||
self.link = None
|
||||
self._fill_attributes(gpo)
|
||||
|
||||
def _fill_attributes(self, gpo):
|
||||
try:
|
||||
self.display_name = gpo.display_name
|
||||
except:
|
||||
self.display_name = "Unknown"
|
||||
try:
|
||||
self.name = gpo.name
|
||||
except:
|
||||
self.name = "Unknown"
|
||||
try:
|
||||
self.version = gpo.version
|
||||
except:
|
||||
self.version = "Unknown"
|
||||
try:
|
||||
self.link = gpo.link
|
||||
except:
|
||||
self.link = "Unknown"
|
@@ -153,13 +153,13 @@ 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', gpo_info=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.gpo_info = gpo_info
|
||||
self.name = ''
|
||||
self.guid = self.path.rpartition('/')[2]
|
||||
if 'default' == self.guid:
|
||||
@@ -217,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, version=self.version)
|
||||
util.preg.merge_polfile(self.settings['machine']['regpol'], policy_name=self.name, gpo_info=self.gpo_info)
|
||||
# Merge machine preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['machine'].items():
|
||||
if preference_path:
|
||||
@@ -247,7 +247,7 @@ class gpt:
|
||||
sid=self.sid,
|
||||
policy_name=self.name,
|
||||
username=self.username,
|
||||
version=self.version)
|
||||
gpo_info=self.gpo_info)
|
||||
# Merge user preferences to registry if possible
|
||||
for preference_name, preference_path in self.settings['user'].items():
|
||||
if preference_path:
|
||||
|
@@ -17,6 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_inifiles(inifiles_file):
|
||||
inifiles = list()
|
||||
@@ -27,7 +28,7 @@ def read_inifiles(inifiles_file):
|
||||
ini_obj.set_section(prors.get('section', default=None))
|
||||
ini_obj.set_property(prors.get('property', default=None))
|
||||
ini_obj.set_value(prors.get('value', default=None))
|
||||
ini_obj.set_action(prors.get('action'))
|
||||
ini_obj.set_action(prors.get('action', default='C'))
|
||||
|
||||
inifiles.append(ini_obj)
|
||||
|
||||
@@ -37,7 +38,7 @@ def merge_inifiles(storage, sid, inifile_objects, policy_name):
|
||||
for iniobj in inifile_objects:
|
||||
storage.add_ini(sid, iniobj, policy_name)
|
||||
|
||||
class inifile:
|
||||
class inifile(DynamicAttributes):
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from util.xml import get_xml_root
|
||||
from storage.dconf_registry import Dconf_registry
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_networkshares(networksharesxml):
|
||||
networkshares = list()
|
||||
@@ -39,7 +39,7 @@ def merge_networkshares(storage, sid, networkshares_objects, policy_name):
|
||||
for networkshareobj in networkshares_objects:
|
||||
storage.add_networkshare(sid, networkshareobj, policy_name)
|
||||
|
||||
class networkshare:
|
||||
class networkshare(DynamicAttributes):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
from util.xml import get_xml_root
|
||||
|
||||
@@ -60,7 +61,7 @@ def json2printer(json_str):
|
||||
|
||||
return prn
|
||||
|
||||
class printer:
|
||||
class printer(DynamicAttributes):
|
||||
def __init__(self, ptype, name, status):
|
||||
'''
|
||||
ptype may be one of:
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
import configparser
|
||||
import os
|
||||
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_scripts(scripts_file):
|
||||
scripts = Scripts_lists()
|
||||
@@ -115,7 +115,7 @@ class Scripts_lists:
|
||||
self.get_shutdown_scripts().append(script)
|
||||
|
||||
|
||||
class Script:
|
||||
class Script(DynamicAttributes):
|
||||
__logon_counter = 0
|
||||
__logoff_counter = 0
|
||||
__startup_counter = 0
|
||||
@@ -126,6 +126,7 @@ class Script:
|
||||
self.action = action_upper
|
||||
self.path = os.path.join(script_dir, action_upper, script_filename.upper())
|
||||
if not os.path.isfile(self.path):
|
||||
self.number = None
|
||||
return None
|
||||
self.args = None
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from util.xml import get_xml_root
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
def read_services(service_file):
|
||||
'''
|
||||
@@ -43,7 +44,7 @@ def merge_services(storage, sid, service_objects, policy_name):
|
||||
for srv in service_objects:
|
||||
pass
|
||||
|
||||
class service:
|
||||
class service(DynamicAttributes):
|
||||
def __init__(self, name):
|
||||
self.unit = name
|
||||
self.servname = None
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
from pathlib import Path
|
||||
import stat
|
||||
import logging
|
||||
from enum import Enum
|
||||
|
||||
from xml.etree import ElementTree
|
||||
@@ -28,11 +27,15 @@ import json
|
||||
from util.windows import transform_windows_path
|
||||
from util.xml import get_xml_root
|
||||
from util.paths import get_desktop_files_directory
|
||||
from .dynamic_attributes import DynamicAttributes
|
||||
|
||||
class TargetType(Enum):
|
||||
FILESYSTEM = 'FILESYSTEM'
|
||||
URL = 'URL'
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def get_ttype(targetstr):
|
||||
'''
|
||||
Validation function for targetType property
|
||||
@@ -43,7 +46,7 @@ def get_ttype(targetstr):
|
||||
'''
|
||||
ttype = TargetType.FILESYSTEM
|
||||
|
||||
if targetstr == 'URL':
|
||||
if targetstr == 'URL'or targetstr == TargetType.URL:
|
||||
ttype = TargetType.URL
|
||||
|
||||
return ttype
|
||||
@@ -97,24 +100,6 @@ def merge_shortcuts(storage, sid, shortcut_objects, policy_name):
|
||||
for shortcut in shortcut_objects:
|
||||
storage.add_shortcut(sid, shortcut, policy_name)
|
||||
|
||||
def json2sc(json_str):
|
||||
'''
|
||||
Build shortcut out of string-serialized JSON
|
||||
'''
|
||||
json_obj = json.loads(json_str)
|
||||
link_type = get_ttype(json_obj['type'])
|
||||
|
||||
sc = shortcut(json_obj['dest'], json_obj['path'], json_obj['arguments'], json_obj['name'], json_obj['action'], link_type)
|
||||
sc.set_changed(json_obj['changed'])
|
||||
sc.set_clsid(json_obj['clsid'])
|
||||
sc.set_guid(json_obj['guid'])
|
||||
sc.set_usercontext(json_obj['is_in_user_context'])
|
||||
if 'comment' in json_obj:
|
||||
sc.set_comment(json_obj['comment'])
|
||||
if 'icon' in json_obj:
|
||||
sc.set_icon(json_obj['icon'])
|
||||
|
||||
return sc
|
||||
|
||||
def find_desktop_entry(binary_path):
|
||||
desktop_dir = get_desktop_files_directory()
|
||||
@@ -129,7 +114,7 @@ def find_desktop_entry(binary_path):
|
||||
return None
|
||||
|
||||
|
||||
class shortcut:
|
||||
class shortcut(DynamicAttributes):
|
||||
def __init__(self, dest, path, arguments, name=None, action=None, ttype=TargetType.FILESYSTEM):
|
||||
'''
|
||||
:param dest: Path to resulting file on file system
|
||||
@@ -217,30 +202,6 @@ class shortcut:
|
||||
def is_usercontext(self):
|
||||
return self.is_in_user_context
|
||||
|
||||
def to_json(self):
|
||||
'''
|
||||
Return shortcut's JSON for further serialization.
|
||||
'''
|
||||
content = dict()
|
||||
content['dest'] = self.dest
|
||||
content['path'] = self.path
|
||||
content['name'] = self.name
|
||||
content['arguments'] = self.arguments
|
||||
content['clsid'] = self.clsid
|
||||
content['guid'] = self.guid
|
||||
content['changed'] = self.changed
|
||||
content['action'] = self.action
|
||||
content['is_in_user_context'] = self.is_in_user_context
|
||||
content['type'] = ttype2str(self.type)
|
||||
if self.icon:
|
||||
content['icon'] = self.icon
|
||||
if self.comment:
|
||||
content['comment'] = self.comment
|
||||
result = self.desktop()
|
||||
result.content.update(content)
|
||||
|
||||
return json.dumps(result.content)
|
||||
|
||||
def desktop(self, dest=None):
|
||||
'''
|
||||
Returns desktop file object which may be written to disk.
|
||||
@@ -260,7 +221,7 @@ class shortcut:
|
||||
'''
|
||||
Update desktop file object from internal data.
|
||||
'''
|
||||
if self.type == TargetType.URL:
|
||||
if get_ttype(self.type) == TargetType.URL:
|
||||
self.desktop_file.set('Type', 'Link')
|
||||
else:
|
||||
self.desktop_file.set('Type', 'Application')
|
||||
@@ -270,7 +231,7 @@ class shortcut:
|
||||
desktop_path = self.path
|
||||
if self.expanded_path:
|
||||
desktop_path = self.expanded_path
|
||||
if self.type == TargetType.URL:
|
||||
if get_ttype(self.type) == TargetType.URL:
|
||||
self.desktop_file.set('URL', desktop_path)
|
||||
else:
|
||||
str2bool_lambda = (lambda boolstr: boolstr if isinstance(boolstr, bool)
|
||||
|
@@ -25,6 +25,7 @@ import os
|
||||
import sys
|
||||
import pwd
|
||||
import signal
|
||||
from storage import Dconf_registry
|
||||
|
||||
from util.users import (
|
||||
is_root
|
||||
@@ -83,6 +84,11 @@ def parse_cli_arguments():
|
||||
type=int,
|
||||
default=5,
|
||||
help='Set logging verbosity level')
|
||||
argparser.add_argument('-f',
|
||||
'--force',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Force GPT download')
|
||||
argparser.add_argument('-s',
|
||||
'--system',
|
||||
action='store_true',
|
||||
@@ -165,6 +171,7 @@ def main():
|
||||
gettext.bindtextdomain('gpoa', '/usr/lib/python3/site-packages/gpoa/locale')
|
||||
gettext.textdomain('gpoa')
|
||||
set_loglevel(args.loglevel)
|
||||
Dconf_registry._force = args.force
|
||||
gpo_appliers = runner_factory(args, process_target(args.target))
|
||||
|
||||
if gpo_appliers:
|
||||
|
@@ -65,6 +65,10 @@ msgstr "Установка свойств для пользователя"
|
||||
msgid "The line in the configuration file was cleared"
|
||||
msgstr "В конфигурационном файле была очищена строка"
|
||||
|
||||
msgid "Found GPT in cache"
|
||||
msgstr "Найден GPT в кеше"
|
||||
|
||||
|
||||
# Error
|
||||
msgid "Insufficient permissions to run gpupdate"
|
||||
msgstr "Недостаточно прав для запуска gpupdate"
|
||||
@@ -252,6 +256,9 @@ msgstr "Не удалось обновить базу данных dconf"
|
||||
msgid "Exception occurred while updating dconf database"
|
||||
msgstr "Возникло исключение при обновлении базы данных dconf"
|
||||
|
||||
msgid "Failed to retrieve data from dconf database"
|
||||
msgstr "Не удалось получить данные из базы dconf"
|
||||
|
||||
# Error_end
|
||||
|
||||
# Debug
|
||||
@@ -870,6 +877,9 @@ msgstr "Создание ini-файла с политиками для dconf"
|
||||
msgid "GPO version was not found"
|
||||
msgstr "Версия GPO не найдена"
|
||||
|
||||
msgid "SYSVOL entry found in cache"
|
||||
msgstr "Запись SYSVOL найдена в кеше"
|
||||
|
||||
# Debug_end
|
||||
|
||||
# Warning
|
||||
@@ -922,8 +932,8 @@ msgstr "Не удалось скопировать файл"
|
||||
msgid "Failed to create KDE settings list"
|
||||
msgstr "Не удалось создать список настроек KDE"
|
||||
|
||||
msgid "Could not find application tools"
|
||||
msgstr "Не удалось найти инструменты применения"
|
||||
msgid "Could not find tools to configure KDE"
|
||||
msgstr "Не удалось найти инструменты для настройки KDE"
|
||||
|
||||
msgid "Failed to open KDE settings"
|
||||
msgstr "Не удалось открыть настройки KDE"
|
||||
|
@@ -31,6 +31,7 @@ def info_code(code):
|
||||
info_ids[8] = 'Chromium policy'
|
||||
info_ids[9] = 'Set user property to'
|
||||
info_ids[10] = 'The line in the configuration file was cleared'
|
||||
info_ids[11] = 'Found GPT in cache'
|
||||
|
||||
return info_ids.get(code, 'Unknown info code')
|
||||
|
||||
@@ -107,6 +108,7 @@ def error_code(code):
|
||||
error_ids[70] = 'Error getting key value'
|
||||
error_ids[71] = 'Failed to update dconf database'
|
||||
error_ids[72] = 'Exception occurred while updating dconf database'
|
||||
error_ids[73] = 'Failed to retrieve data from dconf database'
|
||||
return error_ids.get(code, 'Unknown error code')
|
||||
|
||||
def debug_code(code):
|
||||
@@ -320,7 +322,8 @@ 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'
|
||||
debug_ids[211] = 'SYSVOL entry found in cache'
|
||||
#debug_ids[210] = 'GPO version was not found'
|
||||
|
||||
return debug_ids.get(code, 'Unknown debug code')
|
||||
|
||||
@@ -348,7 +351,7 @@ def warning_code(code):
|
||||
warning_ids[14] = 'Could not create a valid list of keys'
|
||||
warning_ids[15] = 'Failed to copy file'
|
||||
warning_ids[16] = 'Failed to create KDE settings list'
|
||||
warning_ids[17] = 'Could not find application tools'
|
||||
warning_ids[17] = 'Could not find tools to configure KDE'
|
||||
warning_ids[18] = 'Failed to open KDE settings'
|
||||
warning_ids[19] = 'Failed to change KDE configuration file'
|
||||
warning_ids[20] = 'Error connecting to server'
|
||||
|
@@ -20,15 +20,13 @@
|
||||
import rpm
|
||||
import subprocess
|
||||
from gpoa.storage import registry_factory
|
||||
from util.gpoa_ini_parsing import GpoaConfigObj
|
||||
from util.util import get_uid_by_username, string_to_literal_eval
|
||||
import logging
|
||||
from util.logging import log
|
||||
import argparse
|
||||
import gettext
|
||||
import locale
|
||||
from messages import message_with_code
|
||||
from util.arguments import (
|
||||
set_loglevel
|
||||
)
|
||||
|
||||
|
||||
def is_rpm_installed(rpm_name):
|
||||
@@ -45,28 +43,32 @@ def is_rpm_installed(rpm_name):
|
||||
class Pkcon_applier:
|
||||
|
||||
def __init__(self, user = None):
|
||||
self.__install_key_name = 'Install'
|
||||
self.__remove_key_name = 'Remove'
|
||||
self.__hklm_branch = '/Software/BaseALT/Policies/Packages'
|
||||
install_key_name = 'Install'
|
||||
remove_key_name = 'Remove'
|
||||
hklm_branch = 'Software/BaseALT/Policies/Packages'
|
||||
self.__install_command = ['/usr/bin/pkcon', '-y', 'install']
|
||||
self.__remove_command = ['/usr/bin/pkcon', '-y', 'remove']
|
||||
self.__reinstall_command = ['/usr/bin/pkcon', '-y', 'reinstall']
|
||||
self.install_packages = set()
|
||||
self.remove_packages = set()
|
||||
self.storage = registry_factory(username=user)
|
||||
self.storage.filling_storage_from_dconf()
|
||||
install_branch = '{}/{}'.format(self.__hklm_branch, self.__install_key_name)
|
||||
remove_branch = '{}/{}'.format(self.__hklm_branch, self.__remove_key_name)
|
||||
self.install_packages_setting = self.storage.filter_hklm_entries(install_branch)
|
||||
self.remove_packages_setting = self.storage.filter_hklm_entries(remove_branch)
|
||||
self.storage = registry_factory()
|
||||
if user:
|
||||
uid = get_uid_by_username(user)
|
||||
dict_dconf_db = self.storage.get_dictionary_from_dconf_file_db(uid)
|
||||
else:
|
||||
dict_dconf_db = self.storage.get_dictionary_from_dconf_file_db()
|
||||
dict_packages = dict_dconf_db.get(hklm_branch,{})
|
||||
self.install_packages_setting = string_to_literal_eval(dict_packages.get(install_key_name,[]))
|
||||
self.remove_packages_setting = string_to_literal_eval(dict_packages.get(remove_key_name,[]))
|
||||
|
||||
for package in self.install_packages_setting:
|
||||
if not is_rpm_installed(package.data):
|
||||
self.install_packages.add(package.data)
|
||||
if not is_rpm_installed(package):
|
||||
self.install_packages.add(package)
|
||||
for package in self.remove_packages_setting:
|
||||
if package.data in self.install_packages:
|
||||
self.install_packages.remove(package.data)
|
||||
if is_rpm_installed(package.data):
|
||||
self.remove_packages.add(package.data)
|
||||
if package in self.install_packages:
|
||||
self.install_packages.remove(package)
|
||||
if is_rpm_installed(package):
|
||||
self.remove_packages.add(package)
|
||||
|
||||
def apply(self):
|
||||
log('D142')
|
||||
|
@@ -19,8 +19,16 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from util.util import string_to_literal_eval, touch_file, get_uid_by_username
|
||||
from util.paths import get_dconf_config_path
|
||||
from util.logging import log
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
import itertools
|
||||
from gpt.dynamic_attributes import RegistryKeyMetadata
|
||||
import gi
|
||||
gi.require_version("Gvdb", "1.0")
|
||||
gi.require_version("GLib", "2.0")
|
||||
from gi.repository import Gvdb, GLib
|
||||
|
||||
|
||||
class PregDconf():
|
||||
@@ -49,19 +57,24 @@ class Dconf_registry():
|
||||
'''
|
||||
A class variable that represents a global registry dictionary shared among instances of the class
|
||||
'''
|
||||
_ReadQueue = 'Software/BaseALT/Policies/ReadQueue'
|
||||
global_registry_dict = dict({_ReadQueue:{}})
|
||||
_GpoPriority = 'Software/BaseALT/Policies/GpoPriority'
|
||||
global_registry_dict = dict({_GpoPriority:{}})
|
||||
__template_file = '/usr/share/dconf/user_mandatory.template'
|
||||
_policies_path = 'Software/'
|
||||
_policies_win_path = 'SOFTWARE/'
|
||||
_gpt_read_flag = False
|
||||
_force = False
|
||||
__dconf_dict_flag = False
|
||||
__dconf_dict = dict()
|
||||
_dict_gpo_name_version_cache = dict()
|
||||
_username = None
|
||||
_uid = None
|
||||
_envprofile = None
|
||||
_path_bin_system = "/etc/dconf/db/policy"
|
||||
|
||||
list_keys = list()
|
||||
_info = dict()
|
||||
_counter_gpt = itertools.count(0)
|
||||
|
||||
shortcuts = list()
|
||||
folders = list()
|
||||
@@ -86,6 +99,9 @@ class Dconf_registry():
|
||||
def get_info(cls, key):
|
||||
return cls._info.setdefault(key, None)
|
||||
|
||||
@staticmethod
|
||||
def get_next_number():
|
||||
return next(Dconf_registry._counter_gpt)
|
||||
|
||||
@staticmethod
|
||||
def get_matching_keys(path):
|
||||
@@ -140,10 +156,12 @@ class Dconf_registry():
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def dconf_update():
|
||||
def dconf_update(uid=None):
|
||||
logdata = dict()
|
||||
path_dconf_config = get_dconf_config_path(uid)
|
||||
db_file = path_dconf_config[:-3]
|
||||
try:
|
||||
process = subprocess.Popen(['dconf', 'update'],
|
||||
process = subprocess.Popen(['dconf', 'compile', db_file, path_dconf_config],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
output, error = process.communicate()
|
||||
|
||||
@@ -206,20 +224,55 @@ class Dconf_registry():
|
||||
dconf_dict = self.get_key_values(self.get_matching_keys(startswith))
|
||||
for key, value in dconf_dict.items():
|
||||
keys_tmp = key.split('/')
|
||||
update_dict(output_dict.setdefault('/'.join(keys_tmp[:-1])[1:], {}), {keys_tmp[-1]: value})
|
||||
update_dict(output_dict.setdefault('/'.join(keys_tmp[:-1])[1:], {}), {keys_tmp[-1]: str(value)})
|
||||
|
||||
log('D207')
|
||||
return output_dict
|
||||
|
||||
|
||||
@classmethod
|
||||
def filter_entries(cls, startswith):
|
||||
def get_dictionary_from_dconf_file_db(self, uid=None):
|
||||
logdata = dict()
|
||||
if not uid:
|
||||
path_bin = self._path_bin_system
|
||||
else:
|
||||
path_bin = self._path_bin_system + str(uid)
|
||||
output_dict = {}
|
||||
try:
|
||||
if (GLib.file_get_contents(path_bin)[0]):
|
||||
bytes1 = GLib.Bytes.new(GLib.file_get_contents(path_bin)[1])
|
||||
table = Gvdb.Table.new_from_bytes(bytes1, True)
|
||||
|
||||
name_list = Gvdb.Table.get_names(table)
|
||||
for name in name_list:
|
||||
value = Gvdb.Table.get_value(table, name)
|
||||
if not value:
|
||||
continue
|
||||
list_path = name.split('/')
|
||||
if value.is_of_type(GLib.VariantType('s')):
|
||||
part = output_dict.setdefault('/'.join(list_path[1:-1]), {})
|
||||
part[list_path[-1]] = value.get_string()
|
||||
elif value.is_of_type(GLib.VariantType('i')):
|
||||
part = output_dict.setdefault('/'.join(list_path[1:-1]), {})
|
||||
part[list_path[-1]] = value.get_int32()
|
||||
except Exception as exc:
|
||||
logdata['exc'] = exc
|
||||
logdata['path_bin'] = path_bin
|
||||
log('E73', logdata)
|
||||
|
||||
return output_dict
|
||||
|
||||
|
||||
@classmethod
|
||||
def filter_entries(cls, startswith, registry_dict = None):
|
||||
if not registry_dict:
|
||||
registry_dict = cls.global_registry_dict
|
||||
if startswith[-1] == '%':
|
||||
startswith = startswith[:-1]
|
||||
if startswith[-1] == '/' or startswith[-1] == '\\':
|
||||
startswith = startswith[:-1]
|
||||
return filter_dict_keys(startswith, flatten_dictionary(cls.global_registry_dict))
|
||||
return filter_dict_keys(startswith, flatten_dictionary(cls.global_registry_dict))
|
||||
return filter_dict_keys(startswith, flatten_dictionary(registry_dict))
|
||||
return filter_dict_keys(startswith, flatten_dictionary(registry_dict))
|
||||
|
||||
|
||||
@classmethod
|
||||
@@ -234,7 +287,7 @@ class Dconf_registry():
|
||||
elif isinstance(value, list):
|
||||
for data in value:
|
||||
list_entiers.append(PregDconf(
|
||||
keyname, convert_string_dconf(data), find_preg_type(data), data))
|
||||
keyname, data, find_preg_type(data), data))
|
||||
else:
|
||||
list_entiers.append(PregDconf(
|
||||
'/'.join(keyname.split('/')[:-1]), convert_string_dconf(keyname.split('/')[-1]), find_preg_type(value), value))
|
||||
@@ -300,46 +353,55 @@ class Dconf_registry():
|
||||
|
||||
@classmethod
|
||||
def add_shortcut(cls, sid, sc_obj, policy_name):
|
||||
sc_obj.policy_name = policy_name
|
||||
cls.shortcuts.append(sc_obj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_printer(cls, sid, pobj, policy_name):
|
||||
pobj.policy_name = policy_name
|
||||
cls.printers.append(pobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_drive(cls, sid, dobj, policy_name):
|
||||
dobj.policy_name = policy_name
|
||||
cls.drives.append(dobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_folder(cls, sid, fobj, policy_name):
|
||||
fobj.policy_name = policy_name
|
||||
cls.folders.append(fobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_envvar(self, sid, evobj, policy_name):
|
||||
evobj.policy_name = policy_name
|
||||
self.environmentvariables.append(evobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_script(cls, sid, scrobj, policy_name):
|
||||
scrobj.policy_name = policy_name
|
||||
cls.scripts.append(scrobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_file(cls, sid, fileobj, policy_name):
|
||||
fileobj.policy_name = policy_name
|
||||
cls.files.append(fileobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_ini(cls, sid, iniobj, policy_name):
|
||||
iniobj.policy_name = policy_name
|
||||
cls.inifiles.append(iniobj)
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_networkshare(cls, sid, networkshareobj, policy_name):
|
||||
networkshareobj.policy_name = policy_name
|
||||
cls.networkshares.append(networkshareobj)
|
||||
|
||||
|
||||
@@ -371,13 +433,13 @@ class Dconf_registry():
|
||||
def get_scripts(cls, sid, action):
|
||||
action_scripts = list()
|
||||
for part in cls.scripts:
|
||||
if action == 'LOGON':
|
||||
if action == 'LOGON' and part.action == 'LOGON':
|
||||
action_scripts.append(part)
|
||||
elif action == 'LOGOFF':
|
||||
elif action == 'LOGOFF' and part.action == 'LOGOFF':
|
||||
action_scripts.append(part)
|
||||
elif action == 'STARTUP':
|
||||
elif action == 'STARTUP' and part.action == 'STARTUP':
|
||||
action_scripts.append(part)
|
||||
elif action == 'SHUTDOWN':
|
||||
elif action == 'SHUTDOWN' and part.action == 'SHUTDOWN':
|
||||
action_scripts.append(part)
|
||||
return action_scripts
|
||||
|
||||
@@ -404,7 +466,7 @@ class Dconf_registry():
|
||||
|
||||
@classmethod
|
||||
def wipe_hklm(cls):
|
||||
cls.global_registry_dict = dict({cls._ReadQueue:{}})
|
||||
cls.global_registry_dict = dict({cls._GpoPriority:{}})
|
||||
|
||||
|
||||
def filter_dict_keys(starting_string, input_dict):
|
||||
@@ -425,7 +487,7 @@ def find_preg_type(argument):
|
||||
return 1
|
||||
|
||||
|
||||
def update_dict(dict1, dict2):
|
||||
def update_dict(dict1, dict2, save_key=None):
|
||||
'''
|
||||
Updates dict1 with the key-value pairs from dict2
|
||||
'''
|
||||
@@ -433,40 +495,64 @@ def update_dict(dict1, dict2):
|
||||
if key in dict1:
|
||||
# If both values are dictionaries, recursively call the update_dict function
|
||||
if isinstance(dict1[key], dict) and isinstance(value, dict):
|
||||
update_dict(dict1[key], value)
|
||||
save_key = key
|
||||
update_dict(dict1[key], value, save_key)
|
||||
# If the value in dict1 is a list, extend it with unique values from value
|
||||
elif isinstance(dict1[key], list):
|
||||
dict1[key].extend(set(value) - set(dict1[key]))
|
||||
else:
|
||||
# If the value in dict1 is not a dictionary or the value in dict2 is not a dictionary,
|
||||
# replace the value in dict1 with the value from dict2
|
||||
dict1[key] = value
|
||||
if save_key and save_key.startswith('Source'):
|
||||
value.reloaded_with_policy_key = [dict1[key].policy_name]
|
||||
if dict1[key].reloaded_with_policy_key:
|
||||
value.reloaded_with_policy_key += dict1[key].reloaded_with_policy_key
|
||||
dict1[key] = value
|
||||
else:
|
||||
dict1[key] = value
|
||||
else:
|
||||
# If the key does not exist in dict1, add the key-value pair from dict2 to dict1
|
||||
dict1[key] = value
|
||||
|
||||
|
||||
def add_to_dict(string, policy_name, username, version):
|
||||
def add_to_dict(string, policy_name, username, gpo_info):
|
||||
if gpo_info:
|
||||
counter = gpo_info.counter
|
||||
display_name = gpo_info.display_name
|
||||
name = gpo_info.name
|
||||
version = gpo_info.version
|
||||
else:
|
||||
counter = 0
|
||||
display_name = policy_name
|
||||
name = None
|
||||
version = None
|
||||
|
||||
if username is None:
|
||||
correct_path = '/'.join(string.split('/')[:-2])
|
||||
machine= '{}/Machine'.format(Dconf_registry._ReadQueue)
|
||||
machine= '{}/Machine/{}'.format(Dconf_registry._GpoPriority, counter)
|
||||
dictionary = Dconf_registry.global_registry_dict.setdefault(machine, dict())
|
||||
else:
|
||||
correct_path = '/'.join(string.split('/')[:-2])
|
||||
user = '{}/User'.format(Dconf_registry._ReadQueue)
|
||||
user = '{}/User/{}'.format(Dconf_registry._GpoPriority, counter)
|
||||
dictionary = Dconf_registry.global_registry_dict.setdefault(user, dict())
|
||||
|
||||
dictionary[len(dictionary)] = (policy_name, correct_path, version)
|
||||
dictionary['display_name'] = display_name
|
||||
dictionary['name'] = name
|
||||
dictionary['version'] = version
|
||||
dictionary['correct_path'] = correct_path
|
||||
|
||||
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username, version=None):
|
||||
|
||||
def load_preg_dconf(pregfile, pathfile, policy_name, username, gpo_info):
|
||||
'''
|
||||
Loads the configuration from preg registry into a dictionary
|
||||
'''
|
||||
# Prefix for storing key data
|
||||
source_pre = "Source"
|
||||
dd = dict()
|
||||
for i in pregfile.entries:
|
||||
# Skip this entry if the valuename starts with '**del'
|
||||
if i.valuename.startswith('**del'):
|
||||
if i.valuename.lower().startswith('**del'):
|
||||
continue
|
||||
valuename = convert_string_dconf(i.valuename)
|
||||
data = check_data(i.data, i.type)
|
||||
@@ -474,9 +560,11 @@ def load_preg_dconf(pregfile, pathfile, policy_name, username, version=None):
|
||||
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[f"{source_pre}/{i.keyname}".replace('\\', '/')].update({valuename.replace('\\', '/'):RegistryKeyMetadata(policy_name, i.type)})
|
||||
else:
|
||||
# If the key does not exist in dd, create a new key-value pair
|
||||
dd[i.keyname.replace('\\', '/')] = {valuename.replace('\\', '/'):data}
|
||||
dd[f"{source_pre}/{i.keyname}".replace('\\', '/')] = {valuename.replace('\\', '/'):RegistryKeyMetadata(policy_name, i.type)}
|
||||
|
||||
elif not i.valuename:
|
||||
keyname_tmp = i.keyname.replace('\\', '/').split('/')
|
||||
@@ -484,23 +572,28 @@ def load_preg_dconf(pregfile, pathfile, policy_name, username, version=None):
|
||||
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})
|
||||
dd[f"{source_pre}{keyname}"].update({keyname_tmp[-1]:RegistryKeyMetadata(policy_name, i.type)})
|
||||
else:
|
||||
# If the key does not exist in dd, create a new key-value pair
|
||||
dd[keyname] = {keyname_tmp[-1]:data}
|
||||
dd[f"{source_pre}{keyname}"] = {keyname_tmp[-1]:RegistryKeyMetadata(policy_name, i.type)}
|
||||
|
||||
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]),{})
|
||||
key_d ='/'.join(all_list_key[:-1])
|
||||
dd_target_source = dd.setdefault(f"Source/{key_d}",{})
|
||||
dd_target.setdefault(all_list_key[-1], []).append(data)
|
||||
dd_target_source.setdefault(all_list_key[-1], RegistryKeyMetadata(policy_name, i.type, True))
|
||||
|
||||
# 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, gpo_info)
|
||||
update_dict(Dconf_registry.global_registry_dict, dd)
|
||||
|
||||
|
||||
def create_dconf_ini_file(filename, data):
|
||||
def create_dconf_ini_file(filename, data, uid):
|
||||
'''
|
||||
Create an ini-file based on a dictionary of dictionaries.
|
||||
Args:
|
||||
@@ -523,7 +616,7 @@ def create_dconf_ini_file(filename, data):
|
||||
logdata = dict()
|
||||
logdata['path'] = filename
|
||||
log('D209', logdata)
|
||||
Dconf_registry.dconf_update()
|
||||
Dconf_registry.dconf_update(uid)
|
||||
|
||||
def clean_data(data):
|
||||
try:
|
||||
@@ -547,7 +640,8 @@ def convert_string_dconf(input_string):
|
||||
macros = {
|
||||
'#': '%sharp%',
|
||||
';': '%semicolon%',
|
||||
'//': '%doubleslash%'
|
||||
'//': '%doubleslash%',
|
||||
'/': '%oneslash%'
|
||||
}
|
||||
output_string = input_string
|
||||
for key, value in macros.items():
|
||||
@@ -589,3 +683,52 @@ def get_dconf_envprofile():
|
||||
|
||||
profile = '/run/dconf/user/{}'.format(get_uid_by_username(Dconf_registry._username))
|
||||
return {'DCONF_PROFILE': profile}
|
||||
|
||||
|
||||
def convert_elements_to_list_dicts(elements):
|
||||
return list(map(lambda x: dict(x), elements))
|
||||
|
||||
def remove_duplicate_dicts_in_list(list_dict):
|
||||
return convert_elements_to_list_dicts(list(OrderedDict((tuple(sorted(d.items())), d) for d in list_dict).values()))
|
||||
|
||||
def add_preferences_to_global_registry_dict(username, is_machine):
|
||||
if is_machine:
|
||||
prefix = 'Software/BaseALT/Policies/Preferences/Machine'
|
||||
else:
|
||||
prefix = f'Software/BaseALT/Policies/Preferences/{username}'
|
||||
|
||||
preferences_global = [('Shortcuts',remove_duplicate_dicts_in_list(Dconf_registry.shortcuts)),
|
||||
('Folders',remove_duplicate_dicts_in_list(Dconf_registry.folders)),
|
||||
('Files',remove_duplicate_dicts_in_list(Dconf_registry.files)),
|
||||
('Drives',remove_duplicate_dicts_in_list(Dconf_registry.drives)),
|
||||
('Scheduledtasks',remove_duplicate_dicts_in_list(Dconf_registry.scheduledtasks)),
|
||||
('Environmentvariables',remove_duplicate_dicts_in_list(Dconf_registry.environmentvariables)),
|
||||
('Inifiles',remove_duplicate_dicts_in_list(Dconf_registry.inifiles)),
|
||||
('Services',remove_duplicate_dicts_in_list(Dconf_registry.services)),
|
||||
('Printers',remove_duplicate_dicts_in_list(Dconf_registry.printers)),
|
||||
('Scripts',remove_duplicate_dicts_in_list(Dconf_registry.scripts)),
|
||||
('Networkshares',remove_duplicate_dicts_in_list(Dconf_registry.networkshares))]
|
||||
|
||||
preferences_global_dict = dict()
|
||||
preferences_global_dict[prefix] = dict()
|
||||
|
||||
for key, val in preferences_global:
|
||||
preferences_global_dict[prefix].update({key:clean_data(str(val))})
|
||||
|
||||
update_dict(Dconf_registry.global_registry_dict, preferences_global_dict)
|
||||
|
||||
def extract_display_name_version(data):
|
||||
policy_force = data.get('Software/BaseALT/Policies/GPUpdate', {}).get('Force', False)
|
||||
if Dconf_registry._force or policy_force:
|
||||
return {}
|
||||
result = {}
|
||||
tmp = {}
|
||||
if isinstance(data, dict):
|
||||
for key in data.keys():
|
||||
if key.startswith(Dconf_registry._GpoPriority+'/'):
|
||||
tmp[key] = data[key]
|
||||
for value in tmp.values():
|
||||
if isinstance(value, dict) and value.get('version', 'None')!='None' and value.get('display_name'):
|
||||
result[value['display_name']] = {'version': value['version'], 'correct_path': value['correct_path']}
|
||||
Dconf_registry._dict_gpo_name_version_cache = result
|
||||
return result
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
import logging
|
||||
import logging.handlers
|
||||
from enum import IntEnum
|
||||
from enum import IntEnum, Enum
|
||||
|
||||
from messages import message_with_code
|
||||
from .logging import slogm
|
||||
@@ -84,3 +84,20 @@ class ExitCodeUpdater(IntEnum):
|
||||
FAIL_GPUPDATE_USER_NOREPLY = 3
|
||||
EXIT_SIGINT = 130
|
||||
|
||||
class FileAction(Enum):
|
||||
CREATE = 'C'
|
||||
REPLACE = 'R'
|
||||
UPDATE = 'U'
|
||||
DELETE = 'D'
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
def action_letter2enum(letter):
|
||||
if letter in ['C', 'R', 'U', 'D']:
|
||||
if letter == 'C': return FileAction.CREATE
|
||||
if letter == 'R': return FileAction.REPLACE
|
||||
if letter == 'U': return FileAction.UPDATE
|
||||
if letter == 'D': return FileAction.DELETE
|
||||
|
||||
return FileAction.CREATE
|
||||
|
@@ -20,6 +20,7 @@ import dbus
|
||||
|
||||
from .logging import log
|
||||
from .users import is_root
|
||||
from storage import Dconf_registry
|
||||
|
||||
|
||||
class dbus_runner:
|
||||
@@ -72,6 +73,7 @@ class dbus_runner:
|
||||
if self.username:
|
||||
logdata = dict({'username': self.username})
|
||||
log('D6', logdata)
|
||||
gpupdate = 'gpupdate' if not Dconf_registry._force else 'gpupdate_force'
|
||||
if is_root():
|
||||
# oddjobd-gpupdate's ACL allows access to this method
|
||||
# only for superuser. This method is called via PAM
|
||||
@@ -95,7 +97,7 @@ class dbus_runner:
|
||||
result = self.system_bus.call_blocking(self.bus_name,
|
||||
self._object_path,
|
||||
self.interface_name,
|
||||
'gpupdate',
|
||||
gpupdate,
|
||||
None,
|
||||
[],
|
||||
timeout=self._synchronous_timeout)
|
||||
@@ -106,11 +108,12 @@ class dbus_runner:
|
||||
raise exc
|
||||
else:
|
||||
log('D11')
|
||||
gpupdate_computer = 'gpupdate_computer' if not Dconf_registry._force else 'gpupdate_computer_force'
|
||||
try:
|
||||
result = self.system_bus.call_blocking(self.bus_name,
|
||||
self._object_path,
|
||||
self.interface_name,
|
||||
'gpupdate_computer',
|
||||
gpupdate_computer,
|
||||
None,
|
||||
# The following positional parameter is called "args".
|
||||
# There is no official documentation for it.
|
||||
@@ -118,7 +121,6 @@ class dbus_runner:
|
||||
timeout=self._synchronous_timeout)
|
||||
print_dbus_result(result)
|
||||
except dbus.exceptions.DBusException as exc:
|
||||
print(exc)
|
||||
logdata = dict({'error': str(exc)})
|
||||
log('E22', logdata)
|
||||
raise exc
|
||||
|
@@ -94,6 +94,12 @@ def local_policy_cache():
|
||||
return lpcache
|
||||
|
||||
def get_dconf_config_path(uid = None):
|
||||
if uid:
|
||||
return f'/etc/dconf/db/policy{uid}.d/'
|
||||
else:
|
||||
return '/etc/dconf/db/policy.d/'
|
||||
|
||||
def get_dconf_config_file(uid = None):
|
||||
if uid:
|
||||
return f'/etc/dconf/db/policy{uid}.d/policy{uid}.ini'
|
||||
else:
|
||||
|
@@ -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', gpo_info=None):
|
||||
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, gpo_info)
|
||||
else:
|
||||
load_preg_dconf(pregfile, preg, policy_name, username, version)
|
||||
load_preg_dconf(pregfile, preg, policy_name, username, gpo_info)
|
||||
logdata = dict({'pregfile': preg})
|
||||
log('D32', logdata)
|
||||
#log dconf
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from samba import getopt as options
|
||||
from samba import NTSTATUSError
|
||||
|
||||
@@ -28,12 +28,13 @@ except ImportError:
|
||||
from samba.gp.gpclass import get_dc_hostname, check_refresh_gpo_list
|
||||
|
||||
from samba.netcmd.common import netcmd_get_domain_infos_via_cldap
|
||||
from storage.dconf_registry import Dconf_registry, extract_display_name_version
|
||||
import samba.gpo
|
||||
|
||||
from .xdg import (
|
||||
xdg_get_desktop
|
||||
)
|
||||
from .util import get_homedir
|
||||
from .util import get_homedir, get_uid_by_username
|
||||
from .exceptions import GetGPOListFail
|
||||
from .logging import log
|
||||
from .samba import smbopts
|
||||
@@ -109,7 +110,11 @@ class smbcreds (smbopts):
|
||||
hostname
|
||||
'''
|
||||
gpos = list()
|
||||
|
||||
if Dconf_registry.get_info('machine_name') == username:
|
||||
dconf_dict = Dconf_registry.get_dictionary_from_dconf_file_db()
|
||||
else:
|
||||
dconf_dict = Dconf_registry.get_dictionary_from_dconf_file_db(get_uid_by_username(username))
|
||||
dict_gpo_name_version = extract_display_name_version(dconf_dict)
|
||||
try:
|
||||
log('D48')
|
||||
ads = samba.gpo.ADS_STRUCT(self.selected_dc, self.lp, self.creds)
|
||||
@@ -121,6 +126,12 @@ class smbcreds (smbopts):
|
||||
for gpo in gpos:
|
||||
# These setters are taken from libgpo/pygpo.c
|
||||
# print(gpo.ds_path) # LDAP entry
|
||||
if gpo.display_name in dict_gpo_name_version.keys() and dict_gpo_name_version.get(gpo.display_name, {}).get('version') == gpo.version:
|
||||
if Path(dict_gpo_name_version.get(gpo.display_name, {}).get('correct_path')).exists():
|
||||
gpo.file_sys_path = ''
|
||||
ldata = dict({'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path_cache': True})
|
||||
log('I11', ldata)
|
||||
continue
|
||||
ldata = dict({'gpo_name': gpo.display_name, 'gpo_uuid': gpo.name, 'file_sys_path': gpo.file_sys_path})
|
||||
log('I2', ldata)
|
||||
|
||||
|
@@ -8,6 +8,8 @@
|
||||
%add_python3_req_skip gpt.gpt
|
||||
%add_python3_req_skip gpt.printers
|
||||
%add_python3_req_skip gpt.shortcuts
|
||||
%add_python3_req_skip gpt.gpo_dconf_mapping
|
||||
%add_python3_req_skip gpt.dynamic_attributes
|
||||
%add_python3_req_skip messages
|
||||
%add_python3_req_skip storage
|
||||
%add_python3_req_skip storage.fs_file_cache
|
||||
@@ -33,7 +35,7 @@
|
||||
%add_python3_req_skip util.gpoa_ini_parsing
|
||||
|
||||
Name: gpupdate
|
||||
Version: 0.10.3
|
||||
Version: 0.11.1
|
||||
Release: alt1
|
||||
|
||||
Summary: GPT applier
|
||||
@@ -49,12 +51,13 @@ BuildRequires: gettext-tools
|
||||
Requires: python3-module-rpm
|
||||
Requires: python3-module-dbus
|
||||
Requires: python3-module-configobj
|
||||
Requires: oddjob-%name >= 0.2.0
|
||||
Requires: oddjob-%name >= 0.2.3
|
||||
Requires: libnss-role >= 0.5.0
|
||||
Requires: local-policy >= 0.4.9
|
||||
Requires: pam-config >= 1.9.0
|
||||
Requires: autofs
|
||||
Requires: dconf-profile
|
||||
Requires: libgvdb-gir
|
||||
# This is needed by shortcuts_applier
|
||||
Requires: desktop-file-utils
|
||||
# This is needed for smb file cache support
|
||||
@@ -191,6 +194,32 @@ fi
|
||||
%exclude %python3_sitelibdir/gpoa/test
|
||||
|
||||
%changelog
|
||||
* Tue Aug 27 2024 Valery Sinelnikov <greh@altlinux.org> 0.11.1-alt1
|
||||
- Fixed setting links in shortcuts (closes: 51275)
|
||||
|
||||
* Fri Aug 09 2024 Valery Sinelnikov <greh@altlinux.org> 0.11.0-alt1
|
||||
- Added saving preferences in dconf
|
||||
- Added versioning support for gpt
|
||||
- Added the ability to force gpt download
|
||||
- Added completions for --force
|
||||
- Added new exceptions for Chromium 126
|
||||
- Added information to the man pages
|
||||
- Fixed handling of incorrect valuename
|
||||
|
||||
* Mon Jul 08 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.6-alt1
|
||||
- Fixed firefox_applier errors
|
||||
|
||||
* Fri Jun 28 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.5-alt1
|
||||
- Correction of missing entries with a upper case
|
||||
- Fixed string processing in date (closes: 50782)
|
||||
- Fixed getting correct data for the user for pkcon_runner
|
||||
|
||||
* Thu Jun 27 2024 Valery Sinelnikov <greh@altlinux.org> 0.10.4-alt1
|
||||
- Fixed the definition of the module activation check (closes: 50755)
|
||||
- Fixed sorting of scripts (closes: 50756)
|
||||
- Fixed reading key values from dconf
|
||||
- Changed the method for getting the list of packages for pkcon_runner
|
||||
|
||||
* 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
|
||||
|
Reference in New Issue
Block a user