通过官方示例学习 Apple MDM 配置描述文件的编写 – ASPIRE 您所在的位置:网站首页 苹果官网描述文件146 通过官方示例学习 Apple MDM 配置描述文件的编写 – ASPIRE

通过官方示例学习 Apple MDM 配置描述文件的编写 – ASPIRE

2024-04-14 03:14| 来源: 网络整理| 查看: 265

=Start=

缘由:

前段时间在测试MDM配置描述文件时遇到了一点问题,最后通过翻阅官方文档和实际测试后找到了原因(其它站点的要么介绍的不清楚,要么搜不到,还有可能说的是个错的,最靠谱的还是官方文档)。这里简单记录一下MDM配置描述文件的编写方法和注意事项,方便有需要的参考。

正文: 参考解答: 什么是配置描述文件?

配置描述文件是一个 XML 文件(以 .mobileconfig 结尾),其中包含将设置和授权信息载入到 Apple 设备的有效负载。它会自动配置设置、帐户、访问限制和凭证。这些文件可通过 MDM 解决方案或 Apple Configurator 2 创建,也可手动创建。

配置描述文件的常见用途 内容下发;软件下发;软件更新;Web内容过滤;访问限制;远程擦除或锁定设备;证书相关设置;网络相关设置;密码相关控制;敏感行为监控(一般需配合其它软件,由配置描述文件给特定软件赋予相关权限,再由特定软件进行行为监控);…… “隐私偏好设置策略控制”自定有效负载示例 PayloadContent PayloadDescription Corporate policy for Privacy preferences PayloadDisplayName Privacy Preferences Control PayloadIdentifier com.example.1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F.privacy.3C4D5E6F-9I0J-7G8H-5E6F-2B3C4D3C4D5E PayloadUUID 3C4D5E6F-9I0J-7G8H-5E6F-2B3C4D3C4D5E PayloadType com.apple.TCC.configuration-profile-policy PayloadOrganization Example Org Services SystemPolicySysAdminFiles Identifier com.apple.Terminal IdentifierType bundleID CodeRequirement identifier "com.apple.Terminal" and anchor apple Allowed Comment Allows specified apps access to some files used by system administrators. Get the CodeRequirement with 'codesign --display -r - /Applications/Utilities/Terminal.app' SystemPolicyAllFiles Identifier /usr/bin/mdutil IdentifierType path CodeRequirement identifier "com.apple.mdutil" and anchor apple Allowed Comment Allows specified apps access to data like Mail, Messages, Safari, Home, Time Machine backups, and certain administrative settings for all users on the Mac. Get the CodeRequirement with 'codesign --display -r - /usr/bin/mdutil' Accessibility Identifier com.example.Test IdentifierType bundleID CodeRequirement ... output of 'codesign --display -r - ' ... Allowed Comment Allows specified apps to control the Mac via Accessibility APIs. The CodeRequirement can be obtained via 'codesign --display -r - /Applications/ExampleTest.app' PayloadDisplayName Privacy Preferences Configuration Profile PayloadIdentifier com.example.1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F.privacy PayloadUUID 1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F PayloadType Configuration PayloadScope System 以上面的示例进行配置描述文件的内容/结构解读

出现在上面示例中的最外层Key列表有:

PayloadContent //可选,但对于有效的配置文件来说内容其实是必备的。Array of payload dictionaries. Not present if IsEncrypted is true. ... PayloadDisplayName //可选,显示名称。A human-readable name for the profile. Privacy Preferences Configuration Profile PayloadIdentifier //唯一标识符,不能重复。A reverse-DNS style identifier (com.example.myprofile, for example) that identifies the profile. com.example.1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F.privacy PayloadUUID //实际内容并不重要,只要内容全局唯一就行。A globally unique identifier for the profile. In macOS, you can use uuidgen to generate reasonable UUIDs. 1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F PayloadType //值必须为 Configuration 才行 Configuration PayloadScope //可选,默认值为User。Determines if the profile should be installed for the system or the user. System

最全的列表和说明可以参见官方文档中的 Configuration Profile Keys[1] 部分。下面对 PayloadContent 中的内容进行说明:

PayloadDescription Corporate policy for Privacy preferences PayloadDisplayName Privacy Preferences Control PayloadIdentifier com.example.1A2B3C4D-5E6F-7G8H-9I0J-1A2B3C4D5E6F.privacy.3C4D5E6F-9I0J-7G8H-5E6F-2B3C4D3C4D5E PayloadUUID 3C4D5E6F-9I0J-7G8H-5E6F-2B3C4D3C4D5E PayloadType //表明这是一个“隐私偏好”相关的配置 com.apple.TCC.configuration-profile-policy PayloadOrganization Example Org Services //表明这是一个“隐私偏好设置策略控制”的Payload

