[PATCHES] rename samba_gpoupdate to gpupdate

David Mulder dmulder at suse.com
Wed Jun 27 14:02:11 UTC 2018


Rebased and changed the command to samba_gpupdate.

On 06/27/2018 07:22 AM, David Mulder wrote:
> Obviously the rename is a trivial thing. Naming it samba_gpupdate does
> seem to make more sense.
> I would like to make the parameter change though. The current param of
> --machine for computer apply, and lack of --machine meaning user apply
> is awkward.
>
> On 06/26/2018 08:07 PM, Andrew Bartlett wrote:
>> On Thu, 2018-06-07 at 11:07 +0200, David Mulder via samba-technical
>> wrote:
>>> This command is called gpupdate on Windows, and uses a target parameter
>>> to determine Computer/User apply. Let's mimic that command.
>>>
>>>  docs-xml/smbdotconf/domain/gpoupdatecommand.xml                 |  4 ++--
>>>  lib/param/loadparm.c                                            |  2 +-
>>>  selftest/target/Samba4.pm                                       |  2 +-
>>>  source3/param/loadparm.c                                        |  2 +-
>>>  source3/winbindd/winbindd_gpupdate.c                            |  2 +-
>>>  source4/scripting/bin/{samba_gpoupdate => gpupdate}             | 12
>>> ++++++------
>>>  source4/scripting/bin/wscript_build                             |  2 +-
>>>  source4/scripting/man/{samba_gpoupdate.8.xml => gpupdate.8.xml} | 13
>>> ++++++++-----
>>>  source4/scripting/wscript_build                                 |  4 ++--
>>>  9 files changed, 23 insertions(+), 20 deletions(-)
>> G'Day David,
>>
>> I understand the desire not to have the "o" in there, but why remove
>> the samba_ prefix?
>>
>> I'm nervous about the mimic idea, because we tried that with 'net'
>> which doesn't really mimic Windows very well and instead diverges at
>> lot.  (Whereas samba-tool has no pretence as to what it is).
>>
>> Andrew Bartlett
>>

-- 
David Mulder
SUSE Labs Software Engineer - Samba
dmulder at suse.com
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

-------------- next part --------------
From 9c7601b6e1d8657ac5f0c9769174888273576e3a Mon Sep 17 00:00:00 2001
From: David Mulder <dmulder at suse.com>
Date: Mon, 7 May 2018 09:45:32 -0600
Subject: [PATCH 1/2] samba_gpoupdate: Rename the command to samba_gpupdate

On a Windows client, this command is called 'gpupdate'

Signed-off-by: David Mulder <dmulder at suse.com>
---
 docs-xml/smbdotconf/domain/gpoupdatecommand.xml                |  4 ++--
 lib/param/loadparm.c                                           |  2 +-
 selftest/target/Samba4.pm                                      |  2 +-
 source3/param/loadparm.c                                       |  2 +-
 source4/scripting/bin/{samba_gpoupdate => samba_gpupdate}      |  4 ++--
 source4/scripting/bin/wscript_build                            |  2 +-
 .../man/{samba_gpoupdate.8.xml => samba_gpupdate.8.xml}        | 10 +++++-----
 source4/scripting/wscript_build                                |  4 ++--
 8 files changed, 15 insertions(+), 15 deletions(-)
 rename source4/scripting/bin/{samba_gpoupdate => samba_gpupdate} (96%)
 rename source4/scripting/man/{samba_gpoupdate.8.xml => samba_gpupdate.8.xml} (94%)

diff --git a/docs-xml/smbdotconf/domain/gpoupdatecommand.xml b/docs-xml/smbdotconf/domain/gpoupdatecommand.xml
index 3ce26d78287..294e5f1534c 100644
--- a/docs-xml/smbdotconf/domain/gpoupdatecommand.xml
+++ b/docs-xml/smbdotconf/domain/gpoupdatecommand.xml
@@ -5,7 +5,7 @@
                  xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
 <description>
 	<para>This option sets the command that is called to apply GPO policies.
-        The samba_gpoupdate script applies System Access and Kerberos Policies
+        The samba_gpupdate script applies System Access and Kerberos Policies
 	to the KDC. System Access policies set minPwdAge, maxPwdAge,
 	minPwdLength, and pwdProperties in the samdb. Kerberos Policies set
 	kdc:service ticket lifetime, kdc:user ticket lifetime, and kdc:renewal
@@ -13,6 +13,6 @@
 	</para>
 </description>
 
-<value type="default">&pathconfig.SCRIPTSBINDIR;/samba_gpoupdate</value>
+<value type="default">&pathconfig.SCRIPTSBINDIR;/samba_gpupdate</value>
 <value type="example">/usr/local/sbin/gpoupdate</value>
 </samba:parameter>
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 3b7f8053e4a..1fa51a12f8a 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -2733,7 +2733,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
 	lpcfg_do_global_parameter(lp_ctx, "require strong key", "True");
 	lpcfg_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
 	lpcfg_do_global_parameter(lp_ctx, "ntp signd socket directory", dyn_NTP_SIGND_SOCKET_DIR);
-	lpcfg_do_global_parameter_var(lp_ctx, "gpo update command", "%s/samba_gpoupdate", dyn_SCRIPTSBINDIR);
+	lpcfg_do_global_parameter_var(lp_ctx, "gpo update command", "%s/samba_gpupdate", dyn_SCRIPTSBINDIR);
 	lpcfg_do_global_parameter_var(lp_ctx, "apply group policies", "False");
 	lpcfg_do_global_parameter_var(lp_ctx, "dns update command", "%s/samba_dnsupdate", dyn_SCRIPTSBINDIR);
 	lpcfg_do_global_parameter_var(lp_ctx, "spn update command", "%s/samba_spnupdate", dyn_SCRIPTSBINDIR);
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 14e312f8586..0a0c9d708fb 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -641,7 +641,7 @@ sub provision_raw_step1($$)
 	rndc command = true
 	dns update command = $ctx->{samba_dnsupdate}
 	spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
-	gpo update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_gpoupdate -s $ctx->{smb_conf} -H $ctx->{privatedir}/sam.ldb --machine
+	gpo update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_gpupdate -s $ctx->{smb_conf} -H $ctx->{privatedir}/sam.ldb --machine
 	dreplsrv:periodic_startup_interval = 0
 	dsdb:schema update allowed = yes
 
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ecff22eb638..95aa73a226b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -917,7 +917,7 @@ static void init_globals(struct loadparm_context *lp_ctx, bool reinit_globals)
 	Globals.dns_update_command = str_list_make_v3_const(NULL, s, NULL);
 	TALLOC_FREE(s);
 
-	s = talloc_asprintf(talloc_tos(), "%s/samba_gpoupdate", get_dyn_SCRIPTSBINDIR());
+	s = talloc_asprintf(talloc_tos(), "%s/samba_gpupdate", get_dyn_SCRIPTSBINDIR());
 	if (s == NULL) {
 		smb_panic("init_globals: ENOMEM");
 	}
diff --git a/source4/scripting/bin/samba_gpoupdate b/source4/scripting/bin/samba_gpupdate
similarity index 96%
rename from source4/scripting/bin/samba_gpoupdate
rename to source4/scripting/bin/samba_gpupdate
index 89b3ed77616..b2672da53f1 100755
--- a/source4/scripting/bin/samba_gpoupdate
+++ b/source4/scripting/bin/samba_gpupdate
@@ -39,7 +39,7 @@ from samba.gp_sec_ext import gp_sec_ext
 import logging
 
 if __name__ == "__main__":
-    parser = optparse.OptionParser('samba_gpoupdate [options]')
+    parser = optparse.OptionParser('samba_gpupdate [options]')
     sambaopts = options.SambaOptions(parser)
 
     # Get the command line options
@@ -68,7 +68,7 @@ if __name__ == "__main__":
     session = system_session()
 
     # Set up logging
-    logger = logging.getLogger('samba_gpoupdate')
+    logger = logging.getLogger('samba_gpupdate')
     logger.addHandler(logging.StreamHandler(sys.stdout))
     logger.setLevel(logging.CRITICAL)
     log_level = lp.log_level()
diff --git a/source4/scripting/bin/wscript_build b/source4/scripting/bin/wscript_build
index 043442b3407..9b23d196a09 100644
--- a/source4/scripting/bin/wscript_build
+++ b/source4/scripting/bin/wscript_build
@@ -9,4 +9,4 @@ if bld.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'):
                    'samba_upgradedns',
                    'gen_output.py']:
         bld.SAMBA_SCRIPT(script, pattern=script, installdir='.')
-bld.SAMBA_SCRIPT('samba_gpoupdate', pattern='samba_gpoupdate', installdir='.')
+bld.SAMBA_SCRIPT('samba_gpupdate', pattern='samba_gpupdate', installdir='.')
diff --git a/source4/scripting/man/samba_gpoupdate.8.xml b/source4/scripting/man/samba_gpupdate.8.xml
similarity index 94%
rename from source4/scripting/man/samba_gpoupdate.8.xml
rename to source4/scripting/man/samba_gpupdate.8.xml
index 0c3a0a812a1..bcb37889407 100644
--- a/source4/scripting/man/samba_gpoupdate.8.xml
+++ b/source4/scripting/man/samba_gpupdate.8.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-<refentry id="samba_gpoupdate.8">
+<refentry id="samba_gpupdate.8">
 <refentryinfo><date>2017-07-11</date></refentryinfo>
 
 <refmeta>
@@ -12,17 +12,17 @@
 </refmeta>
 
 <refnamediv>
-	<refname>samba_gpoupdate</refname>
+	<refname>samba_gpupdate</refname>
 	<refpurpose>apply group policy</refpurpose>
 </refnamediv>
 
 <refsynopsisdiv>
 	<cmdsynopsis>
-		<command>samba_gpoupdate</command>
+		<command>samba_gpupdate</command>
 	</cmdsynopsis>
 
 	<cmdsynopsis>
-		<command>samba_gpoupdate</command>
+		<command>samba_gpupdate</command>
 		<arg choice="opt">
 		<replaceable>options</replaceable>
 		</arg>
@@ -37,7 +37,7 @@
 	<citerefentry><refentrytitle>samba</refentrytitle>
 	<manvolnum>1</manvolnum></citerefentry> suite.</para>
 
-	<para><command>samba_gpoupdate</command> a script for
+	<para><command>samba_gpupdate</command> a script for
 	applying and unapplying Group Policy. Group Policy
 	application is experimental. Currently this applies
 	password policies (minimum/maximum password age,
diff --git a/source4/scripting/wscript_build b/source4/scripting/wscript_build
index 2f53cce12b7..430dd9a6fd7 100644
--- a/source4/scripting/wscript_build
+++ b/source4/scripting/wscript_build
@@ -5,8 +5,8 @@ from samba_utils import MODE_755
 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 '
-sbin_files += 'bin/samba_gpoupdate'
-man_files = 'man/samba_gpoupdate.8'
+sbin_files += 'bin/samba_gpupdate'
+man_files = 'man/samba_gpupdate.8'
 
 if sbin_files:
     bld.INSTALL_FILES('${SBINDIR}',
-- 
2.13.6


From c4998f821fcb03ae66a7f79911313f87a3610a62 Mon Sep 17 00:00:00 2001
From: David Mulder <dmulder at suse.com>
Date: Mon, 7 May 2018 09:48:32 -0600
Subject: [PATCH 2/2] samba_gpupdate: Change machine option to target

On a Windows client, you designate machine/user
apply with a 'target' parameter. This change
makes gpupdate work more like that command.

Signed-off-by: David Mulder <dmulder at suse.com>
---
 selftest/target/Samba4.pm                  | 2 +-
 source3/winbindd/winbindd_gpupdate.c       | 2 +-
 source4/scripting/bin/samba_gpupdate       | 8 ++++----
 source4/scripting/man/samba_gpupdate.8.xml | 3 +++
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 0a0c9d708fb..686c4d7acce 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -641,7 +641,7 @@ sub provision_raw_step1($$)
 	rndc command = true
 	dns update command = $ctx->{samba_dnsupdate}
 	spn update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_spnupdate -s $ctx->{smb_conf}
-	gpo update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_gpupdate -s $ctx->{smb_conf} -H $ctx->{privatedir}/sam.ldb --machine
+	gpo update command = $ENV{SRCDIR_ABS}/source4/scripting/bin/samba_gpupdate -s $ctx->{smb_conf} -H $ctx->{privatedir}/sam.ldb --target=Computer
 	dreplsrv:periodic_startup_interval = 0
 	dsdb:schema update allowed = yes
 
diff --git a/source3/winbindd/winbindd_gpupdate.c b/source3/winbindd/winbindd_gpupdate.c
index c86c007be12..75772ea4feb 100644
--- a/source3/winbindd/winbindd_gpupdate.c
+++ b/source3/winbindd/winbindd_gpupdate.c
@@ -62,7 +62,7 @@ static void gpupdate_callback(struct tevent_context *ev,
 				gpupdate_cmd,
 				"-s",
 				smbconf,
-				"--machine",
+				"--target=Computer",
 				"--machine-pass",
 				NULL);
 	if (req == NULL) {
diff --git a/source4/scripting/bin/samba_gpupdate b/source4/scripting/bin/samba_gpupdate
index b2672da53f1..056727c0c45 100755
--- a/source4/scripting/bin/samba_gpupdate
+++ b/source4/scripting/bin/samba_gpupdate
@@ -49,8 +49,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('--target', default='Computer', help='{Computer | User}',
+                      choices=['Computer', 'User'])
     parser.add_option_group(credopts)
 
     # Set the options and the arguments
@@ -85,10 +85,10 @@ if __name__ == "__main__":
     store = GPOStorage(os.path.join(cache_dir, 'gpo.tdb'))
 
     gp_extensions = []
-    if opts.machine:
+    if opts.target == 'Computer':
         if lp.get('server role') == 'active directory domain controller':
             gp_extensions.append(gp_sec_ext(logger))
-    else:
+    elif opts.target == 'User':
         pass # User extensions
 
     # Get a live instance of Samba
diff --git a/source4/scripting/man/samba_gpupdate.8.xml b/source4/scripting/man/samba_gpupdate.8.xml
index bcb37889407..a184c16537f 100644
--- a/source4/scripting/man/samba_gpupdate.8.xml
+++ b/source4/scripting/man/samba_gpupdate.8.xml
@@ -59,6 +59,9 @@
 <para><option>-X</option>, <option>--unapply</option>
        Unapply Group Policy</para>
 
+<para><option>--target</option>
+       {Computer | User}</para>
+
 <para>Samba Common Options:</para>
 
 <para><option>-s </option>FILE, <option>--configfile</option>=<emphasis remap="I">FILE</emphasis>
-- 
2.13.6



More information about the samba-technical mailing list