6

Following WWDC 2015 session "703 Privacy and Your App", there is changes using sysctl. And now there we will no longer be able to call kern.proc, kern.procargs, kern.procargs2 and see data from any other processes then one's self. It's a quite legit privacy hardening by Apple.

Can anyone confirm that calling sysctlbyname(...) with hw.machine to fetch exact device name is allowed in iOS9 and not affected by restriction mentioned above?

jww
  • 97,681
  • 90
  • 411
  • 885
topsky
  • 199
  • 3
  • 12
  • If you need the string like *"iPhone1,1"*, then also see [How to get device make and model on iOS?](https://stackoverflow.com/a/11197770/608639). It looks easier to use for the model string than `sysctlbyname`. – jww Aug 11 '17 at 15:33

1 Answers1

3

Yes,I have tested it Using Xcode7 beta5 in iPhone5(iOS9 beta5 installed,not simulator).

+(NSString *) getDeviceModel {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *model = malloc(size);
    sysctlbyname("hw.machine", model, &size, NULL, 0);
    NSString *deviceModel = [NSString stringWithCString:model encoding:NSUTF8StringEncoding];
    free(model);
    return deviceModel;
}

And the returning value is "iPhone5,2".So I thought the device name is not affected by restriction on the "sysctl" function.

tounaobun
  • 14,570
  • 9
  • 53
  • 75
  • Hi, thank you for the answer. But my question was actually is if Apple can reject application that uses "sysctlbyname" with "hw.machine" flag or they just reject only those, who use "kern.proc" flags? – topsky Sep 03 '15 at 18:44
  • By the way, fot the same reason we cannot get the list of running apps now ((( – Dmitry Isakov Sep 21 '15 at 10:13
  • I believe that this is used in CDVDevice.m of Cordova. So if it wasn't allowed then Cordova wouldn't be using it. The real question I have is ... how can we verify this string came from a real device? I need it to prevent people from creating unlimited accounts on my social network. – Gregory Magarshak Apr 28 '17 at 19:31