samba-tool: Move create_directory_hier to a common file
authorDavid Mulder <dmulder@samba.org>
Wed, 7 Dec 2022 18:27:00 +0000 (11:27 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 30 Jan 2023 09:00:39 +0000 (09:00 +0000)
This is in preparation for needing it here later.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/gpcommon.py [new file with mode: 0644]
python/samba/netcmd/gpo.py

diff --git a/python/samba/netcmd/gpcommon.py b/python/samba/netcmd/gpcommon.py
new file mode 100644 (file)
index 0000000..f578b94
--- /dev/null
@@ -0,0 +1,26 @@
+# Samba common group policy functions
+#
+# Copyright Andrew Tridgell 2010
+# Copyright Amitay Isaacs 2011-2012 <amitay@gmail.com>
+#
+# 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/>.
+#
+
+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)
index d37276b1175aeadb3194650b9722300c5263e946..55da664d04d70861f44cf3ee4c723a1fa7621069 100644 (file)
@@ -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