[Samba] CreateFile for EXE images vs other files

Jeremiah Gowdy jeremiah at freedomvoice.com
Wed Sep 24 18:13:51 GMT 2003


This question isn't directly Samba related, but Samba has helped me figure out part of the problem.  When I CreateFile on an existing file like so:

CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

Samba shows that I have the file opened with this type of lock

DENY_NONE  0x20089     RDONLY

When the file is locked in this manner, I am unable to rename the file.

However, Windows launches executables over Samba shares with the lock:

DENY_WRITE 0x20        RDONLY

I have tried to mimic this lock using GENERIC_READ with FILE_SHARE_READ:

DENY_WRITE 0x20089     RDONLY

and with GENERIC_EXECUTE with FILE_SHARE_READ

DENY_WRITE 0x200a0     RDONLY

and by simply putting the constant value FILE_EXECUTE

DENY_WRITE 0xa0        RDONLY

It seems like something is automatically ORing in FILE_READ_ATTRIBUTES into my desired_access, since FILE_EXECUTE is 0x20 and FILE_READ_ATTRIBUTES is 0x80.


My goal is simply to open a file, read only, deny write, but allowing others to rename the file.  Windows does this when you open an EXE and the lock is 

DENY_WRITE 0x20        RDONLY

then file renames are possible.

Thank you for any information you can provide.


________________________________________

Jeremiah Lee Gowdy
Senior Software Engineer
FreedomVOICE Systems

E-mail: jeremiah at freedomvoice.com
Phone: 800-477-1477 Ext. 804
________________________________________



More information about the samba mailing list