MacOS: Version info for not bundled/unix executables
Asked Answered
C

2

6

It's a puzzle for me:

  • for Bundles/Frameworks version lays in Info.plist
  • for old applications it lays in resource fork

But today I found an executable (LaunchDaemon) which is new, has no resource fork, has no Info.plist and has version 1.0.0.1110 according to right pane in Finder. The question is where is the version is sourced from ?

Collateral answered 23/2, 2015 at 9:47 Comment(4)
The version comes from the info plist of the executable located in this path. /Applications/AppName.app/Contents/Info.PlistInsolvable
please read my question attentively. It is not a bundled application. like /usr/bin/grep (but grep has no version info)Collateral
What directory is your LaunchDaemon in? I don't seem to have one on OS X Yosemite.Corabelle
@MarkSetchell, I believe the OP is referring to /sbin/launchdTishatishri
W
4

I don't know about the specific LaunchDaemon program you're referring to, but for the general case it's possible to embed an Info.plist into an executable at link time.

Pass -sectcreate __TEXT __info_plist path/to/Info.plist to ld or, equivalently, pass -Wl,-sectcreate,__TEXT,__info_plist,path/to/Info.plist to the compiler.

This is documented by Apple in Code Signing Guide: Code Signing Tasks – Adding an Info.plist to Single-File Tools.

You can check if that's what's going on with the LaunchDaemon program you're referring to by looking at the output of otool -lV path/to/whatever.

Willey answered 23/2, 2015 at 19:20 Comment(6)
yes, it's the case. I found. as an output of otool there is no Info.plist itself but there is sectname __info_plist in grep. Thank you for sharing the esoteric knowledgeCollateral
That's good to know. I wonder why Apple don't bother embedding a plist in all their binaries; It seems odd to me that version info isn't available for most of them.Tishatishri
They might very well embed an Info.plist in most. As alluded to with my link, it's necessary for code signing. It's just that they may not include a version number in all of them. What use would you make of the version number?Willey
Different checks for compatibilityCollateral
Or you can just set the CREATE_INFOPLIST_SECTION_IN_BINARY build setting to Yes in your project’s build settings instead of the -sectcreate options.Infanta
@Infanta Also, you'll want to set INFOPLIST_FILE to path/to/Info.plist.Bundelkhand
T
1

The launchd and launchctl binaries appear to be the only lone binaries that report the version number in Finder, as far as I can tell.

From Mac OS X and iOS Internals, it describes the startup of launchd as being directly by the kernel and the "name -- /sbin/launchd -- is hard coded as the variable init_program_name".

I suspect that the version number is also hard-coded in a way in which Finder knows what to display, else Finder is treating this as a special known case.

If you use the 'what' command you can also see the version number in the binary, which in my case, is 2.0.0 on Yosemite 10.10.2:

$ what /sbin/launchd

/sbin/launchd
PROGRAM:launchd  PROJECT:libxpc-559.10.3
VERSION:Darwin System Bootstrapper 2.0.0: Wed Nov 12 18:47:07 PST 2014; root:libxpc_executables-559.10.3~1/launchd/RELEASE_X86_64
Tishatishri answered 23/2, 2015 at 16:20 Comment(1)
It doesn't work for my service. it shows version 1.0, but indeed it works for launchd. one more vague way...Collateral

© 2022 - 2024 — McMap. All rights reserved.