API to check if an OS X device is password protected

I am looking for an API to check if a MacBook is password protected.

I know about a similar API in iOS:

 LAContext *laContext = [[LAContext alloc] init];
 BOOL passcodeSet = [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error: &authError];

Unfortunately, this always returns true when you set the password to blank and / or enable autorun. I checked with Apple and expected its behavior.

Is there any other API that allows me to get the status of a password (directly or indirectly)?

Update 1

Looks like I'm using a bit of the wrong terminology. I am trying to check if the user account is password protected (enough integer mac is password protected). However, to say that it is almost the same for most end users who have a macOS device and have only one active account.

+4
source share
1

, - API, /etc/passwd. . , . , x , , /etc/shadow

+3

Source: https://habr.com/ru/post/1693336/


All Articles