Re: [launchd-dev] launchd-dev Digest, Vol 41, Issue 5
Per, The method I use is to get the version number of the installed tool and compare it against the version in the app bundle. Since we know that SMJobBless installs the helper executable in /Library/PrivilegedHelperTools, you can create the URL to /Library/PrivilegedHelperTools/com.yourdomain.yourapp.helper and use NSBundle's + bundleWithURL: method and then call - infoDictionary (or similarly use CFBundleCopyInfoDictionaryForURL) to get the helper tool's info dict. You can then query the dictionary for its version, and decide whether to prompt for blessing rights. HTH, Richard On Mon, Nov 15, 2010 at 10:00, <launchd-dev-request@lists.macosforge.org> wrote:
From: Per Ejeklint <ejeklint@me.com> To: launchd-dev@lists.macosforge.org Date: Mon, 15 Nov 2010 11:21:07 +0100 Subject: [launchd-dev] Not calling SMJobBless if not needed? This is slightly off-topic I guess but the expertise is definitely on this list. :)
I'm using SMJobBless to install and update a launchd daemon from my app and it works like a charm. Only thing is that the user must authenticate at every launch of the app and not just when the provided daemon is actually newer than the running one. Is there a way work around this with ServiceManagement framework? Or another simple way? I'm new to this part of Mac OS X stuff, so I apologize if I'm posting to the wrong list.
/Per
OK, I get the idea, Thanks. Can't get it to work though. Here's example code: NSString *installedToolPath = [[NSString alloc] initWithFormat:@"file://Library/PrivilegedHelperTools/se.ejeklint.mytool"]; NSDictionary *installedToolDict = [[NSBundle bundleWithURL:[NSURL URLWithString:installedToolPath]] infoDictionary]; and I get a NULL dictionary back. Same goes for the tool embedded in my app. URLs are ok. I have the link flag like this: -sectcreate __TEXT __info_plist "$(SRCROOT)/daemon-info.plist" What have I missed? /Per 17 nov 2010 kl. 16.01 skrev Richard Brown:
Per, The method I use is to get the version number of the installed tool and compare it against the version in the app bundle. Since we know that SMJobBless installs the helper executable in /Library/PrivilegedHelperTools, you can create the URL to /Library/PrivilegedHelperTools/com.yourdomain.yourapp.helper and use NSBundle's + bundleWithURL: method and then call - infoDictionary (or similarly use CFBundleCopyInfoDictionaryForURL) to get the helper tool's info dict. You can then query the dictionary for its version, and decide whether to prompt for blessing rights. HTH, Richard
On Mon, Nov 15, 2010 at 10:00, <launchd-dev-request@lists.macosforge.org> wrote:
From: Per Ejeklint <ejeklint@me.com> To: launchd-dev@lists.macosforge.org Date: Mon, 15 Nov 2010 11:21:07 +0100 Subject: [launchd-dev] Not calling SMJobBless if not needed? This is slightly off-topic I guess but the expertise is definitely on this list. :)
I'm using SMJobBless to install and update a launchd daemon from my app and it works like a charm. Only thing is that the user must authenticate at every launch of the app and not just when the provided daemon is actually newer than the running one. Is there a way work around this with ServiceManagement framework? Or another simple way? I'm new to this part of Mac OS X stuff, so I apologize if I'm posting to the wrong list.
/Per
On 17 Nov 2010, at 15:01, Richard Brown wrote:
The method I use is to get the version number of the installed tool and compare it against the version in the app bundle.
The way that I recommend you do this is to ask the tool for its version via whatever IPC mechanism you use to talk to the tool in the first place. This avoids you having to code knowledge of the file system layout into your client. BetterAuthorizationSample shows the basic idea (search for kSampleGetVersionResponse), although it doesn't use the resulting info to drive an update. <http://developer.apple.com/library/mac/#samplecode/BetterAuthorizationSample> S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (3)
-
Per Ejeklint
-
Quinn "The Eskimo!"
-
Richard Brown