RE: Snow Leopard osax security and 'run script' with parameters
RE: Snow Leopard osax security and 'run script' with parameters
- Subject: RE: Snow Leopard osax security and 'run script' with parameters
- From: Scott Babcock <email@hidden>
- Date: Thu, 3 Dec 2009 03:59:51 +0000
- Thread-topic: Snow Leopard osax security and 'run script' with parameters
Without using 'run script', how would you dynamically assemble a completely arbitrary script object?
Yes, the reference is carried into the 'run' handler. Unfortunately, the reference has been damaged in the process and can't be used for any productive purpose.
Specifying a TextEdit object reference as a 'run script' parameter without 'telling' TextEdit will result in an error (-1700 to be exact). The only way to avoid the error is to 'tell' TextEdit.
Here's the sequence:
1. The static script "tells" TextEdit to execute the 'run script' command on the dynamically assembled script code string
2. The new SL security model forbids the execution of 'run script' in any context besides the "current application" (AppleScript Editor)
3. The resulting privilege error (-10004) is suppressed and the 'run script' command is redirected to AppleScript Editor
4. AppleScript Editor executes the 'run script' command, compiling the script text and passing in the damaged object reference
5. The compiled script code attempts to make use of the damaged object reference and is met with failure
The reference is not owned - the object being referred to is. However, the reference includes the ownership specification.
Although it's not common, 'run' handlers are allowed to accept a single parameter of the 'list' variety. Why is this at issue?
Are you also asserting that a reference produced within the 'run script' context will encounter the same failure as one passed in as a parameter? Not likely.
I understand the Snow Leopard osax command context restrictions. It appears that the parameter passing behavior of 'run script' doesn't play well in this new security model.
Regarding domain of terminology, the subject of my post should make it clear that I understand 'run script' to be an osax command rather than a TextEdit command.
-----Original Message-----
From: Stockly, Ed [mailto:email@hidden]
Sent: Wednesday, December 02, 2009 1:21 PM
To: Scott Babcock; AppleScript Users
Subject: Re: Snow Leopard osax security and 'run script' with parameters
> Loaded script objects won't meet the objective to assemble script code on the
fly, since these are static, pre-compiled scripts rather than being dynamically
generated.
You can generate script objects on the fly and use them for dynamically
generated scripts. (Technically, you may actually be creating a script
object already) Check the archives.
>Also, the re-worked script doesn't make use of the reference. It's merely a
re-iteration of the first script with an extra unused parameter.
But the point is that the value of the parameter is carried into the run
handler. (But that's not really a parameter, its a list element inside a
parameter, see below).
This shows that both values are carried into the runhandler.
---
tell application "TextEdit"
set docRef to document 1
activate
set docRef to document 1
end tell
set theScript to "on run {X,y}" & return & "tell app \"TextEdit\" to set
text of document 1 to X" & return & "display dialog y as text " & return &
"end"
tell application "TextEdit" to run script theScript with parameters {"This
is the complex test.", text of docRef}
----
> The issue here appears to be related to the way that object references get
treated when they're specified as 'run script' parameters. Reference ownership
appears to be handed off to the current context:
No. A reference is a reference. They are free, not owned by anyone.
Run handlers generally don't have parameters. I believe they can take a
single parameter (just like open handlers) and in your script you are
passing a single parameter (a list with two elements).
Your run handler then distributes the list into a list of variables.
(as in: Set {x,y} to {1,2})
Put this inside your runhandler and you should get the same error:
tell application "TextEdit" to set docRef to document 1
> You'll see that the 'from' component of the event record indicates that the
reference is owned by the script, not TextEdit.
I don't have SN at work so I'll look at it this evening.
> tell application "TextEdit" to run script theScript with parameters {docRef}
You do not need to send the run script command to TextEdit. In fact apple's
Chris(x) will tell you explicitly not to do that.
Run script is an osax command, not a textedit command.
ES
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden