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 ?

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
dev_null
  • 1,907
  • 1
  • 16
  • 25

2 Answers2

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.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • 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 knowledge – dev_null Feb 24 '15 at 11:27
  • 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. – TheDarkKnight Feb 24 '15 at 11:36
  • 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? – Ken Thomases Feb 24 '15 at 11:51
  • Different checks for compatibility – dev_null Feb 26 '15 at 07:05
  • 3
    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. – 0xced Mar 19 '15 at 23:56
  • 2
    @0xced Also, you'll want to set `INFOPLIST_FILE` to `path/to/Info.plist`. – Dimitri Bouniol Jan 08 '16 at 21:51
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
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • It doesn't work for my service. it shows version 1.0, but indeed it works for launchd. one more vague way... – dev_null Feb 24 '15 at 11:28