Old 12th March 2008, 12:38   #1
Daniel James
Junior Member
 
Join Date: Feb 2008
Location: Near London, UK
Posts: 40
Odd AccessControl error

I'm using the AccessControl plugin to set the rights on a data directory set up by my installer. The directory is freshly-created and known to exist, so the user running install will be its "CREATOR OWNER" and should have authority to set the access.

However, I'm occasionally -- not always, but I haven't spotted a trend -- getting error "22" returned. Looking at the source for the plugin I see that errors are usually textual, and that "22" doesn't seem to be one of them!

Here's the code snippet:
code:

; create the data directory
ClearErrors
CreateDirectory "$MBDir"

${If} ${Errors}
Abort "Can't create MessageBase directory $MBDir"
${EndIf}

; Set access permissions on $MBDir -- read write accessible by all users
; We have to use "(S-1-1-0)" instead of "World" or "(WD)" for Win2k
ClearErrors
AccessControl::GrantOnFile "$MBDir" "(S-1-1-0)" "GenericRead + GenericWrite + DeleteChild"
pop $0

${If} $0 != ""
MessageBox MB_OK "Error $0 granting access to $MBDir "
${EndIf}


The message I'm getting in the message box is typically something like "Error 22 granting access to E:\MyApp\Data ". The directory name is correct, and the directory has been created.

Can anyone tell me what this actually means? I take it I am calling the plugin correctly, and that GrantOnFile is meant to be usable on directories as well as normal files?

The Windows error code 22 is ERROR_BAD_COMMAND which is documented as meaning "The device does not recognize the command". I believe that's normally returned by IOCtl-type calls to devices, and not by access control APIs.

I'm testing this on XP64, BTW, but it's intended to be usable on all NT-class systems.

Cheers,
Daniel
Daniel James is offline   Reply With Quote
Old 13th March 2008, 10:26   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
AccessControl does not push anything to the stack if there were no errors. Therefore your value in $0 is coming from a stack item that was already on the stack before you called the plug-in.

I will change this in the next version.

Stu
Afrow UK is offline   Reply With Quote
Old 13th March 2008, 15:05   #3
Daniel James
Junior Member
 
Join Date: Feb 2008
Location: Near London, UK
Posts: 40
Quote:
Originally posted by Afrow UK
AccessControl does not push anything to the stack if there were no errors. Therefore your value in $0 is coming from a stack item that was already on the stack before you called the plug-in.

I will change this in the next version.
OK, thanks, Stu ... that makes sense.

What's the best workaround? Is there any other indication of an error -- way to tell whether anything has been pushed onto the stack -- apart from calling pop?

I could do something like:
code:

ClearErrors
Push "OK"
AccessControl::GrantOnFile "$MBDir" "(S-1-1-0)" "GenericRead + GenericWrite + DeleteChild"
pop $0

${If} $0 != "OK"
MessageBox MB_OK "Error $0 granting access to $MBDir "
pop $0 ; remove the "OK"
${EndIf}


Can you think of anything better?

Cheers,
Daniel.

Cheers,
Daniel
Daniel James is offline   Reply With Quote
Old 13th March 2008, 17:23   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
That is what I was doing until I decided to start updating the plug-in myself.

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump