Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling "sysctlbyname(...)" with "hw.machine" flag in iOS9

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?

like image 856
topsky Avatar asked Aug 24 '15 13:08

topsky


1 Answers

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.

like image 57
tounaobun Avatar answered Oct 13 '22 06:10

tounaobun