From: David Mulder Date: Wed, 7 Dec 2022 18:27:00 +0000 (-0700) Subject: samba-tool: Move create_directory_hier to a common file X-Git-Tag: tevent-0.14.1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6194600c19e12a58686199ce65daa45367371f6;p=thirdparty%2Fsamba.git samba-tool: Move create_directory_hier to a common file This is in preparation for needing it here later. Signed-off-by: David Mulder Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/gpcommon.py b/python/samba/netcmd/gpcommon.py new file mode 100644 index 00000000000..f578b945cbf --- /dev/null +++ b/python/samba/netcmd/gpcommon.py @@ -0,0 +1,26 @@ +# Samba common group policy functions +# +# Copyright Andrew Tridgell 2010 +# Copyright Amitay Isaacs 2011-2012 +# +# 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 . +# + +def create_directory_hier(conn, remotedir): + elems = remotedir.replace('/', '\\').split('\\') + path = "" + for e in elems: + path = path + '\\' + e + if not conn.chkpath(path): + conn.mkdir(path) diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index d37276b1175..55da664d04d 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -77,6 +77,7 @@ from samba.ntstatus import ( NT_STATUS_OBJECT_PATH_NOT_FOUND, NT_STATUS_ACCESS_DENIED ) +from samba.netcmd.gpcommon import create_directory_hier def gpo_flags_string(value): @@ -382,14 +383,6 @@ def copy_directory_local_to_remote(conn, localdir, remotedir, conn.savefile(r_name, data) -def create_directory_hier(conn, remotedir): - elems = remotedir.replace('/', '\\').split('\\') - path = "" - for e in elems: - path = path + '\\' + e - if not conn.chkpath(path): - conn.mkdir(path) - def smb_connection(dc_hostname, service, lp, creds): # SMB connect to DC # Force signing for the smb connection