bibikurosawa / dokan

Automatically exported from code.google.com/p/dokan
0 stars 0 forks source link

can't run an executable file in Dokan drive #209

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Run Dokan mirror example and mount a drive
2. Copy an executable file to the Dokan drive (Ex. C:\Windows\write.exe)
3. Run the executable file in Dokan drive

What is the expected output? What do you see instead?

Expected : The program is launched
Actual: The error message "The system cannot execute the specified program" is 
shown.

Please use labels and text to provide additional information.

I found a work around of this issue. If you specify DOKAN_OPTION_REMOVABLE when 
calling DokanMain, the program is launched without any issue.

Original issue reported on code.google.com by asa...@gmail.com on 11 Feb 2011 at 3:23

GoogleCodeExporter commented 9 years ago
But will using "DOKAN_OPTION_REMOVABLE" will prevent the mounted drive 
directories from being shared ?

Original comment by smurf...@gmail.com on 11 Feb 2011 at 3:44

GoogleCodeExporter commented 9 years ago
I did some further experiments as to what causes the problem.

When launching the executable GetFileSecurity is called several times, and at 
least once with all the flags for SECURITY_INFORMATION set. Part of the problem 
appears to be that an application which is not running as the SYSTEM user can 
not actually query all that information, so the call fails. The particular 
information that cannot be queried is SACL_SECURITY_INFORMATION. So part of a 
fix I have here involves masking out that bit. This basically just pretends the 
information was never asked for.

That said, I still cannot retrieve the security information using 
GetUserObjectSecurity as the mirror sample is doing right now. This appears to 
fail for me all the time. However, if I use GetFileSecurity itself instead (and 
leave out SACL_SECURITY_INFORMATION as mentioned above) things appear to work.

Is GetUserObjectSecurity supposed to work? Is there a particular reason for 
using this instead of GetFileSecurity()?

Original comment by jkats...@nixxes.com on 12 Feb 2011 at 6:28

GoogleCodeExporter commented 9 years ago
@JK
1) Are you using your own implementation ?
2) Are you saying that Dokan is sending the requests through to the 
GetFileSecurity call for SACL_SECURITY_INFORMATION
3) Are you sugesting another API to route the GetUserObjectSecurity ?
4) Are you saying that the mirror example is working ?
5) What OS are you using ?
Some of these might have ben answered in the general email, but I want them 
here for reference please.

Original comment by smurf...@gmail.com on 14 Feb 2011 at 7:19

GoogleCodeExporter commented 9 years ago
1) No, I am starting from the Mirror sample and an out of the box Dokan 0.6.

2) The OS is performing GetFileSecurity calls including the 
SACL_SECURITY_INFOMRATION flag, Dokan (correctly, I would argue) sends these 
along to the mirror example. However, the mirror example, being an application 
not running as the system user, does not have sufficient access rights to query 
these.

3) I am suggesting to implement MirrorGetFileSecurity using GetFileSecurity. It 
is not clear to me why the current Mirror code is using GetUserObjectSecurity.

4) No, mirror does not work. It uses GetUserObjectSecurity which I can't get to 
work either way, and when modififed to use GetFileSecurity it still doesn't 
work because of SACL_SECURITY_INFORMATION, so it requires this to be masked 
away to work.

5) Windows 7 64-bit

I am not very familiar yet with the Dokan development process. Is there a way 
to submit patches/fixes, either directly or for review? I could submit the 
modification to Mirror that allows it to work again.

Original comment by jkats...@nixxes.com on 14 Feb 2011 at 8:50

GoogleCodeExporter commented 9 years ago
?? It all seems to have gone quiet ??
@JK
1) Have you tried running the MirrorSample as Administrator ?
2) Have you tried this on any other OS Yet ?

Original comment by smurf...@gmail.com on 8 Mar 2011 at 8:13

GoogleCodeExporter commented 9 years ago
We did originally try it on Windows XP, and the problem does not exist there. I 
do not know and do not have the ability to test on Vista. I suspect it would be 
the same as on Windows 7, but can't be sure.

Running as Administrator was tried, but doesn't actually work. The 
Administrator user apparently does not have access to 
SACL_SECURITY_INFORMATION, only the System user has this access. I suspect that 
if the DokanDrive would run as as a Windows Service, which would cause it to 
run as the System user, it would potentially work, at least when using 
GetFileSecurity.

Either way, as I mentioned before, I have a change that effectively fixes it. 
But again, I do not actually know what the process is for bringing fixes back 
into the main Dokan codebase.

