1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Merge pull request #49 from altlinux/samba_format

Samba format: local.xml -> Machine/Registry.pol.xml
This commit is contained in:
Evgeny Sinelnikov 2020-04-22 00:36:15 +04:00 committed by GitHub
commit a7aa12d42d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 14 deletions

12
dist/gpupdate-setup vendored
View File

@ -25,6 +25,9 @@ import subprocess
import re
from gpoa.util.samba import smbopts
def command(args):
try:
subprocess.check_call(args.split())
@ -44,6 +47,13 @@ def from_command(args):
def get_default_policy_name():
localpolicy = 'workstation'
dcpolicy = 'ad-domain-controller'
try:
if smbopt.get_server_role() == 'active directory domain controller':
return dcpolicy
except:
pass
try:
release = '/etc/altlinux-release'
@ -172,7 +182,7 @@ def enable_gp(policy_name):
if not os.path.isdir(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)
else:
os.unlink(active_policy_name)

View File

@ -273,7 +273,7 @@ def lp2gpt():
'''
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
polparser = GPPolParser()

38
gpoa/util/samba.py Normal file
View 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)

View File

@ -21,7 +21,6 @@ import logging
import os
import pwd
import optparse
from samba import getopt as options
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 .util import get_homedir
from .logging import slogm
from .samba import smbopts
class smbcreds:
class smbcreds (smbopts):
def __init__(self, dc_fqdn=None):
self.parser = optparse.OptionParser('GPO Applier')
self.sambaopts = options.SambaOptions(self.parser)
smbopts.__init__(self, 'GPO Applier')
self.credopts = options.CredentialsOptions(self.parser)
self.lp = self.sambaopts.get_loadparm()
self.creds = self.credopts.get_credentials(self.lp, fallback_machine=True)
self.selected_dc = self.set_dc(dc_fqdn)
@ -87,9 +85,6 @@ class smbcreds:
return dns_domainname
def get_cache_dir(self):
return self._get_prop('cache directory')
def get_gpos(self, username):
'''
Get GPO list for the specified username for the specified DC
@ -125,9 +120,6 @@ class smbcreds:
username, self.selected_dc)))
return gpos
def _get_prop(self, property_name):
return self.lp.get(property_name)
def wbinfo_getsid(domain, user):
'''

View File

@ -18,7 +18,7 @@ Requires: python3-module-rpm
Requires: python3-module-dbus
Requires: oddjob-%name >= 0.2.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