summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorDavid Mulder <dmulder@suse.com>2017-11-21 03:44:12 -0700
committerStefan Metzmacher <metze@samba.org>2018-01-13 22:38:05 +0100
commit2ca73cba53621c6db79f769f625316535fbfdbc9 (patch)
tree87a83f1fd5aba3330cf1708a78bfbe70e763cb3e /source4/scripting
parentfb5241aa9d3fe8319ff5232b8a3d1987d03ba7bf (diff)
downloadsamba-2ca73cba53621c6db79f769f625316535fbfdbc9.tar.gz
gpo: Add the winbind call to gpupdate
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/samba_gpoupdate21
-rw-r--r--source4/scripting/bin/wscript_build2
-rw-r--r--source4/scripting/wscript_build7
3 files changed, 24 insertions, 6 deletions
diff --git a/source4/scripting/bin/samba_gpoupdate b/source4/scripting/bin/samba_gpoupdate
index e74b2c896a1..26e0984413e 100755
--- a/source4/scripting/bin/samba_gpoupdate
+++ b/source4/scripting/bin/samba_gpoupdate
@@ -29,11 +29,18 @@ sys.path.insert(0, "bin/python")
import optparse
from samba import getopt as options
+from samba.auth import system_session
+try:
+ from samba.samdb import SamDB
+except:
+ SamDB = None
from samba.gpclass import *
from samba.net import Net
from samba.dcerpc import nbt
from samba import smb
+import samba.gpo as gpo
import logging
+import chardet
''' Fetch the hostname of a writable DC '''
def get_dc_hostname(creds, lp):
@@ -117,6 +124,8 @@ if __name__ == "__main__":
parser.add_option('-H', '--url', dest='url', help='URL for the samdb')
parser.add_option('-X', '--unapply', help='Unapply Group Policy',
action='store_true')
+ parser.add_option('-M', '--machine', help='Apply machine policy',
+ action='store_true', default=False)
parser.add_option_group(credopts)
# Set the options and the arguments
@@ -150,10 +159,18 @@ if __name__ == "__main__":
cache_dir = lp.get('cache directory')
store = GPOStorage(os.path.join(cache_dir, 'gpo.tdb'))
- gp_extensions = [gp_sec_ext(logger)]
+ gp_extensions = []
+ if opts.machine:
+ if lp.get('server role') == 'active directory domain controller':
+ gp_extensions.append(gp_sec_ext(logger))
+ else:
+ pass # User extensions
# Get a live instance of Samba
- test_ldb = SamDB(url, session_info=session, credentials=creds, lp=lp)
+ if SamDB:
+ test_ldb = SamDB(url, session_info=session, credentials=creds, lp=lp)
+ else:
+ test_ldb = None
if not opts.unapply:
apply_gp(lp, creds, test_ldb, logger, store, gp_extensions)
diff --git a/source4/scripting/bin/wscript_build b/source4/scripting/bin/wscript_build
index 737f1bce411..043442b3407 100644
--- a/source4/scripting/bin/wscript_build
+++ b/source4/scripting/bin/wscript_build
@@ -7,6 +7,6 @@ if bld.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
'samba_kcc',
'samba_upgradeprovision',
'samba_upgradedns',
- 'samba_gpoupdate',
'gen_output.py']:
bld.SAMBA_SCRIPT(script, pattern=script, installdir='.')
+bld.SAMBA_SCRIPT('samba_gpoupdate', pattern='samba_gpoupdate', installdir='.')
diff --git a/source4/scripting/wscript_build b/source4/scripting/wscript_build
index eb11c4202fe..2f53cce12b7 100644
--- a/source4/scripting/wscript_build
+++ b/source4/scripting/wscript_build
@@ -2,10 +2,11 @@
from samba_utils import MODE_755
-sbin_files = None
+sbin_files = ''
if bld.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
- sbin_files = 'bin/samba_dnsupdate bin/samba_spnupdate bin/samba_upgradedns bin/samba_kcc bin/samba_gpoupdate'
- man_files = 'man/samba_gpoupdate.8'
+ sbin_files = 'bin/samba_dnsupdate bin/samba_spnupdate bin/samba_upgradedns bin/samba_kcc '
+sbin_files += 'bin/samba_gpoupdate'
+man_files = 'man/samba_gpoupdate.8'
if sbin_files:
bld.INSTALL_FILES('${SBINDIR}',