[PATCHES] rename samba_gpoupdate to gpupdate

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Wed Jul 11 05:32:00 UTC 2018


On 07/07/18 01:57, David Mulder via samba-technical wrote:
 
> Douglas, I'm hoping to get the patches from merge requests 8, 10, and 15
> into 4.9. Merge request 16 can wait. You and Andrew have already
> reviewed 8 and 10, so these are likely ready to merge (and are not
> dependent on 15 or 16 to merge).

OK, I have reviewed 8 and a bit of 10 and re-pushed here:

https://gitlab.com/samba-team/samba/merge_requests/27

with the following inserted in "gpo: Read GPO versions locally, not from sysvol":

-FILE_ATTRIBUTE_DIRECTORY = 0x10
+
 def cache_gpo_dir(conn, cache, sub_dir):
     loc_sub_dir = sub_dir.upper()
+    local_dir = os.path.join(cache, loc_sub_dir)
     try:
-        os.makedirs(os.path.join(cache, loc_sub_dir), mode=0o755)
+        os.makedirs(local_dir, mode=0o755)
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise
     for fdata in conn.list(sub_dir):
-        if fdata['attrib'] & FILE_ATTRIBUTE_DIRECTORY:
+        if fdata['attrib'] & smb.FILE_ATTRIBUTE_DIRECTORY:
             cache_gpo_dir(conn, cache, os.path.join(sub_dir, fdata['name']))
         else:
             local_name = fdata['name'].upper()
-            with open(os.path.join(cache, loc_sub_dir, local_name), 'w') as f:
-                fname = os.path.join(sub_dir, fdata['name']).replace('/', '\\')
-                f.write(conn.loadfile(fname))
+            f = NamedTemporaryFile(delete=False, dir=local_dir)
+            fname = os.path.join(sub_dir, fdata['name']).replace('/', '\\')
+            f.write(conn.loadfile(fname))
+            f.close()
+            os.rename(f.name, os.path.join(local_dir, local_name))
+
 
That is, the write here should be atomic too, and it is better to use the
FILE_ATTRIBUTE_DIRECTORY constant from a module than invent our own one.

If I got that bit right it should pass CI shortly.

More tomorrow.

cheers,
Douglas



More information about the samba-technical mailing list