A mistake to avoid with launchctl

Posted:
in Genius Bar edited January 2014
This is just a FYI so people don't make the same mistake I did today.



If you install XCode 2.3 or later, you will see a process running in your computer called DNBOBSERVER which is meant for distributed builds. If you search the web for information on this, you are likely to be taken to a site where you are asked to execute a command



Quote:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dnbobserver.plist



Except that the website command has a white space between the directory name and the file name. If you cut & paste the same, it will run fine and launchctl will think you are passing it two params, so nothing is reported. What happens is that you disable all operating system daemons that are necessary. This will prevent your computer from booting up again.



Fixing it requires going into single user mode and editing all the plist files in the /System/Library/LaunchDaemons/ directory and changing the key value for "Disabled" from "true" to "false".



You don't need to enable the following services.



bootps.plist

com.apple.dnbobserver.plist

com.apple.dnbvolunteer.plist

com.apple.xgridagentd.plist

com.apple.xgridcontrollerd.plist

comsat.plist

distccd.plist

eppc.plist

exec.plist

finger.plist

ftp.plist

login.plist

nmbd.plist

ntalk.plist

org.isc.named.plist

printer.plist

shell.plist

smbd.plist

ssh.plist

swat.plist

telnet.plist

tftp.plist



Reboot after this and you still need to check system preferences->network options to make sure any unnecessary services are switched off.

Comments

  • Reply 1 of 5
    MarvinMarvin Posts: 14,584moderator
    Ouch. I hate to think what you used to edit the plist files in single user mode, Vi or something. I hate those command line text editors.



    I actually noticed this thing running too and I wondered what it was. It would be nice if these processes actually had a piece of text that explained what they did.



    Are you sure you needed to change the plist files manually? I would have thought from single user mode, all you'd do is sudo launchctl load /System/Library/LaunchDaemons. I can't think why it would have prevented booting either because you didn't specify the -w flag to write the settings to file.



    Launchd is just a replacement for rc and other things to speed things up. Plus, there aren't any files that take the Disabled flag in the Launchdaemons folder other than those you mentioned and they are off.
  • Reply 2 of 5
    I did the load of the files with the directory parameter in single user mode, but it didn't work as advertised. I was probably a bit too impatient and should have given the computer more time to boot up with all of those services, but it seemed to me that there was some IP stack issue when I tried to boot the full system with a /etc/rc in single user mode. I had to use Vim to edit the files with a vi *.plist which was OK. The last thing I wanted to do was to use SED or an equivalent to screw things further by trying to automate things. The one other thing I didn't want to compromise on was the security of the system by starting all these services which I don't need and some of them don't have a direct GUI interface in the System Preference pane.



    Launchd is great, they just need to add a command line option to specify directories instead of a single file so people don't accidently shoot themselves in the foot.



    http://lists.apple.com/archives/Xcod.../msg00839.html
  • Reply 3 of 5
    lundylundy Posts: 4,466member
    I believe the malformed launchctl command actually was a



    sudo launchctl unload -w



    Which sets the Launch Agent/Daemon to Disabled in addition to unloading it.
  • Reply 4 of 5
    Quote:
    Originally Posted by lundy


    I believe the malformed launchctl command actually was a



    sudo launchctl unload -w



    Which sets the Launch Agent/Daemon to Disabled in addition to unloading it.



    Yes, I missed out the -w option when I typed this in. I edited the post to reflect it.
  • Reply 5 of 5
    MarvinMarvin Posts: 14,584moderator
    Quote:
    Originally Posted by talksense101


    Yes, I missed out the -w option when I typed this in. I edited the post to reflect it.



    If you used the -w flag in single user mode is it possible you didn't mount the drive read/write first with mount -uw /? Also, for some reason, that link you posted used /Volumes/... to access the drive to load the processes back up. They managed to run it ok in single user mode too so it must work with directories.
Sign In or Register to comment.