I have several plugins that use on-the-fly generation of text scripts expected to be executed by osascript interpreter.
That worked fine up through Snow Leopard, but Lion usually disallows such stuff.
Any ideas for work-around?
Rob
Nothing specific, sorry. Is there a way that you could write a static script that gets authorised somehow, and have it read configuration from a file instead? Or maybe its the location being written to (/tmp ?) that doesn't support execution of scripts?
But when testing ideas for a work around I'd suggest making sure it can work in a sandboxed environment. Now that there is a Mac App Store version of Lightroom I suspect it will only be a matter of time before Apple force them to have it run in sandboxed mode.
Matt
Example script (for saving metadata):
"osascript" -e 'tell application "Lightroom" to activate' -e 'tell application "System Events"' -e 'key down command' -e 'keystroke "s"' -e 'key up command' -e 'end tell'
and the error code: 256 (returned by osascript interpreter).
I have assumed the problem was related to security, but I suppose it could be syntax or some other incompatibility (reminder: exact same script has been working for years previously...)
It could very well be that compiling the script(s) into app(s) would solve the problem. e.g. no problems executing exiftool from plugins.
Since scripts are not being written to disk I don't see how disk permissions (e.g. /tmp) would be a factor, unless such writing is implicit...
How does one "make sure it works in a sandboxed environment"?
Rob
Rob Cole wrote:
How does one "make sure it works in a sandboxed environment"?
I'd suggest reading up about Mac's sandbox and temporary exception entitlements.
I haven't seen anyone say that the Mac App Store version of Lightroom will become sandboxed but I can't see how they will be able to avoid it. If you are going to be reworking this part of your code anyway it wouldn't hurt to think ahead.
Matt
So, the Mac App Store version can't launch any external scripts? Can anyone confirm that? Can I somehow emulate the App Store version's sandboxing features with sandbox-exec?
I have a plugin that does keyboard stuffing (http://www.capturemonkey.com/excessor), it's working fine on Lion and Mountain Lion, but I only have regular downloadable version of Lightroom. I'm not too eager to purchase another copy just for testing...
To be clear, I am certain that the Lightroom 4.1 MAS version is not
sandboxed. So the problems you are experiencing are likely to do with the
operating system upgrade only.
I was advising Rob that if he changes code he should future proof it to
work in a sandboxed environment. I suspect that a future version will be
forced by Apple to introduce sandboxing so might as well get ahead of the
curve while making any change.
I am not aware of any way to simulate a sandboxed MAS version without
having purchased the MAS version first. Sorry.
Matt
Thanks Matt,
So next question is:
Why does it work on some (Lion) systems, but not others?
And of course:
* Is it possible for the user to change system config so that it works, and for the sake of completeness:
* Is it possible for the plugin programmer to change code so that it always works...
Rob
I don't have much experience with Mac, and none with Lion, so can't give
you any definitive answers.
It is possible Lion has introduced some additional security around the
functionality you are relying upon and that is causing the issues you are
seeing. It might be the MAS version that is hitting the issue but is a Lion
triggered issue and not an LR sandboxing one. Pretty sure I read somewhere
there were malware related features in Lion. I wouldn't be surprised if key
press stuffing and dynamic scripts were viewed with suspicion by such a
feature.
Matt
Rob, are you seeing this behaviour yourself, or has one of your users reported it? Are you getting multiple reports or just single incident?
I haven't heard of any problems with Lion keyboard shortcuts with my plugins, but there isn't that many users with OS X 10.7.
I find it hard to believe that there would be issues with dynamic scripts, maybe there's a hidden switch to adjust System Events permissions somewhere (and someone has non-default configuration...)
BTW. My plugin skips the Lightroom activate part, since its invoked from menu, I'm expecting Lightroom to be already active
Jarno
Hi Jarno,
I have not seen it myself, but a couple of clients have reported it.
You could be on to something - might have nothing to do with text osascript execution, and be more about the "activate" part.
I'll consider making a change for testing.
If you would try for me on your Lion system, ChangeManager. On File Menu / Plugin Extras, choose Lock. That will attempt to save metadata using "Cmd-S".
If it's not obvious from the log file what happened, enable "Verbose Logging" in top section of plugin manager.
Thanks bunches,
Rob
Here's the logfile
| 2012-07-30 20:09:26 +0000, INFO | Locking one photo |
| 2012-07-30 20:09:26 +0000, INFO | 1 photo photos under consideration for snapshot and/or mark... |
| 2012-07-30 20:09:26 +0000, DEBUG | Main style: RC Finished, Summarized |
| 2012-07-30 20:09:26 +0000, DEBUG | Snapshotted /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF with Master 2012-07-30 23:09:26 Locked (test) |
| 2012-07-30 20:09:26 +0000, DEBUG | Lens profile corrections are defined, but disabled. |
| 2012-07-30 20:09:26 +0000, DEBUG | Marked edit history of /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF with details: no adjustments |
| 2012-07-30 20:09:26 +0000, DEBUG | Marked edit history of /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF with profile: Adobe Standard |
| 2012-07-30 20:09:26 +0000, DEBUG | Marked edit history of /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF with snap: Master 2012-07-30 23:09:26 Locked (test) |
| 2012-07-30 20:09:26 +0000, DEBUG | snapshotted and/or marked /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF |
| 2012-07-30 20:09:26 +0000, ERROR | ****** ERROR #2: Unable to lock /Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.ORF because Non-zero exit code returned by command: "chmod" a+w "/Volumes/dada/Pictures/2012/2012-07/2012-07-15/_7150537.xmp", exit-code: 256 |
| 2012-07-30 20:09:26 +0000, INFO | Finalizing to lockage of 0 photos... |
| 2012-07-30 20:09:26 +0000, DEBUG | Previous lib filter table restored. |
| 2012-07-30 20:09:26 +0000, DEBUG | Previous lib filter table restored. |
| 2012-07-30 20:09:26 +0000, DEBUG | Background state changed to: running |
| 2012-07-30 20:09:26 +0000, INFO | 0 photos locked. |
I'm not seeing any mention of osascript, and the chmod probably fails because the XMP is not generated.
From commandline, osascript code mentioned before works fine (I'm seeing the warning dialog, because I clicked reset-all-warnings buttons just to be sure)
I'm guessing its problem with your code, but i didn't understand the stuff enough to add more logging :-)
Still, I'm not buying this as a wide spread problem. It's definately not a SDK problem anyway.
Perhaps the users system is just misconfigured, or could use the magic of Disk Utility's repair permissions. Error code 256 indicates a file access error, perhaps they have wrong permissions under /System/Library/CoreServices/System Events.app or something...
North America
Europe, Middle East and Africa
Asia Pacific