mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
gpupdate: Add the --force option
This option forces the reapplication of policy, and works the same as MS 'gpupdate /force' Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
This commit is contained in:
parent
471089eed4
commit
4e98d18bea
@ -427,7 +427,7 @@ def gpo_version(lp, path):
|
||||
return int(gpo.gpo_get_sysvol_gpt_version(gpt_path)[1])
|
||||
|
||||
|
||||
def apply_gp(lp, creds, logger, store, gp_extensions):
|
||||
def apply_gp(lp, creds, logger, store, gp_extensions, force=False):
|
||||
gp_db = store.get_gplog(creds.get_username())
|
||||
dc_hostname = get_dc_hostname(creds, lp)
|
||||
gpos = get_gpo_list(dc_hostname, creds, lp)
|
||||
@ -439,16 +439,21 @@ def apply_gp(lp, creds, logger, store, gp_extensions):
|
||||
% dc_hostname)
|
||||
return
|
||||
|
||||
changed_gpos = []
|
||||
for gpo_obj in gpos:
|
||||
if not gpo_obj.file_sys_path:
|
||||
continue
|
||||
guid = gpo_obj.name
|
||||
path = check_safe_path(gpo_obj.file_sys_path).upper()
|
||||
version = gpo_version(lp, path)
|
||||
if version != store.get_int(guid):
|
||||
logger.info('GPO %s has changed' % guid)
|
||||
changed_gpos.append(gpo_obj)
|
||||
if force:
|
||||
changed_gpos = gpos
|
||||
gp_db.state(GPOSTATE.ENFORCE)
|
||||
else:
|
||||
changed_gpos = []
|
||||
for gpo_obj in gpos:
|
||||
if not gpo_obj.file_sys_path:
|
||||
continue
|
||||
guid = gpo_obj.name
|
||||
path = check_safe_path(gpo_obj.file_sys_path).upper()
|
||||
version = gpo_version(lp, path)
|
||||
if version != store.get_int(guid):
|
||||
logger.info('GPO %s has changed' % guid)
|
||||
changed_gpos.append(gpo_obj)
|
||||
gp_db.state(GPOSTATE.APPLY)
|
||||
|
||||
store.start()
|
||||
for ext in gp_extensions:
|
||||
|
@ -46,6 +46,8 @@ if __name__ == "__main__":
|
||||
action='store_true')
|
||||
parser.add_option('--target', default='Computer', help='{Computer | User}',
|
||||
choices=['Computer', 'User'])
|
||||
parser.add_option('--force', help='Reapplies all policy settings',
|
||||
action='store_true')
|
||||
parser.add_option_group(credopts)
|
||||
|
||||
# Set the options and the arguments
|
||||
@ -85,7 +87,7 @@ if __name__ == "__main__":
|
||||
gp_extensions.append(ext(logger, lp, creds, store))
|
||||
|
||||
if not opts.unapply:
|
||||
apply_gp(lp, creds, logger, store, gp_extensions)
|
||||
apply_gp(lp, creds, logger, store, gp_extensions, opts.force)
|
||||
else:
|
||||
unapply_gp(lp, creds, logger, store, gp_extensions)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user