hierynomus / smbj

Server Message Block (SMB2, SMB3) implementation in Java
Other
713 stars 180 forks source link

DiskShare.fileExists() always returning true on Netapp Ontap device #562

Closed kvk484 closed 4 years ago

kvk484 commented 4 years ago

DiskShare.fileExists() always returning true on Netapp Ontap device , even for folders.

hierynomus commented 4 years ago

Can you send a TCP dump for a file that does exist and one that does not?

kvk484 commented 4 years ago

Attached the req and response dump for both file and folder. smbclient machine : 10.75.154.146 smbserver machine : 10.65.40.9 tcp_req_resp_dump_File.txt tcp_req_resp_dump_folder.txt

ecki commented 4 years ago

That's a bit hard to decipher without protocol helpers, can you upload binary pcap files so we can open it in Wireshark. And also add two cases of missing entries (one where the parent dir exists and one where a non-terminal path component misses)

So if you Test existence for S,/x/a/b the following 4 scenarios:

s/x/a/b # file exists S/X/a/b/ # dir exists S/x/a/ # File missing, parent exists S/x/ # parent missing

kvk484 commented 4 years ago

dirExist.txt file_doesnt_exist_parent_exist.txt fileExsit.txt parent_doesnt_exist.txt

these are pcap files. just cahnged the ext,

kvk484 commented 4 years ago

Hi team, Is there any update on the issue. Did you get chance to analyze the pcap files provided? Thanks Chaitanya

hierynomus commented 4 years ago
CreateOpts Name Response Response file type
dirExist Non-Directory FS_SCAN/F1 STATUS_SUCCESS isDirectory
file_doesnt_exist_parent_exist Non-Directory FS_SCAN/F1/kvk123.txt STATUS_OBJECT_NAME_NOT_FOUND
fileExist Non-Directory FS_SCAN/288.csv STATUS_SUCCESS isFile
parent_doesnt_exist Non-Directory FS_SCAN/kvk5/kvk123.txt STATUS_OBJECT_PATH_NOT_FOUND
hierynomus commented 4 years ago

It seems that the NetApp OnTap device does not take the CreateOptions into account. I.e. In SMB you explicitly need to set whether you're CREATE-ing (opening) a file or directory. But the device seems to ignore this flag and returns STATUS_SUCCESS when the path exists, regardless of the type of the leaf element of the path.

Note that the responses for the non-existing cases are correct and lead to a false response on the fileExists call.

kvk484 commented 4 years ago

Thanks for replying. But folderExists api seems to be working fine. where create options are FILE_DIRECTORY_FILE.
1 question: If folderExists api for a path, throws smbapiexcpetion with status STATUS_NOT_A_DIRECTORY can we consider that path as file?