1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-10-18 19:33:32 +03:00

Compare commits

..

144 Commits

Author SHA1 Message Date
527c4f8172 Fixed the definition of the module activation check
Reported-by: Sergey Sysoev <sysoevsa@surgut.gazprom.ru>
2024-06-27 14:08:27 +04:00
Valery Sinelnikov
c57d1bac9e 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)
2024-06-19 14:45:49 +04:00
b9b5239448 Changed macro processing method 2024-06-19 14:37:40 +04:00
aae2776790 Added dictionary with macros 2024-06-19 13:59:13 +04:00
Valery Sinelnikov
a20aa841d6 Add functions to find and wait for a Python process by script path 2024-06-19 13:57:53 +04:00
Valentin Sokolov
8c7819d96f Update autocompletion for gpupdate-setup 2024-06-13 16:54:24 +04:00
Valentin Sokolov
3d9473f979 Update autocompletion for gpoa and gpupdate 2024-06-13 16:52:34 +04:00
Valentin Sokolov
01f48be853 Update gpupdate.spec 2024-06-13 16:17:02 +04:00
Valentin Sokolov
1638098fd4 Added autocompletion for gpupdate-setup 2024-06-13 16:16:56 +04:00
Valentin Sokolov
047e5459af Added autocompletion for gpupdate 2024-06-13 16:16:37 +04:00
Valentin Sokolov
5baa4245e3 Added autocompletion for gpoa 2024-06-13 16:16:30 +04:00
ec6b9f7887 Changing the date in the license 2024-06-13 16:13:00 +04:00
22d0d23b89 Added functionality for clearing unconnected settings 2024-06-13 16:12:53 +04:00
fd3a32e8e1 Removing the old system settings cleanup 2024-06-13 16:12:37 +04:00
Valery Sinelnikov
9e849e8fe3 Added use try_dict_to_literal_eval 2024-06-13 16:09:02 +04:00
Valery Sinelnikov
d65f3ed942 Added forgotten return 2024-06-13 16:07:53 +04:00
Valery Sinelnikov
31298be840 Added new function try_dict_to_literal_eval 2024-06-13 16:06:27 +04:00
Valery Sinelnikov
5c889fd57e Added saving to dconf of type REG_MULTI_SZ 2024-06-11 16:02:17 +04:00
Valery Sinelnikov
4e2874c972 Fixed reading flagSync 2024-06-11 15:44:18 +04:00
Valery Sinelnikov
63e50ac2df Polkit_applier enabled by default 2024-06-11 15:42:29 +04:00
Valery Sinelnikov
ad2a87e20d 0.10.2-alt1
- Added some fixes to dconf_registry and scripts
- Fixed windows registry key reading for loopback
2024-06-07 14:59:14 +04:00
Valery Sinelnikov
e9c3a4262a Fixed windows registry key reading for loopback 2024-06-07 14:54:25 +04:00
Valery Sinelnikov
b5706ec6e1 Added support for the newline symbol in the environment file 2024-06-06 18:14:35 +04:00
Valery Sinelnikov
61e7350429 Replaced Popen with run for command execution 2024-06-06 16:39:39 +04:00
Valery Sinelnikov
c9a274fc79 Reducing typical data to two types 2024-06-06 16:33:01 +04:00
Valery Sinelnikov
127c9f7183 0.10.1-alt1
- Added handling of unexpected data types when writing to dconf
2024-06-04 17:45:48 +04:00
Valery Sinelnikov
a27f8ba5dd Added handling of unexpected data types 2024-06-04 17:40:23 +04:00
Valery Sinelnikov
fafe2c34b4 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
2024-05-13 18:36:07 +04:00
Valery Sinelnikov
9c91ddc7ba Added processing the absence of GPO version 2024-05-13 18:34:12 +04:00
Valery Sinelnikov
1f02ed650b Added corrections of shortcuts 2024-05-07 13:51:03 +04:00
Valery Sinelnikov
fc47df4649 Added saving version 2024-04-26 10:30:58 +04:00
Valery Sinelnikov
42b8bdb82a Added usage version 2024-04-26 10:29:58 +04:00
Valery Sinelnikov
2a174edeef Added version argument 2024-04-26 10:29:02 +04:00
Valery Sinelnikov
9b8529b39b Fixed creation of shortcut attributes 2024-04-25 15:15:35 +04:00
Valery Sinelnikov
062ff742c3 Typo fixed 2024-04-24 13:19:27 +04:00
Valery Sinelnikov
1764560c49 Fixed the templates for a new registry 2024-04-10 17:10:20 +04:00
Valery Sinelnikov
b439e04a2f Corrected the interpretation of the terminal attribute for shortcuts 2024-04-09 18:20:35 +04:00
Valery Sinelnikov
e413f95633 Improved processing of registry keys 2024-04-05 16:40:31 +04:00
Valery Sinelnikov
675f37ab85 The incapable dictionary is removed 2024-04-04 16:01:34 +04:00
Valery Sinelnikov
9932c682ef Simplifying dconf profile selection 2024-03-15 13:31:41 +04:00
Valery Sinelnikov
018b30cdc4 Cleaning up code and removing unnecessary parts 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
249eb69ade Changed package_applier_user launch keys 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
1ab8c7aee0 Adapted check_enable_home_link to work with the new storage 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
400a5fab7d Typo corrected 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
e7851e88b3 Added use of profile forwarding in registry_factory 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0761637666 Corrected variable name 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
dda4d987cb Added the ability to store envprofile status 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
609ec0e8b8 Improve code readability 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
c0b28a0655 In dconf_registry init was removed, the action performed in it was transferred to gpt 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
78aad11e06 Improved get_key_value and get_dconf_envprofile 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
59bebbc45e Added function to get profile for dconf 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
e92656add0 Adaptation to the new storage for pkcon_runner 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
5d24579d2f Added use of username when get storage 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
ce284b61be Added class field to store username 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
7a8118ac63 Added the ability to save username when get storage 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
18d8e73acd Unnecessary line removed 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
58235cb1a1 Fix check_enabled in package_applier 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
e0d88cc076 Adapted to work with the new storage 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
c8b0927090 Adding forwarding policy_name and username to load_preg_dconf 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
a4a79d8c99 Adding policy name to ReadQueue key values 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
408609fa58 Using a new argument when creating a gpt object 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
6efebfad89 Added username argument to gpt class constructor 2024-03-14 10:40:30 +04:00
12865b0b43 Correcting logs in class methods 2024-03-14 10:40:30 +04:00
9117dddcee Changing the log in the create_dconf_ini_file method 2024-03-14 10:40:30 +04:00
1e267f5cb6 Removing an empty key in a dictionary 2024-03-14 10:40:30 +04:00
62ed015ea9 Added logs for the create_dconf_ini_file 2024-03-14 10:40:30 +04:00
3e6b7cd040 Added logs for the get_entry 2024-03-14 10:40:30 +04:00
209eb84d6d Added logs for the get_dictionary_from_dconf 2024-03-14 10:40:30 +04:00
7f3b47a23c Added logs for the apply_template 2024-03-14 10:40:30 +04:00
08ba87c8d8 log correction 2024-03-14 10:40:30 +04:00
f2a45a2a6d Added logs for the dconf_update 2024-03-14 10:40:30 +04:00
9c544adc94 Added logs for the get_key_value method 2024-03-14 10:40:30 +04:00
a225c9aa7f Added logs for the get_matching_keys method 2024-03-14 10:40:30 +04:00
51c8711da6 Updated get_key_values ​​method 2024-03-14 10:40:30 +04:00
54eb4188a7 Fixed error message and added logging module 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
89d5e36d6c Added extension with unique values 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
6cd5ab4ee2 Removed duplicate additions of objects 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0c913c68e3 Added search for a suitable .desktop file
and creation of a policy based on it
2024-03-14 10:40:30 +04:00
Valery Sinelnikov
12d746a1dc Added get_desktop_files_directory for .desktop path 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0a25f3a1d6 Changed work with object_shortcut 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
1eaab893c8 Changed queries to the registry from systemd_applier 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
05ea872831 Fixed registry queries 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
d0506dba29 Changed interpretation method from new repository 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
dd28587b20 Added local path processing 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
1a288c84f5 Added check for empty value 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
cadc3eda52 Added processing of the key list request 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
8d3e6691d4 Added the ability to return registry keys with a list item value 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
cb54fa5d78 Changes in requests to get a list of packages 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
53ffc072f0 Added the ability to get a class 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
7a59bcb65b Added fun for correct processing of branch requests 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
b81a727cd4 Added class method to get the key 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
11b33dd148 Changed request method for ScrollSysvolDC 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
1ccc18a31f Changed request method for UserPolicyMode 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
9a3afeebdf Request method changed 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0720471cca Fixed adding a list of scripts 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
dd43ddaad6 Typos corrected 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
6fc059aaac Processing module status changed 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
8cfb6f0bb3 Removed unnecessary arguments 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
ddcdc322f8 Moved save_dconf 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
4ee52f06d6 Added gpt status flags 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
603efc2deb Removed obsolete implementation 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
9fc5007590 Added registry saving to dconf in the backend 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
a6210f8b29 Removed obsolete implementation 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
175f244a5f Removed excess supply merge_polfile 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0d4ce533bc Added flag for data status 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
8e22235df2 Adaptation of gsettings for new storage 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
0519d2703c Added handling of empty data 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
1ca9b006e1 Using the dconf registry 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
8cc5a8904b Added processing of various requests 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
70cdef2e71 Changed key request gsettings 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
3baffeb12d Changes to the data source in the registry 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
a0d9dc585f Removed erroneous addition of objects 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
388125415b Fixed directory functionality 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
14c7e5db21 Bugs fixed and return data wrapper added 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
582a85df88 Added explicit conversion to string 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
18ddc54626 Added processing of different types of keys 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
6bad9a331d Added the ability to query the Group Policy dictionary 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
16b5747620 Added checking the fullness of the global registry key dictionary 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
47015ec312 Added the ability to query a dictionary across multiple dconf paths 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
666c88bdf1 Added class method for getting dconf keys 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
bd5262353b Added semicolon handling when writing dconf 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
e1d5712b83 Added the ability to call methods through a class 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
bcb9108424 Refactor object initialization in init 2024-03-14 10:40:30 +04:00
Valery Sinelnikov
82bb88ca34 Added saving the preference to dconf 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
518685f361 Added to gpupdate.spec req_skip storage.dconf_registry 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
39e3d15fa8 Fixed formation of the general list of scripts 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
7a755bbb3e Added old storage functionality 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
41260df1a1 Added support for sqlite_registry API 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
0d1b60158a Added functions for verification and request in the dictionary 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
b244df8f2d Changed storage int 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
e48ca4fc8e Added staticmethod for update dconf 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
82d52d1c9f Added methods for mandatory_profile creation 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
e6a51d02fb Added functions get_uid_by_username 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
28e2d9c94b Added new fields to store preference 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
60137feed0 Added static methods to query dconf 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
a86c49e471 Added to the global_dict key ReadQueue and to able fill it 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
8c5d0bbb06 Use load_preg_dconf in merge_polfile 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
c26fbf8042 create_dconf_ini_file function moved 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
83e70d5e7a Added functions for filling the dictionary 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
c383b8df9b Added class to storing registry data for dconf 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
fc810c3362 Add create_ini_file function 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
7e225c837a Add touch_file function 2024-03-14 10:40:29 +04:00
Valery Sinelnikov
b053544512 0.9.13.9-alt1
- Fixed premature removal of double slash
2024-03-13 16:14:31 +04:00
Valery Sinelnikov
9b4527d334 Fixed premature removal of double slash 2024-03-13 16:13:26 +04:00
24 changed files with 287 additions and 82 deletions

22
completions/gpoa Normal file
View 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
View 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

View 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

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:])

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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 = {

View File

@@ -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:

View File

@@ -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):
'''

View File

@@ -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

View File

@@ -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')

View File

@@ -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)

View File

@@ -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()

View File

@@ -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}

View File

@@ -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" ||

View File

@@ -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" ||

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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