问题描述
Mac OS有一组非常基本的父母控制选项,可让您限制用户对网站和应用程序的访问权限,以及每天设置的时间限制.我希望能够编写脚本以执行以下操作:
Mac OS has a very basic set of parental control options that allow you to limit user's access to websites and apps, as well a set daily time limits. I want to be able to script this to do something like the following:
允许特定站点从上午8点到上午9:30进行访问,限制访问游戏.允许从下午5点到下午6:00进行常规访问.
Allow access from 8am to 9:30 am for specific sites, restrict access to games.Allow general access from 5pm to 6:00 pm.
对于在Mac OS 10.8上编写脚本的方式,我不确定从何处开始.有什么建议么?这是Automator可以处理的,还是我最好使用cron作业/shell脚本?
I'm not sure where to start in terms of scripting this on Mac OS 10.8. Any suggestions? Is this something Automator can handle or am I better off using a cron job/shell script?
推荐答案
家长控制"是使用自10.2以来一直存在的常规ol'Managed Preference(aka MCX)框架实施的.它将它们存储在相关用户的mcx_attributes属性中的本地目录服务中.
The Parental Controls are enforced using the regular ol' Managed Preference (aka MCX) frameworks that have been around since 10.2. It stores them in the local directory services in the mcx_attributes attribute for the user in question.
要在GUI之外设置它们或任何托管设置,您需要做的就是使用 dscl
工具的mcx插件向用户提供格式正确的plist.OS X sysadmin社区很好地理解和记录了使用这样的本地目录服务策略.
To set them, or any managed setting, outside of the GUI all you need to do is feed in a properly formatted plist using the mcx plugin of the dscl
tool into the user. Using local directory service policy like this is well understood and documented by the OS X sysadmin community.
最简单的入门方法是设置一些家长控制,然后使用/System/Library/CoreServices中的Directory Utility应用程序或 dscl
命令检查mcx属性,您可以像使用cd和ls的文件系统一样浏览目录服务.
The easiest way to get started with understanding this is to setup some Parental Controls, then inspect the mcx attributes using the Directory Utility app from /System/Library/CoreServices or the dscl
command which will let you explore your directory services as if it were a file system with cd and ls.
一旦看到在XML中设置了哪些键,就可以开始制作自己的键.您也可以使用 dscl.-mcxexport
命令.这将转储管理配置,然后您可以稍后将其导入.检出 dscl.-mcxhelp
获取有关mcx插件的详细信息.
Once you see what the keys are that get set in the XML you can start crafting your own. You can also use the dscl . -mcxexport
command. This will dump the management configuration out and you can then import it later. Check out dscl . -mcxhelp
for the lowdown on the mcx plugin.
要查看使用脚本实现此过程的过程,请执行以下操作:
To review the process of implementing this with a script is:
- 创建一个包含所需策略信息的xml plist.
- 使用
dscl将该plist导入到正确的帐户.mcximport
一个更具前瞻性的替代方法是创建一个配置文件(也只是一个plist文件.),然后使用 profiles
命令加载它.如果采用配置概要文件路由,则目录服务或 dscl
命令无需担心.
A more forward looking alternative would be to create a Configuration Profile (Which is just a plist file as well.) and then load it with the profiles
command. If you take the configuration profile route then there isn't any messing about in directory services or the dscl
command to worry about.
这篇关于在Mac OS X上以编程方式修改家长控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!