I am linking a executable with a plist using -sectcreate __TEXT
linker flags. Reason for this is mainly to use the SMJobBless() method. But I need to read plist lin
User's computer would not probably have otool
installed, and I had the same problem. The solution was to use launchctl
, which is guaranteed to be present at any modern Mac.
It has a plist
subcommand which does the following:
Prints the the property list embedded in the __TEXT,__info_plist segment/section
of the target Mach-O or the specified segment/section.
If you do not specify the section, it prints __TEXT by default. The only argument to provide is the path to the executable:
launchctl plist /Library/PrivilegedHelperTools/com.sparklabs.ViscosityHelper
If you have given path, output might be something like this:
{
"CFBundleIdentifier" = "com.sparklabs.ViscosityHelper";
"SMAuthorizedClients" = (
"anchor apple generic and identifier "com.viscosityvpn.Viscosity" and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "34XR7GXFPX")";
);
"CFBundleName" = "ViscosityHelper";
"CFBundleVersion" = "548";
"CFBundleInfoDictionaryVersion" = "6.0";
};
It can be used in command-line as well as from code via NSTask
(Process
in swift) class.