Original comment by jkats...@nixxes.com on 8 Mar 2011 at 8:22

GoogleCodeExporter commented 9 years ago
We also need a solution to get it to work in DokanNet as there's no 
Get/Set_FileSecurity methods in IDokanOperations

Original comment by scratch....@gmail.com on 30 May 2011 at 4:46

GoogleCodeExporter commented 9 years ago
I just ran into this problem!
A dialog box with the message "The parameter is incorrect" is displayed when I 
try to execute an exe. Using RemovableDrive = true doesn't solve the problem.

Has anyone found a workaround and is willing to share it? (@JK?)

I am using the .Net client on Win7 64bit.

Original comment by huwsimp...@gmail.com on 6 Jul 2011 at 4:20

GoogleCodeExporter commented 9 years ago
Can Confirm that just masking out the SACL_SECURITY_INFORMATION and running as 
a service works:-)
see http://liquesce.wordpress.com/2011/10/05/liquesce-and-file-security/ for 
pictures

Original comment by smurf...@gmail.com on 5 Oct 2011 at 6:54

GoogleCodeExporter commented 9 years ago
so how 'd you do that? Can you post some code? 

Original comment by scratch....@gmail.com on 6 Oct 2011 at 12:54

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
could we also have a look at your (jkats...)implementation ?
it might help me solve my problem.

Original comment by eugenj...@gmail.com on 22 Oct 2011 at 6:55

GoogleCodeExporter commented 9 years ago
could we also have a look at your (jkats...)implementation ?
it might help me solve my problem.

Original comment by eugenj...@gmail.com on 22 Oct 2011 at 6:56

GoogleCodeExporter commented 9 years ago
I have completely removed the code that used to PInvoke down to Win32 calls, 
and in so doing, also fixed the calls into SACL_SECURITY_INFORMATION. I use 
nothing but C# and also impersonate the user to ensure accurate results.
Currently there is a problem with XP and the service allowing access to 
directories it shouldn't. But in on Win7x64 it's as expected :-)
The history for both the PInvoke, and the C# implementations are in my GPL 
project @ http://Liquesce.codeplex.com

Original comment by smurf...@gmail.com on 28 Oct 2011 at 2:28

GoogleCodeExporter commented 9 years ago
I'm working on a fuse implementation for windows based on dokan and an existing 
(and seemingly abandoned) fuse for windows code plus some fixes from Fredi's 
encfs4win tree on top.

I have just hit this bug and specifying DOKAN_OPTION_REMOVABLE fixed it, 
however I am not particularly fond of this, since I'd like to understand the 
core of this change in Dokan and properly address it. If 
{Set,Get}FileSecurity() callbacks need to be implemented, I'll happily add 
those. What's the status on this issue?

Original comment by rnib...@gmail.com on 18 Nov 2012 at 4:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm a user of encfs4win, which uses Dokan. I landed up with the same problem on 
Win 7 x64, i.e., when an executable is run from a Dokan drive, the error 
message "Windows cannot access the specified device, path, or file. You may not 
have the appropriate permissions to access them." pops up, and I can't run the 
executable. But I can copy the same file from the Dokan drive to a "normal" 
directory (say the Desktop) and execute the file from there. 

Has this issue been resolved ? If yes, how can I get the fix ? If not, can I do 
anything to help ?

Original comment by sagarsp...@gmail.com on 9 Jul 2014 at 3:34

GoogleCodeExporter commented 9 years ago
I've managed to fix it partially by removing SACL from SecurityInformation AND 
CreateFile with READ_CONTROL , I don't know why but AccessMode for handle 
doesn't have READ_CONTROL that is required to get XXX_SECURITY_INFORMATION:

in MirrorGetFileSecurity():

if (*SecurityInformation & SACL_SECURITY_INFORMATION)
{
    *SecurityInformation -= SACL_SECURITY_INFORMATION;
}
HANDLE localHandle = CreateFile(filePath, READ_CONTROL, FILE_SHARE_READ, NULL, 
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);

if (!GetUserObjectSecurity(localHandle, SecurityInformation, 
SecurityDescriptor, BufferLength, LengthNeeded)) {...}

CloseHandle(localHandle);

+ manifest or Run As Administrator

partially , because I still can't run some EXE file 
Example :
 CAn't run DokanInstall_0.6.0.exe
 But can run PsExec.exe

Original comment by Vladimir...@gmail.com on 8 Aug 2014 at 2:43