xcode OS X Mavericks 中的自定义登录/锁定屏幕
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21582995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Custom login/lock screen in OS X Mavericks
提问by Micha? Siwek
I'm trying to override the default login/lock screen in OS X to allow the user to login in other way than providing a password (think fingerprint scanner or how "Knock to unlock" works), and I'm looking for a way to do it for hours now - all I found that looks useful is the Authorization Plugin ADC reference and this example: https://developer.apple.com/library/mac/samplecode/NameAndPassword/Introduction/Intro.html#//apple_ref/doc/uid/DTS10004022
我正在尝试覆盖 OS X 中的默认登录/锁定屏幕,以允许用户以提供密码以外的其他方式登录(想想指纹扫描仪或“敲开解锁”的工作原理),我正在寻找一种方法现在做几个小时 - 我发现看起来有用的是授权插件ADC参考和这个例子:https: //developer.apple.com/library/mac/samplecode/NameAndPassword/Introduction/Intro.html#//apple_ref /doc/uid/DTS10004022
This NameAndPassword xcode project is a little outdated, but I managed to build it simply by specifying the Base SDK (there was a hardcoded wrong path), then I put the resulting .bundle file into /Library/Security/SecurityAgentPlugins
directory. Nothing changed after I locked my screen, but I know I need to add the authorization role to /etc/authorization
file, which I know no longer exists in Mavericks (there is this auth.db file and the whole auth API), but I'm therefore stuck here - I don't know how to put NameAndPassword inside this database.
这个 NameAndPassword xcode 项目有点过时,但我设法通过指定 Base SDK 来构建它(有一个硬编码的错误路径),然后我将生成的 .bundle 文件放入/Library/Security/SecurityAgentPlugins
目录中。锁定屏幕后没有任何变化,但我知道我需要将授权角色添加到/etc/authorization
文件中,我知道它在 Mavericks 中不再存在(有这个 auth.db 文件和整个 auth API),但我因此被卡住了这里 - 我不知道如何将 NameAndPassword 放入这个数据库中。
Please let me know how do I do it right, or if you know some other way to achieve my goal.
请让我知道我该怎么做,或者您是否知道实现我的目标的其他方法。
回答by Micha? Siwek
I found a way to edit the database - at first, I tried direct /var/private/db/auth.db
sqlite modifications, but it didn't work, so after some time I managed to do this easier than I thought I will:
我找到了一种编辑数据库的方法 - 起初,我尝试直接/var/private/db/auth.db
修改 sqlite,但没有奏效,所以一段时间后我设法比我想象的更容易做到这一点:
security authorizationdb read system.login.console > outfile.plist
After this, you need to modify the resulting
outfile.plist
as it's said in the NullAuthPlugin readme:<key>mechanisms</key> <array> <string>NameAndPassword:invoke</string>
(the last line is the one you need to add to the file).
Then, to save it to the database:
security authorizationdb write system.login.console < outfile.plist
security authorizationdb read system.login.console > outfile.plist
在此之后,您需要修改结果,
outfile.plist
如 NullAuthPlugin 自述文件中所述:<key>mechanisms</key> <array> <string>NameAndPassword:invoke</string>
(最后一行是您需要添加到文件中的行)。
然后,将其保存到数据库:
security authorizationdb write system.login.console < outfile.plist
Then the changes should be visible on any login/lock screen of your system, but be careful!
然后更改应该在您系统的任何登录/锁定屏幕上可见,但要小心!
You will not be able to authenticate with current version of NameAndPassword example!
您将无法使用当前版本的 NameAndPassword 示例进行身份验证!
Be sure to estabilish a working SSH connection to your Mac beforeyou modify the database, so you will be able to revert the changes using other device (just repeat the db modification process but this time remove the line you added before).
在修改数据库之前,请务必与 Mac 建立有效的 SSH 连接,这样您就可以使用其他设备恢复更改(只需重复 db 修改过程,但这次删除您之前添加的行)。