mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-08-26 13:50:22 +03:00
Compare commits
40 Commits
0.4.4-alt1
...
binary_mod
Author | SHA1 | Date | |
---|---|---|---|
8292aa69b3
|
|||
aa03e6dfa4
|
|||
0328afa788 | |||
edead53d7e
|
|||
db1a82f930
|
|||
fd7cfe2b83
|
|||
b3694a8b4d
|
|||
060f125258
|
|||
1f4960cb48
|
|||
a0c5b1a2b1 | |||
2f7e6f3a98 | |||
393529f0af | |||
ccf73c4fc6 | |||
a7aa12d42d | |||
d12d4c4227 | |||
e8833ddee0
|
|||
18e1911bb5
|
|||
fa34dc9e96
|
|||
34ed296546
|
|||
8b63d294d3 | |||
d38e937e22 | |||
c70280a964 | |||
41e950172b
|
|||
25381e1a04
|
|||
f7233c539e
|
|||
0b3c004d0b
|
|||
ac37d736cb
|
|||
91da6ff912
|
|||
ae7d1ed0dc
|
|||
ce0e3f1901
|
|||
edfca0e31d
|
|||
77da991c6f
|
|||
d61583e704
|
|||
1d31f17bb3
|
|||
3276be53cc
|
|||
442e7986d5
|
|||
faa0265fd7 | |||
0150e60f3d
|
|||
7572fa1ed7 | |||
1fa9b67fb2 |
36
dist/gpupdate-setup
vendored
36
dist/gpupdate-setup
vendored
@ -25,14 +25,35 @@ import subprocess
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from gpoa.util.samba import smbopts
|
||||||
|
|
||||||
|
|
||||||
def command(args):
|
def command(args):
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(args.split())
|
subprocess.check_call(args.split())
|
||||||
except:
|
except:
|
||||||
print ('command: \'%s\' error' % args)
|
print ('command: \'%s\' error' % args)
|
||||||
|
|
||||||
|
def from_command(args):
|
||||||
|
try:
|
||||||
|
with subprocess.Popen(args.split(), stdout=subprocess.PIPE) as proc:
|
||||||
|
value = proc.stdout.readline().decode('utf-8')
|
||||||
|
proc.wait()
|
||||||
|
except:
|
||||||
|
print ('from_command: \'%s\' error' % args)
|
||||||
|
return 'local'
|
||||||
|
|
||||||
|
return value.strip()
|
||||||
|
|
||||||
def get_default_policy_name():
|
def get_default_policy_name():
|
||||||
localpolicy = 'workstation'
|
localpolicy = 'workstation'
|
||||||
|
dcpolicy = 'ad-domain-controller'
|
||||||
|
|
||||||
|
try:
|
||||||
|
if smbopt.get_server_role() == 'active directory domain controller':
|
||||||
|
return dcpolicy
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
release = '/etc/altlinux-release'
|
release = '/etc/altlinux-release'
|
||||||
@ -139,9 +160,12 @@ def get_active_policy():
|
|||||||
|
|
||||||
|
|
||||||
def disable_gp():
|
def disable_gp():
|
||||||
#command('/usr/sbin/control system-policy local')
|
if from_command('/usr/sbin/control system-auth') != 'local':
|
||||||
|
command('/usr/sbin/control system-policy global')
|
||||||
|
else:
|
||||||
|
command('/usr/sbin/control system-policy local')
|
||||||
command('systemctl disable gpupdate.service')
|
command('systemctl disable gpupdate.service')
|
||||||
command('systemctl --global --user disable gpupdate-user.service')
|
command('systemctl --global disable gpupdate-user.service')
|
||||||
|
|
||||||
def enable_gp(policy_name):
|
def enable_gp(policy_name):
|
||||||
policy_dir = '/usr/share/local-policy'
|
policy_dir = '/usr/share/local-policy'
|
||||||
@ -158,18 +182,18 @@ def enable_gp(policy_name):
|
|||||||
if not os.path.isdir(etc_policy_dir):
|
if not os.path.isdir(etc_policy_dir):
|
||||||
os.makedirs(etc_policy_dir)
|
os.makedirs(etc_policy_dir)
|
||||||
|
|
||||||
if not os.path.isdir(active_policy_name):
|
if not os.path.islink(active_policy_name):
|
||||||
os.symlink(default_policy_name, active_policy_name)
|
os.symlink(default_policy_name, active_policy_name)
|
||||||
else:
|
else:
|
||||||
os.unlink(active_policy_name)
|
os.unlink(active_policy_name)
|
||||||
os.symlink(default_policy_name, active_policy_name)
|
os.symlink(default_policy_name, active_policy_name)
|
||||||
|
|
||||||
# Enable oddjobd_gpupdate in PAM config
|
# Enable oddjobd_gpupdate in PAM config
|
||||||
#command('/usr/sbin/control system-policy gpupdate')
|
command('/usr/sbin/control system-policy gpupdate')
|
||||||
# Bootstrap the Group Policy engine
|
# Bootstrap the Group Policy engine
|
||||||
command('/usr/sbin/gpoa --nodomain')
|
command('/usr/sbin/gpoa --nodomain --loglevel 5')
|
||||||
# Enable gpupdate-setup.service for all users
|
# Enable gpupdate-setup.service for all users
|
||||||
command('systemctl --global --user enable gpupdate-user.service')
|
command('systemctl --global enable gpupdate-user.service')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
arguments = parse_arguments()
|
arguments = parse_arguments()
|
||||||
|
@ -41,8 +41,13 @@ from util.users import (
|
|||||||
with_privileges
|
with_privileges
|
||||||
)
|
)
|
||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
|
from util.paths import (
|
||||||
|
frontend_module_dir
|
||||||
|
)
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
def determine_username(username=None):
|
def determine_username(username=None):
|
||||||
'''
|
'''
|
||||||
@ -72,6 +77,12 @@ class frontend_manager:
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, username, is_machine):
|
def __init__(self, username, is_machine):
|
||||||
|
frontend_module_files = frontend_module_dir().glob('**/*')
|
||||||
|
self.frontend_module_binaries = list()
|
||||||
|
for exe in frontend_module_files:
|
||||||
|
if (exe.is_file() and os.access(exe.resolve(), os.X_OK)):
|
||||||
|
self.frontend_module_binaries.append(exe)
|
||||||
|
|
||||||
self.storage = registry_factory('registry')
|
self.storage = registry_factory('registry')
|
||||||
self.username = determine_username(username)
|
self.username = determine_username(username)
|
||||||
self.is_machine = is_machine
|
self.is_machine = is_machine
|
||||||
@ -105,6 +116,10 @@ class frontend_manager:
|
|||||||
logging.error('Not sufficient privileges to run machine appliers')
|
logging.error('Not sufficient privileges to run machine appliers')
|
||||||
return
|
return
|
||||||
logging.debug(slogm('Applying computer part of settings'))
|
logging.debug(slogm('Applying computer part of settings'))
|
||||||
|
|
||||||
|
for exe in self.frontend_module_binaries:
|
||||||
|
subprocess.check_call([exe.resolve()])
|
||||||
|
|
||||||
self.machine_appliers['systemd'].apply()
|
self.machine_appliers['systemd'].apply()
|
||||||
self.machine_appliers['control'].apply()
|
self.machine_appliers['control'].apply()
|
||||||
self.machine_appliers['polkit'].apply()
|
self.machine_appliers['polkit'].apply()
|
||||||
|
@ -273,7 +273,7 @@ def lp2gpt():
|
|||||||
'''
|
'''
|
||||||
Convert local-policy to full-featured GPT.
|
Convert local-policy to full-featured GPT.
|
||||||
'''
|
'''
|
||||||
lppath = os.path.join(default_policy_path(), 'local.xml')
|
lppath = os.path.join(default_policy_path(), 'Machine/Registry.pol.xml')
|
||||||
|
|
||||||
# Load settings from XML PolFile
|
# Load settings from XML PolFile
|
||||||
polparser = GPPolParser()
|
polparser = GPPolParser()
|
||||||
|
@ -22,6 +22,6 @@ from .sqlite_cache import sqlite_cache
|
|||||||
def cache_factory(cache_name):
|
def cache_factory(cache_name):
|
||||||
return sqlite_cache(cache_name)
|
return sqlite_cache(cache_name)
|
||||||
|
|
||||||
def registry_factory(registry_name):
|
def registry_factory(registry_name='registry', registry_dir=None):
|
||||||
return sqlite_registry(registry_name)
|
return sqlite_registry(registry_name, registry_dir)
|
||||||
|
|
||||||
|
59
gpoa/storage/record_types.py
Normal file
59
gpoa/storage/record_types.py
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 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/>.
|
||||||
|
|
||||||
|
class samba_preg(object):
|
||||||
|
'''
|
||||||
|
Object mapping representing HKLM entry (registry key without SID)
|
||||||
|
'''
|
||||||
|
def __init__(self, preg_obj):
|
||||||
|
self.hive_key = '{}\\{}'.format(preg_obj.keyname, preg_obj.valuename)
|
||||||
|
self.type = preg_obj.type
|
||||||
|
self.data = preg_obj.data
|
||||||
|
|
||||||
|
class samba_hkcu_preg(object):
|
||||||
|
'''
|
||||||
|
Object mapping representing HKCU entry (registry key with SID)
|
||||||
|
'''
|
||||||
|
def __init__(self, sid, preg_obj):
|
||||||
|
self.sid = sid
|
||||||
|
self.hive_key = '{}\\{}'.format(preg_obj.keyname, preg_obj.valuename)
|
||||||
|
self.type = preg_obj.type
|
||||||
|
self.data = preg_obj.data
|
||||||
|
|
||||||
|
class ad_shortcut(object):
|
||||||
|
'''
|
||||||
|
Object mapping representing Windows shortcut.
|
||||||
|
'''
|
||||||
|
def __init__(self, sid, sc):
|
||||||
|
self.sid = sid
|
||||||
|
self.path = sc.dest
|
||||||
|
self.shortcut = sc.to_json()
|
||||||
|
|
||||||
|
class info_entry(object):
|
||||||
|
def __init__(self, name, value):
|
||||||
|
self.name = name
|
||||||
|
self.value = value
|
||||||
|
|
||||||
|
class printer_entry(object):
|
||||||
|
'''
|
||||||
|
Object mapping representing Windows printer of some type.
|
||||||
|
'''
|
||||||
|
def __init__(self, sid, pobj):
|
||||||
|
self.sid = sid
|
||||||
|
self.name = pobj.name
|
||||||
|
self.printer = pobj.to_json()
|
@ -36,53 +36,21 @@ from sqlalchemy.orm import (
|
|||||||
from util.logging import slogm
|
from util.logging import slogm
|
||||||
from util.paths import cache_dir
|
from util.paths import cache_dir
|
||||||
from .registry import registry
|
from .registry import registry
|
||||||
|
from .record_types import (
|
||||||
class samba_preg(object):
|
samba_preg
|
||||||
'''
|
, samba_hkcu_preg
|
||||||
Object mapping representing HKLM entry (registry key without SID)
|
, ad_shortcut
|
||||||
'''
|
, info_entry
|
||||||
def __init__(self, preg_obj):
|
, printer_entry
|
||||||
self.hive_key = '{}\\{}'.format(preg_obj.keyname, preg_obj.valuename)
|
)
|
||||||
self.type = preg_obj.type
|
|
||||||
self.data = preg_obj.data
|
|
||||||
|
|
||||||
class samba_hkcu_preg(object):
|
|
||||||
'''
|
|
||||||
Object mapping representing HKCU entry (registry key with SID)
|
|
||||||
'''
|
|
||||||
def __init__(self, sid, preg_obj):
|
|
||||||
self.sid = sid
|
|
||||||
self.hive_key = '{}\\{}'.format(preg_obj.keyname, preg_obj.valuename)
|
|
||||||
self.type = preg_obj.type
|
|
||||||
self.data = preg_obj.data
|
|
||||||
|
|
||||||
class ad_shortcut(object):
|
|
||||||
'''
|
|
||||||
Object mapping representing Windows shortcut.
|
|
||||||
'''
|
|
||||||
def __init__(self, sid, sc):
|
|
||||||
self.sid = sid
|
|
||||||
self.path = sc.dest
|
|
||||||
self.shortcut = sc.to_json()
|
|
||||||
|
|
||||||
class info_entry(object):
|
|
||||||
def __init__(self, name, value):
|
|
||||||
self.name = name
|
|
||||||
self.value = value
|
|
||||||
|
|
||||||
class printer_entry(object):
|
|
||||||
'''
|
|
||||||
Object mapping representing Windows printer of some type.
|
|
||||||
'''
|
|
||||||
def __init__(self, sid, pobj):
|
|
||||||
self.sid = sid
|
|
||||||
self.name = pobj.name
|
|
||||||
self.printer = pobj.to_json()
|
|
||||||
|
|
||||||
class sqlite_registry(registry):
|
class sqlite_registry(registry):
|
||||||
def __init__(self, db_name):
|
def __init__(self, db_name, registry_cache_dir=None):
|
||||||
self.db_name = db_name
|
self.db_name = db_name
|
||||||
self.db_path = os.path.join('sqlite:///{}/{}.sqlite'.format(cache_dir(), self.db_name))
|
cdir = registry_cache_dir
|
||||||
|
if cdir == None:
|
||||||
|
cdir = cache_dir()
|
||||||
|
self.db_path = os.path.join('sqlite:///{}/{}.sqlite'.format(cdir, self.db_name))
|
||||||
self.db_cnt = create_engine(self.db_path, echo=False)
|
self.db_cnt = create_engine(self.db_path, echo=False)
|
||||||
self.__metadata = MetaData(self.db_cnt)
|
self.__metadata = MetaData(self.db_cnt)
|
||||||
self.__info = Table(
|
self.__info = Table(
|
||||||
@ -221,15 +189,21 @@ class sqlite_registry(registry):
|
|||||||
Write PReg entry to HKEY_LOCAL_MACHINE
|
Write PReg entry to HKEY_LOCAL_MACHINE
|
||||||
'''
|
'''
|
||||||
pentry = samba_preg(preg_entry)
|
pentry = samba_preg(preg_entry)
|
||||||
self._hklm_upsert(pentry)
|
if not pentry.hive_key.rpartition('\\')[2].startswith('**'):
|
||||||
|
self._hklm_upsert(pentry)
|
||||||
|
else:
|
||||||
|
logging.warning(slogm('Skipping branch deletion key: {}'.format(pentry.hive_key)))
|
||||||
|
|
||||||
def add_hkcu_entry(self, preg_entry, sid):
|
def add_hkcu_entry(self, preg_entry, sid):
|
||||||
'''
|
'''
|
||||||
Write PReg entry to HKEY_CURRENT_USER
|
Write PReg entry to HKEY_CURRENT_USER
|
||||||
'''
|
'''
|
||||||
hkcu_pentry = samba_hkcu_preg(sid, preg_entry)
|
hkcu_pentry = samba_hkcu_preg(sid, preg_entry)
|
||||||
logging.debug(slogm('Adding HKCU entry for {}'.format(sid)))
|
if not hkcu_pentry.hive_key.rpartition('\\')[2].startswith('**'):
|
||||||
self._hkcu_upsert(hkcu_pentry)
|
logging.debug(slogm('Adding HKCU entry for {}'.format(sid)))
|
||||||
|
self._hkcu_upsert(hkcu_pentry)
|
||||||
|
else:
|
||||||
|
logging.warning(slogm('Skipping branch deletion key: {}'.format(hkcu_pentry.hive_key)))
|
||||||
|
|
||||||
def add_shortcut(self, sid, sc_obj):
|
def add_shortcut(self, sid, sc_obj):
|
||||||
'''
|
'''
|
||||||
|
18
gpoa/test/storage/__init__.py
Normal file
18
gpoa/test/storage/__init__.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 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/>.
|
||||||
|
|
18
gpoa/test/storage/data/Registry.pol.xml
Normal file
18
gpoa/test/storage/data/Registry.pol.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PolFile num_entries="3" signature="PReg" version="1">
|
||||||
|
<Entry type="1" type_name="REG_SZ">
|
||||||
|
<Key>Software\BaseALT\Policies\Control</Key>
|
||||||
|
<ValueName>**del.cups</ValueName>
|
||||||
|
<Value> </Value>
|
||||||
|
</Entry>
|
||||||
|
<Entry type="1" type_name="REG_SZ">
|
||||||
|
<Key>Software\BaseALT\Policies\Control</Key>
|
||||||
|
<ValueName>**del.postfix</ValueName>
|
||||||
|
<Value> </Value>
|
||||||
|
</Entry>
|
||||||
|
<Entry type="1" type_name="REG_SZ">
|
||||||
|
<Key>Software\BaseALT\Policies\Control</Key>
|
||||||
|
<ValueName>**del.postqueue</ValueName>
|
||||||
|
<Value> </Value>
|
||||||
|
</Entry>
|
||||||
|
</PolFile>
|
47
gpoa/test/storage/test_preg_special_values.py
Normal file
47
gpoa/test/storage/test_preg_special_values.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import unittest.mock
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class StorageTestCase(unittest.TestCase):
|
||||||
|
preg_xml_path = '{}/test/storage/data/Registry.pol.xml'.format(os.getcwd())
|
||||||
|
reg_name = 'registry'
|
||||||
|
# Run destructive storage tests in current directory
|
||||||
|
reg_path = '{}/test/tmp'.format(os.getcwd())
|
||||||
|
|
||||||
|
@unittest.mock.patch('util.paths.cache_dir')
|
||||||
|
def test_add_hklm_entry(self, cdir_mock):
|
||||||
|
test_sid = None
|
||||||
|
|
||||||
|
from util.preg import merge_polfile
|
||||||
|
|
||||||
|
merge_polfile(self.preg_xml_path, test_sid, self.reg_name, self.reg_path)
|
||||||
|
|
||||||
|
@unittest.mock.patch('util.paths.cache_dir')
|
||||||
|
def test_add_hkcu_entry(self, cdir_mock):
|
||||||
|
test_sid = 'test_sid'
|
||||||
|
|
||||||
|
from util.preg import merge_polfile
|
||||||
|
|
||||||
|
merge_polfile(self.preg_xml_path, test_sid, self.reg_name, self.reg_path)
|
||||||
|
|
5
gpoa/test/tmp/.gitignore
vendored
Normal file
5
gpoa/test/tmp/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
|
|
37
gpoa/test/util/test_rpm.py
Normal file
37
gpoa/test/util/test_rpm.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from util.rpm import (
|
||||||
|
install_rpms
|
||||||
|
, remove_rpms
|
||||||
|
)
|
||||||
|
|
||||||
|
class RPMTestCase(unittest.TestCase):
|
||||||
|
@unittest.skip('test_install_rpm is not unit test')
|
||||||
|
def test_install_rpm(self):
|
||||||
|
test_package_names = ['tortoisehg', 'csync']
|
||||||
|
install_rpms(test_package_names)
|
||||||
|
|
||||||
|
@unittest.skip('test_remove_rpm is not unit test')
|
||||||
|
def test_remove_rpm(self):
|
||||||
|
test_package_names = ['tortoisehg', 'csync']
|
||||||
|
remove_rpms(test_package_names)
|
||||||
|
|
@ -59,3 +59,31 @@ def local_policy_cache():
|
|||||||
|
|
||||||
return lpcache
|
return lpcache
|
||||||
|
|
||||||
|
def backend_module_dir():
|
||||||
|
backend_dir = '/usr/lib/gpoa/backend'
|
||||||
|
return pathlib.Path(backend_dir)
|
||||||
|
|
||||||
|
def frontend_module_dir():
|
||||||
|
frontend_dir = '/usr/lib/gpoa/frontend'
|
||||||
|
return pathlib.Path(frontend_dir)
|
||||||
|
|
||||||
|
def storage_module_dir():
|
||||||
|
storage_dir = '/usr/lib/gpoa/storage'
|
||||||
|
return pathlib.Path(storage_dir)
|
||||||
|
|
||||||
|
def pre_backend_plugin_dir():
|
||||||
|
pre_backend_dir = '/usr/lib/gpoa/backend_pre'
|
||||||
|
return pathlib.Path(pre_backend_dir)
|
||||||
|
|
||||||
|
def post_backend_plugin_dir():
|
||||||
|
post_backend_dir = '/usr/lib/gpoa/backend_post'
|
||||||
|
return pathlib.Path(post_backend_dir)
|
||||||
|
|
||||||
|
def pre_frontend_plugin_dir():
|
||||||
|
pre_forntend_dir = '/usr/lib/gpoa/frontend_pre'
|
||||||
|
return pathlib.Path(pre_frontend_dir)
|
||||||
|
|
||||||
|
def post_frontend_plugin_dir():
|
||||||
|
post_frontend_dir = '/usr/lib/gpoa/frontend_post'
|
||||||
|
return pathlib.Path(post_frontend_dir)
|
||||||
|
|
||||||
|
@ -76,11 +76,10 @@ def preg_keymap(preg):
|
|||||||
return keymap
|
return keymap
|
||||||
|
|
||||||
|
|
||||||
def merge_polfile(preg, sid=None):
|
def merge_polfile(preg, sid=None, reg_name='registry', reg_path=None):
|
||||||
pregfile = load_preg(preg)
|
pregfile = load_preg(preg)
|
||||||
logging.info(slogm('Loaded PReg {}'.format(preg)))
|
logging.info(slogm('Loaded PReg {}'.format(preg)))
|
||||||
key_map = dict()
|
storage = registry_factory(reg_name, reg_path)
|
||||||
storage = registry_factory('registry')
|
|
||||||
for entry in pregfile.entries:
|
for entry in pregfile.entries:
|
||||||
if not sid:
|
if not sid:
|
||||||
storage.add_hklm_entry(entry)
|
storage.add_hklm_entry(entry)
|
||||||
|
@ -33,6 +33,64 @@ def is_rpm_installed(rpm_name):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class Package:
|
||||||
|
__install_command = ['/usr/bin/apt-get', '-y', 'install']
|
||||||
|
__remove_command = ['/usr/bin/apt-get', '-y', 'remove']
|
||||||
|
__reinstall_command = ['/usr/bin/apt-get', '-y', 'reinstall']
|
||||||
|
|
||||||
|
def __init__(self, package_name):
|
||||||
|
self.package_name = package_name
|
||||||
|
self.for_install = True
|
||||||
|
|
||||||
|
if package_name.endswith('-'):
|
||||||
|
self.package_name = package_name[:-1]
|
||||||
|
self.for_install = False
|
||||||
|
|
||||||
|
self.installed = is_rpm_installed(self.package_name)
|
||||||
|
|
||||||
|
def mark_for_install(self):
|
||||||
|
self.for_install = True
|
||||||
|
|
||||||
|
def mark_for_removal(self):
|
||||||
|
self.for_install = False
|
||||||
|
|
||||||
|
def is_installed(self):
|
||||||
|
return self.installed
|
||||||
|
|
||||||
|
def is_for_install(self):
|
||||||
|
return self.for_install
|
||||||
|
|
||||||
|
def is_for_removal(self):
|
||||||
|
return (not self.for_install)
|
||||||
|
|
||||||
|
def action(self):
|
||||||
|
if self.for_install:
|
||||||
|
if not self.is_installed():
|
||||||
|
return self.install()
|
||||||
|
else:
|
||||||
|
if self.is_installed():
|
||||||
|
return self.remove()
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
fullcmd = self.__install_command
|
||||||
|
fullcmd.append(self.package_name)
|
||||||
|
return subprocess.check_call(fullcmd)
|
||||||
|
|
||||||
|
def reinstall(self):
|
||||||
|
fullcmd = self.__reinstall_command
|
||||||
|
fullcmd.append(self.package_name)
|
||||||
|
return subprocess.check_call(fullcmd)
|
||||||
|
|
||||||
|
def remove(self):
|
||||||
|
fullcmd = self.__remove_command
|
||||||
|
fullcmd.append(self.package_name)
|
||||||
|
return subprocess.check_call(fullcmd)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.package_name
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.package_name
|
||||||
|
|
||||||
def update():
|
def update():
|
||||||
'''
|
'''
|
||||||
@ -40,18 +98,40 @@ def update():
|
|||||||
'''
|
'''
|
||||||
subprocess.check_call(['/usr/bin/apt-get', 'update'])
|
subprocess.check_call(['/usr/bin/apt-get', 'update'])
|
||||||
|
|
||||||
|
|
||||||
def install_rpm(rpm_name):
|
def install_rpm(rpm_name):
|
||||||
'''
|
'''
|
||||||
Install RPM from APT-RPM sources.
|
Install single RPM
|
||||||
'''
|
'''
|
||||||
update()
|
update()
|
||||||
subprocess.check_call(['/usr/bin/apt-get', '-y', 'install', rpm_name])
|
rpm = Package(rpm_name)
|
||||||
|
return rpm.install()
|
||||||
|
|
||||||
def remove_rpm(rpm_name):
|
def remove_rpm(rpm_name):
|
||||||
'''
|
'''
|
||||||
Remove RPM from file system.
|
Remove single RPM
|
||||||
'''
|
'''
|
||||||
subprocess.check_call(['/usr/bin/apt-get', '-y', 'remove', rpm_name])
|
rpm = Package(rpm_name)
|
||||||
|
return rpm.remove()
|
||||||
|
|
||||||
|
def install_rpms(rpm_names):
|
||||||
|
'''
|
||||||
|
Install set of RPMs sequentially
|
||||||
|
'''
|
||||||
|
result = list()
|
||||||
|
|
||||||
|
for package in rpm_names:
|
||||||
|
result.append(install_rpm(package))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def remove_rpms(rpm_names):
|
||||||
|
'''
|
||||||
|
Remove set of RPMs requentially
|
||||||
|
'''
|
||||||
|
result = list()
|
||||||
|
|
||||||
|
for package in rpm_names:
|
||||||
|
result.append(remove_rpm(package))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
38
gpoa/util/samba.py
Normal file
38
gpoa/util/samba.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#
|
||||||
|
# GPOA - GPO Applier for Linux
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019-2020 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/>.
|
||||||
|
|
||||||
|
|
||||||
|
import optparse
|
||||||
|
from samba import getopt as options
|
||||||
|
|
||||||
|
|
||||||
|
class smbopts:
|
||||||
|
|
||||||
|
def __init__(self, prog=None):
|
||||||
|
self.parser = optparse.OptionParser(prog)
|
||||||
|
self.sambaopts = options.SambaOptions(self.parser)
|
||||||
|
self.lp = self.sambaopts.get_loadparm()
|
||||||
|
|
||||||
|
def get_cache_dir(self):
|
||||||
|
return self._get_prop('cache directory')
|
||||||
|
|
||||||
|
def get_server_role(self):
|
||||||
|
return self._get_prop('server role')
|
||||||
|
|
||||||
|
def _get_prop(self, property_name):
|
||||||
|
return self.lp.get(property_name)
|
@ -21,7 +21,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
|
|
||||||
import optparse
|
|
||||||
from samba import getopt as options
|
from samba import getopt as options
|
||||||
|
|
||||||
from samba.gpclass import get_dc_hostname, check_refresh_gpo_list
|
from samba.gpclass import get_dc_hostname, check_refresh_gpo_list
|
||||||
@ -33,15 +32,14 @@ from storage import cache_factory
|
|||||||
from .xdg import get_user_dir
|
from .xdg import get_user_dir
|
||||||
from .util import get_homedir
|
from .util import get_homedir
|
||||||
from .logging import slogm
|
from .logging import slogm
|
||||||
|
from .samba import smbopts
|
||||||
|
|
||||||
|
|
||||||
class smbcreds:
|
class smbcreds (smbopts):
|
||||||
|
|
||||||
def __init__(self, dc_fqdn=None):
|
def __init__(self, dc_fqdn=None):
|
||||||
self.parser = optparse.OptionParser('GPO Applier')
|
smbopts.__init__(self, 'GPO Applier')
|
||||||
self.sambaopts = options.SambaOptions(self.parser)
|
|
||||||
self.credopts = options.CredentialsOptions(self.parser)
|
self.credopts = options.CredentialsOptions(self.parser)
|
||||||
self.lp = self.sambaopts.get_loadparm()
|
|
||||||
self.creds = self.credopts.get_credentials(self.lp, fallback_machine=True)
|
self.creds = self.credopts.get_credentials(self.lp, fallback_machine=True)
|
||||||
self.selected_dc = self.set_dc(dc_fqdn)
|
self.selected_dc = self.set_dc(dc_fqdn)
|
||||||
|
|
||||||
@ -87,9 +85,6 @@ class smbcreds:
|
|||||||
|
|
||||||
return dns_domainname
|
return dns_domainname
|
||||||
|
|
||||||
def get_cache_dir(self):
|
|
||||||
return self._get_prop('cache directory')
|
|
||||||
|
|
||||||
def get_gpos(self, username):
|
def get_gpos(self, username):
|
||||||
'''
|
'''
|
||||||
Get GPO list for the specified username for the specified DC
|
Get GPO list for the specified username for the specified DC
|
||||||
@ -125,9 +120,6 @@ class smbcreds:
|
|||||||
username, self.selected_dc)))
|
username, self.selected_dc)))
|
||||||
return gpos
|
return gpos
|
||||||
|
|
||||||
def _get_prop(self, property_name):
|
|
||||||
return self.lp.get(property_name)
|
|
||||||
|
|
||||||
|
|
||||||
def wbinfo_getsid(domain, user):
|
def wbinfo_getsid(domain, user):
|
||||||
'''
|
'''
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
%define _unpackaged_files_terminate_build 1
|
%define _unpackaged_files_terminate_build 1
|
||||||
|
|
||||||
Name: gpupdate
|
Name: gpupdate
|
||||||
Version: 0.4.4
|
Version: 0.5.0
|
||||||
Release: alt1
|
Release: alt1
|
||||||
|
|
||||||
Summary: GPT applier
|
Summary: GPT applier
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Group: Other
|
Group: Other
|
||||||
Url: http://git.altlinux.org/
|
Url: https://github.com/altlinux/gpupdate
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
Requires: control
|
Requires: control
|
||||||
@ -15,9 +15,13 @@ Requires: local-policy >= 0.1.0
|
|||||||
|
|
||||||
BuildRequires: rpm-build-python3
|
BuildRequires: rpm-build-python3
|
||||||
Requires: python3-module-rpm
|
Requires: python3-module-rpm
|
||||||
|
Requires: python3-module-dbus
|
||||||
Requires: oddjob-%name >= 0.2.0
|
Requires: oddjob-%name >= 0.2.0
|
||||||
Requires: libnss-role >= 0.5.0
|
Requires: libnss-role >= 0.5.0
|
||||||
Requires: local-policy >= 0.2.0
|
Requires: local-policy >= 0.3.0
|
||||||
|
Requires: pam-config >= 1.8
|
||||||
|
# This is needed by shortcuts_applier
|
||||||
|
Requires: desktop-file-utils
|
||||||
|
|
||||||
Source0: %name-%version.tar
|
Source0: %name-%version.tar
|
||||||
|
|
||||||
@ -50,9 +54,9 @@ mkdir -p %buildroot%_datadir/%name
|
|||||||
mv %buildroot%python3_sitelibdir/gpoa/templates \
|
mv %buildroot%python3_sitelibdir/gpoa/templates \
|
||||||
%buildroot%_datadir/%name/
|
%buildroot%_datadir/%name/
|
||||||
|
|
||||||
install -Dm0644 %name.service %buildroot%_unitdir/%name.service
|
install -Dm0644 dist/%name.service %buildroot%_unitdir/%name.service
|
||||||
install -Dm0644 %name.service %{buildroot}/usr/lib/systemd/user/%{name}-user.service
|
install -Dm0644 dist/%name.service %{buildroot}/usr/lib/systemd/user/%{name}-user.service
|
||||||
install -Dm0644 system-policy-%name %buildroot%_sysconfdir/pam.d/system-policy-%name
|
install -Dm0644 dist/system-policy-%name %buildroot%_sysconfdir/pam.d/system-policy-%name
|
||||||
install -Dm0644 doc/gpoa.1 %buildroot/%{_man1dir}/gpoa.1
|
install -Dm0644 doc/gpoa.1 %buildroot/%{_man1dir}/gpoa.1
|
||||||
install -Dm0644 doc/gpupdate.1 %buildroot/%{_man1dir}/gpupdate.1
|
install -Dm0644 doc/gpupdate.1 %buildroot/%{_man1dir}/gpupdate.1
|
||||||
|
|
||||||
@ -71,13 +75,21 @@ install -Dm0644 doc/gpupdate.1 %buildroot/%{_man1dir}/gpupdate.1
|
|||||||
%python3_sitelibdir/gpoa
|
%python3_sitelibdir/gpoa
|
||||||
%_datadir/%name
|
%_datadir/%name
|
||||||
%_unitdir/%name.service
|
%_unitdir/%name.service
|
||||||
%{_man1dir}/gpoa.1.xz
|
%_man1dir/gpoa.1.*
|
||||||
%{_man1dir}/gpupdate.1.xz
|
%_man1dir/gpupdate.1.*
|
||||||
/usr/lib/systemd/user/%{name}-user.service
|
/usr/lib/systemd/user/%name-user.service
|
||||||
%_sysconfdir/pam.d/system-policy-%name
|
%_sysconfdir/pam.d/system-policy-%name
|
||||||
%dir %_cachedir/%name
|
%dir %_cachedir/%name
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Apr 22 2020 Evgeny Sinelnikov <sin@altlinux.org> 0.5.0-alt1
|
||||||
|
- Update samba format: local.xml -> Machine/Registry.pol.xml
|
||||||
|
- Add support of ad-domain-controller local policy profile
|
||||||
|
- Set properly URL of project
|
||||||
|
|
||||||
|
* Mon Apr 20 2020 Evgeny Sinelnikov <sin@altlinux.org> 0.4.5-alt1
|
||||||
|
- Add support for control system-policy and requires to new pam-config
|
||||||
|
|
||||||
* Sun Apr 19 2020 Evgeny Sinelnikov <sin@altlinux.org> 0.4.4-alt1
|
* Sun Apr 19 2020 Evgeny Sinelnikov <sin@altlinux.org> 0.4.4-alt1
|
||||||
- Add gpupdate-setup initialization script supported local-policy profiles
|
- Add gpupdate-setup initialization script supported local-policy profiles
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user