在“隐私偏好设置策略控制”(注意上面的 PayloadType 的key取值)的 Services 下可支持的Key列表可以参考[1](Privacy Service Dictionary Keys)部分,先对上面出现的Key进行说明:

SystemPolicySysAdminFiles //Optional. Allows the application access to some files used in system administration. ... SystemPolicyAllFiles //可选,系统全盘访问权限。 Allows the application access to all protected files, including system administration files. ... Accessibility //Optional. Control the application via the Accessibility subsystem. ...

再以 SystemPolicyAllFiles 这个Key的取值为例进行说明(可以参考[3]中的内容):

SystemPolicyAllFiles Identifier //说明:标识符名称或文件路径 /usr/bin/mdutil IdentifierType //说明:标识符类型 path CodeRequirement //说明:代码签名要求 identifier "com.apple.mdutil" and anchor apple Allowed //说明:允许或拒绝 Comment //说明:注释(选填) Allows specified apps access to data like Mail, Messages, Safari, Home, Time Machine backups, and certain administrative settings for all users on the Mac. Get the CodeRequirement with 'codesign --display -r - /usr/bin/mdutil' 针对 Apple 设备的“自定” MDM 有效负载设置

若要允许或不允许 App 或二进制文件访问其中一个隐私类数据,您可以创建自定有效负载,并且必须包括以下要求:

要求描述示例标识符类型指定捆绑包 ID 或文件路径。捆绑包 ID标识符名称或文件路径捆绑包 ID 名称或实际文件路径。捆绑包 ID:com.MyOrganization.AppName文件路径:/Applications/AppName允许或拒绝指定文件是允许访问还是拒绝访问。允许:True拒绝:False代码签名要求实际的代码签名值。若要获取该值,请打开“终端” App 并运行以下命令:App:codesign -dr - /path/to/Application.app二进制文件:codesign -dr - /path/to/mybinaryApp:designated => (anchor apple generic and certificate leaf[field.1.2.345.678901.234.5.6.7] /* exists */ or anchor apple) and identifier "com.apple.appname.ui"二进制文件:designated => identifier "com.organization.binaryname" and anchor apple【注】不是由 Apple 提供的 App 和二进制文件可能有更长的指定要求。您的描述文件中应当包括“designated =>”之后的所有内容。注释添加注释(选填)。允许我的组织的 App 在不提示用户的情况下与所有文件交互。 “隐私偏好设置策略控制”的限制

Apple的MDM设置中不对外开放的(隐私偏好设置相关)权限有3类:

相机(用于拒绝指定的 App 访问相机。)麦克风(拒绝指定的 App 访问麦克风。)屏幕录制(拒绝指定的 App 访问以阻止其拍摄(读取)系统显示的内容。)

通过MDM只能下发拒绝,不能下发允许策略。(除了上面3个之外,其实还有一个ListenEvent权限也是只能下发拒绝“Allows the application to use CoreGraphics and HID APIs to listen to (receive) CGEvents and HID events from all processes. Access to these events cannot be given in a profile; it can only be denied.”)

参考链接:

[1] Apple 设备的 MDM 概览https://support.apple.com/zh-cn/guide/mdm/mdmbf9e668/web

[2] 针对 Apple 设备的完整 MDM 有效负载列表https://support.apple.com/zh-cn/guide/mdm/mdm5370d089/web

[3] 针对 Apple 设备的“隐私偏好设置策略控制” MDM 有效负载设置https://support.apple.com/zh-cn/guide/mdm/mdm38df53c2a/1/web/1.0

[4] “隐私偏好设置策略控制”自定有效负载示例https://support.apple.com/zh-cn/guide/mdm/mdm9ddb7e0b5/1/web/1.0

[5] 针对 Apple 设备的“隐私偏好设置策略控制”有效负载设置https://support.apple.com/zh-cn/guide/mdm/mdm38df53c2a/1/web/1

[6] Configuration Profile Referencehttps://developer.apple.com/business/documentation/Configuration-Profile-Reference.pdf

[7] PrivacyPreferencesPolicyControl.Serviceshttps://developer.apple.com/documentation/devicemanagement/privacypreferencespolicycontrol/services

=END=



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有