google / restor

Restor is a user-friendly application to (mass) image macOS computers from a single source
Apache License 2.0
228 stars 29 forks source link

Bundle the LaunchDaemon outside of the helper tool #44

Closed erikng closed 6 years ago

erikng commented 6 years ago

In my process of automating the Restor installation, I have put together the following:

  1. Install Restor.app to /Applications
  2. Install Restor.app/Contents/Library/LaunchServices/com.google.corp.restord to /Library/PrivilegedHelperTools
  3. Extract the LaunchDaemon out of the helper tool (manually), install it to /Libary/LaunchDaemons and load it.

I have created a custom package with a postinstall script to handle this, however I had an idea.

If you would be willing to bundle the LaunchDaemon at Restor.app/Contents/Library/LaunchServices and remove it from the helper tool, someone (myself) could easily write an autopkg recipe for Restor that automates this procedure.

Right now the LaunchDaemon is in the source code, however I have found that the helper tool adds some components to the launchdaemon that are not here - my assumption is this is injected into the helper tool when the build process is being created.

Since you already supply a signed DMG, the build process/helper tool would just need to be slightly modified to do this.

tburgin commented 6 years ago

I am struggling to understand why 1 and 2 are necessary? SMJobBless should handle all this for you. https://developer.apple.com/documentation/servicemanagement/1431078-smjobbless?language=objc

tburgin commented 6 years ago

The only thing I can think of is: allowing non-admins to launch Restor.

erikng commented 6 years ago

It's more of a I want Restor ready to go for them upon first launch rather than the first thing they have to do is authenticate their credentials. It's just one more step I have to document.

tburgin commented 6 years ago

Okay. Unfortunately SMJobBless does the generating of the launchd plist at runtime. The com.google.corp.restord binary does have an __launchd_plist section, but it is just merged into the actual plist that is created on our behalf.

⇒  launchctl plist __TEXT,__launchd_plist /Applications/Restor.app/Contents/Library/LaunchServices/com.google.corp.restord
{
    "StandardOutPath" = "/var/log/restord.log";
    "StandardErrorPath" = "/var/log/restord.log";
    "MachServices" = {
        "com.google.corp.restord" = true;
    };
    "Label" = "com.google.corp.restord";
};
⇒  defaults read /Library/LaunchDaemons/com.google.corp.restord
{
    Label = "com.google.corp.restord";
    MachServices =     {
        "com.google.corp.restord" = 1;
    };
    Program = "/Library/PrivilegedHelperTools/com.google.corp.restord";
    ProgramArguments =     (
        "/Library/PrivilegedHelperTools/com.google.corp.restord"
    );
    StandardErrorPath = "/var/log/restord.log";
    StandardOutPath = "/var/log/restord.log";
}

If you are after the launchd list, I think the best way is to do what you describe. Just copy it from /Library/LaunchDaemons/com.google.corp.restord. It is unlikely to change. However if it does it may be hard to track down. I would advise you to use Restor as is, letting SMJobBless do its job.

erikng commented 6 years ago

Fair enough. I'll not take that advice and watch the repo when new revisions take place, heh.

I'll make an internal only autopkg recipe so as not to potentially generate tickets on this repo. You can go ahead and close this ticket.

Thanks, Erik Gomez


From: Tom Burgin notifications@github.com Sent: Friday, August 10, 2018 4:20:52 PM To: google/restor Cc: Erik Gomez; Author Subject: Re: [google/restor] Bundle the LaunchDaemon outside of the helper tool (#44)

Okay. Unfortunately SMJobBless does the generating of the launchd plist at runtime. The com.google.corp.restord binary does have an __launchd_plist section, but it is just merged into the actual plist that is created on our behalf.

⇒ launchctl plist TEXT,launchd_plist /Applications/Restor.app/Contents/Library/LaunchServices/com.google.corp.restord { "StandardOutPath" = "/var/log/restord.log"; "StandardErrorPath" = "/var/log/restord.log"; "MachServices" = { "com.google.corp.restord" = true; }; "Label" = "com.google.corp.restord"; };

⇒ defaults read /Library/LaunchDaemons/com.google.corp.restord { Label = "com.google.corp.restord"; MachServices = { "com.google.corp.restord" = 1; }; Program = "/Library/PrivilegedHelperTools/com.google.corp.restord"; ProgramArguments = ( "/Library/PrivilegedHelperTools/com.google.corp.restord" ); StandardErrorPath = "/var/log/restord.log"; StandardOutPath = "/var/log/restord.log"; }

If you are after the launchd list, I think the best way is to do what you describe. Just copy it from /Library/PrivilegedHelperTools/com.google.corp.restord. It is unlikely to change. However if it does it may be hard to track down. I would advise you to use Restor as is, letting SMJobBless do its job.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/google/restor/issues/44#issuecomment-412209799, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFa_GN_VPqIz18mFIQrwwTipBEtG3WX1ks5uPfk0gaJpZM4V4t3d.

tburgin commented 6 years ago

Gotcha ;) Just a quick note: The changes will not show up in this repo. Say a future version of SMJobBless decides it wants to put the binary elsewhere on disk. Your launchd plist would be running an unexpected instance of com.google.corp.restord, which could lead to some odd / undefined behavior. I think this is unlikely, but worth noting.