Bug 14177 - Overwriting and renaming hidden files doesn't clear the hidden attribute
Summary: Overwriting and renaming hidden files doesn't clear the hidden attribute
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: 4.11.1
Hardware: All Linux
: P5 major (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
Depends on:
Reported: 2019-10-30 16:18 UTC by Kacper
Modified: 2019-10-30 16:48 UTC (History)
1 user (show)

See Also:

Network trace (9.96 KB, application/vnd.tcpdump.pcap)
2019-10-30 16:18 UTC, Kacper
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kacper 2019-10-30 16:18:09 UTC
Created attachment 15587 [details]
Network trace


I've stumbled upon another bug most likely related to #14137. It seems that a simple python script like the one below makes samba not to clear the hidden dos attribute of a previously created dot file.

This only happens when the file that is going to overwrite another file has the permission 444 (r--r--r--).

How to reproduce:
1. Mount a Samba 4.11 share using the mount command: mount
//server1/share /tmp/share1
2. Run python script:

	import shutil
	import tempfile
	import os

	tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=b'.file_tmp',
	dir='/tmp/share', suffix='test.pdf')

	shutil.copy2('testfile', tmp_dest_name)
	os.rename(tmp_dest_name, "/tmp/share/testfile")

Expected results:
Temporary file created by mkstemp should be renamed to testfile and no longer have the hidden dos attribute.

The mount command is: mount //localhost/share /tmp/share -o username=Administrator