Skip to content

Debugging VPN issues on Mac OS X Lion

Mac OS X Lion uses open-source package ip-sec for its built-in VPN support. It is easy enough to setup debug-level logging to troubleshoot issues with VPN: just add a file called com.apple.ipsec.plist under /Library/Preferences/SystemConfiguration directory. File should contain the following xml structure:

<?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>Global</key>
<dict>
<key>DebugLevel</key>
<integer>2</integer>
<key>DebugLogfile</key>
<string>/Users/martin/jazz.log</string>
</dict>
</dict>
</plist>

Next time VPN connection is initiated there will be debug log created in the /Users/martin/jazz.log file.

Categories: Debugging, Mac OS X.

Mac OS X debugger presence check

This piece of code is designed to determine if the application runs under debugger. I found it at http://borkware.com/quickies/single?id=182

#include <stdio.h>
#include <sys/sysctl.h>
#include <errno.h>

int main(int argc, char * argv[])
{
    int mib[4];
    size_t size;

    mib[0] = CTL_KERN;
    mib[1] = KERN_PROC;
    mib[2] = KERN_PROC_PID;
    mib[3] = getpid();

    struct kinfo_proc info;

    info.kp_proc.p_flag = 0;

    size = sizeof(info);

    if ( sysctl(mib, 4, &info, &size, NULL, 0) )
    {
        printf("Error: %d\n", errno);
        return 1;
    }

    if((info.kp_proc.p_flag & P_TRACED) == P_TRACED)
    {
        printf("This program is being debugged.\n");
    }

    return 0;
}

Categories: Debugging, Mac OS X.

Send any questions to: support at jimmers info

Categories: Uncategorized.