[PATCHES] rename samba_gpoupdate to gpupdate

David Mulder dmulder at suse.com
Wed Jul 11 13:25:20 UTC 2018


Nice work Douglas, thank you.


On 07/10/2018 11:32 PM, Douglas Bagnall wrote:
> 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
>

-- 
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)




More information about the samba-technical mailing list