So, the test on my macbook from the previous post worked nicely. I contacted my supervisor to get his opinion on the method I decided upon. Porting this method over to the iPhone was a little messy but seems to be working nicely. Firstly, I set up my macbook as a central logging server. This was done by modifying the /etc/syslog.conf.
Firstly, we move the existing syslog.conf to a backup file to restore later:
mv /etc/syslog.conf /etc/syslog.conf.bak; touch /etc/syslog.conf
I then copy the following configuration into /etc/syslog.conf using an editor:
*.* /var/log/logclient.log
And finally, restart the syslog service:
launchctl unload /System/Library/LaunchDaemon/com.apple.syslog.plist
launch load /System/Library/LaunchDaemon/com.apple.syslog.plist
At this point, I opened up a terminal and ran tail -f /var/log/logclient.log to keep an eye (in real time) of the logs being generated (if any). Setting up the iPhone as a client was a different story. On OSX systems, the plist file (the configuration) file is stored as a plist at /System/Library/LaunchDaemons/com.apple.syslogd.plist in XML. However, on the iPhone, it’s stored as a binary file and the iOS base doesn’t include plutil to convert it back to XML for modification. To circumvent this problem, I decided to create my own config instead. This was done by creating a /etc/syslog.conf file and adding the following configuration:
*.* @192.168.1.100
To load this configuration, I restart syslog on the iPhone.
launchctl unload /System/Library/LaunchDaemon/com.apple.syslog.plist
launch load /System/Library/LaunchDaemon/com.apple.syslog.plist
Obviously, in the above, the IP of the central logging server (my macbook) is at 192.168.1.100. At this point, I generated some alerts by opening SMS, sending an email, launching a third-party application to ensure logs were being generated and sent over the network via syslog.
Jul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: MS:Notice: Installing: com.apple.MobileSMS [MobileSMS] (478.52)Jul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/MailToAttachmentMessageUI.dylibJul 15 16:33:34 192.168.1.102 abnev-ip1 UIKitApplication: com.apple.MobileSMS[0xe734][489]: MS:Warning: message not found [NSFileManager rawDirectoryContentsAtPath:]Jul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: *** _NSAutoreleaseNoPool(): Object 0x10c210 of class NSPathStore2 autoreleased with no pool in place – just leaking\nStack: (0x326edf87 0x326c2135 0x326c3bb3 0x326c4b15 0x326c47c3 0x326c4639 0x326c5f33 0x336079c5 0x33477b27 0x3347ce93 0x3347a245 0x33477a11 0x33477747 0x334784df 0x33477337 0x334774ef 0x47408 0x47a7c 0x43c14 0x2fe0be0d 0x2fe0be31 0x2fe09d7f 0x2fe0a16d 0x2fe01dd9 0x2fe08247 0x328c4975 0xa038 0x2fe0bd7d 0x2fe0be39 0x2fe09d7f 0x2fe0a16d 0x2fe0228b 0x2fe06a15 0x2fe016fd 0x2fe01050)Jul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: *** _NSAutoreleaseNoPool(): Object 0x10c710 of class NSPathStore2 autoreleased with no pool in place – just leaking\nStack: (0x326edf87 0x326c2135 0x326c3bb3 0x326c31a7 0x326c5b9d 0x326c46f3 0x326c5f33 0x336079c5 0x33477b27 0x3347ce93 0x3347a245 0x33477a11 0x33477747 0x334784df 0x33477337 0x334774ef 0x47408 0x47a7c 0x43c14 0x2fe0be0d 0x2fe0be31 0x2fe09d7f 0x2fe0a16d 0x2fe01dd9 0x2fe08247 0x328c4975 0xa038 0x2fe0bd7d 0x2fe0be39 0x2fe09d7f 0x2fe0a16d 0x2fe0228b 0x2fe06a15 0x2fe016fd 0x2fe01050)Jul 15 16:33:34 192.168.1.102 abnev-ip1 UIKitApplication: com.apple.MobileSMS[0xe734][489]: MS:Warning: message not found [MailComposeController _setupForMessageWithURL:]Jul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/WinterBoard.dylibJul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: WB:Notice: WinterBoardJul 15 16:33:34 192.168.1.102 abnev-ip1 MobileSMS[489]: MS:Notice: Loading: /Library/MobileSubstrate/DynamicLibraries/iNoRotate.dylib
logger.c:47: error: expected declaration specifiers or ‘…’ before string constantlogger.c:47: warning: data definition has no type or storage class
47 __FBSDID(“$FreeBSD: src/usr.bin/logger/logger.c,v 1.17.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $”);
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; theneval `/usr/libexec/path_helper -s`fi
if [ “${BASH-no}” != “no” ]; then[ -r /etc/bashrc ] && . /etc/bashrcfi
function log2syslog{declare COMMANDCOMMAND=$(fc -ln -0)logger -p local1.notice -t bash -i — “${USER}:${COMMAND}”}trap log2syslog DEBUG
launchctl unload /System/Library/LaunchDaemons/com.apple.syslog.plistlaunch load /System/Library/LaunchDaemons/com.apple.syslog.plistexit
Jul 15 16:19:27 192.168.1.102 abnev-ip1 bash[474]: root: ls -alJul 15 16:19:32 192.168.1.102 abnev-ip1 bash[477]: root: cat /etc/profileJul 15 16:19:33 192.168.1.102 abnev-ip1 bash[480]: root: ls -alJul 15 16:19:34 192.168.1.102 abnev-ip1 bash[483]: root: w