Originally Posted By: dbrashear
Originally Posted By: LittleBlueThing
FWIW I got dragged kicking and screaming down a rabbit hole over the past few days.

For reasons best known to my subconscious I decided to put hijack into a local git repo.

Then I decided it would be a good idea to import *all* the available hijack history into said repository.

I downloaded all the patches, wrote some perl to automate it and off we went.

A few problems arose - some patches are a touch dodgy - but essentially it worked. (Nb 'tweaked' patches attached...)

But then I loaded git web and the timestamps annoyed me so I used a faketime (LD_PRELOAD hijack of the time() calls) to fake the system time for the untar/patch/git commit cycle. (Nb seems to be quite slow - the script was much faster without the timestamp fakery).


so i ported faketime to macos, and it bombed. i looked a little more closely and it's just looping:
#2254 0x000000010002843d in time ()
#2255 0x0000000100028c53 in fake_gettimeofday ()
#2256 0x00000001000285b9 in gettimeofday ()
#2257 0x00007fff80803aa2 in time ()
#2258 0x0000000100028407 in _ftpl_time ()
#2259 0x000000010002843d in time ()
#2260 0x0000000100028c53 in fake_gettimeofday ()

well, i narrowed it down to basically, you can't override gettimeofday. unsure why. but either without DYLD_FORCE_FLAT_NAMESPACE you don't override, or with it, you get an infinite loop.

#137793 0x00007fff5fc01052 in __dyld__dyld_start ()
...
#137785 0x00007fff807c0088 in libSystem_initializer ()
#137784 0x00007fff807c1a70 in __keymgr_initializer ()
#137783 0x00007fff807c1aa9 in _keymgr_get_and_lock_processwide_ptr_2 ()
#137782 0x00007fff807c1b8c in get_or_create_key_element ()
#137781 0x00007fff807c1c76 in malloc ()
#137780 0x00007fff807c2179 in _malloc_initialize ()
#137779 0x00007fff807c2509 in create_scalable_zone ()
#137778 0x00007fff807c2efa in arc4random ()
#137777 0x00007fff807c3041 in arc4_stir ()
#137776 0x000000010000851c in gettimeofday ()

and then we loop. forever. so basically it's too early for dyld to help us, because dyld needs to malloc, and malloc needs to call us, and so we are sad.