Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mehdies

macrumors member
Original poster
Jun 10, 2012
41
0
I have a daemon with source code.this daemon run with :
Code:
launchctl load /Library/LaunchDaemons/deamon.plist
How can i debug that?
 

mehdies

macrumors member
Original poster
Jun 10, 2012
41
0
Debug what? The "deamon.plist" you didn't post, or the daemon source code you didn't post?
.plist source code.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Disabled</key>
	<false/>
	<key>Label</key>
	<string>com.daemon.user</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Application Support/daemon.app/Contents/MacOS/daemon</string>
	</array>
	<key>UserName</key>
	<string>root</string>
</dict>
</plist>


----------

I must be debug daemon in Xcode.with breakpoint.or logging messages to console.


Thanks
 

chown33

Moderator
Staff member
Aug 9, 2009
10,706
8,346
A sea of green
.plist source code.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Disabled</key>
	<false/>
	<key>Label</key>
	<string>com.daemon.user</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/Library/Application Support/daemon.app/Contents/MacOS/daemon</string>
	</array>
	<key>UserName</key>
	<string>root</string>
</dict>
</plist>
What user owns the program being run as a daemon? If it's not root, then launchd may not launch it.

Also, what are the read/write permissions on the directories leading to the executable? What about on the executable itself?


Exactly what have you read about making daemons? Be specific.

The central Apple document is this:
http://developer.apple.com/library/...al/BPSystemStartup/Chapters/Introduction.html

TN2083 also contains a wealth of information.

If you haven't read either document, you should do so.

From TN2083, under the heading title "Daemon Security Considerations":
When you install your daemon, make sure that you set the file system permissions correctly. Apple recommends that daemons be owned by root, have an owning group of wheel, and use permissions 755 (rwxr-xr-x) for executables and directories, and 644 (rw-r--r--) for files. In addition, every directory from your daemon up to the root directory must be owned by root and only writable by the owner (or owned by root and sticky). If you don't do this correctly, a non-admin user might be able to escalate their privileges by modifying your daemon (or shuffling it aside).



I must be debug daemon in Xcode.with breakpoint.or logging messages to console.
You should test and debug your program before trying to run it as a launch daemon. If it can only run with root privileges, then make a shell script that will run it as root, and test it that way.

You should also test and debug your plist by having it run a safe program that does nothing.

After both things have been tested and confirmed to work separately (your program and your plist), you can run your program as a launch daemon and confirm it works in that environment.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.