gorakhargosh / watchdog

Python library and shell utilities to monitor filesystem events.
http://packages.python.org/watchdog/
Apache License 2.0
6.64k stars 698 forks source link

File on SMB gets invalid permissions when created in an observed folder #1080

Open cmantsch opened 1 month ago

cmantsch commented 1 month ago

I have a SMB share mounted on a linux server (Server 1). On this server, a bash script that touches a .txt file is executed.

On a second linux server (Server 2), the same share is mounted and a python program is observing the directory using PollingObserver with PatternMatchingEventHandler for .txt files.

First time, the script runs fine, but second time it fails as follows:

user@server1:~$ cat test-heartbeat.sh
rm -f /mnt/mysmb/heartbeat.txt
touch /mnt/mysmb/heartbeat.txt
ls -l /mnt/mysmb/heartbeat.txt

user@server1:~$ sudo bash test-heartbeat.sh
-rwxr-xr-x 1 root root 0 Okt 10 09:35 /mnt/mysmb/heartbeat.txt

user@server1:~$ sudo bash test-heartbeat.sh
touch: cannot touch '/mnt/mysmb/heartbeat.txt': No such file or directory
ls: cannot access '/mnt/mysmb/heartbeat.txt': No such file or directory

user@server1:~$ ls -l /mnt/mysmb/heartbeat.txt
-rwxr-xr-x 1 root root 0 Okt 10 09:35 /mnt/mysmb/heartbeat.txt

user@server1:~$ sudo bash test-heartbeat.sh
touch: cannot touch '/mnt/mysmb/heartbeat.txt': No such file or directory
ls: cannot access '/mnt/mysmb/heartbeat.txt': No such file or directory

user@server1:~$ ls -l /mnt/mysmb/heartbeat.txt
ls: cannot access '/mnt/mysmb/heartbeat.txt': No such file or directory

Also, when checking the file properties on a windows machine, the file has invalid permissions (every access in this whole process is done using the same AD user on SMB): Bildschirmfoto 2024-10-09 um 22 17 09

All of this only occurs when there is an active observer watching the directory and only for extensions in the specified patterns.

Is this some known issue?