Linux

如何設置 olcAccess 屬性以便 gidNumber=0+uidNumber=0 像 olcRootDN 一樣工作?

  • October 17, 2018

我正在將 Ubuntu 14.04 OpenLDAP 伺服器升級到 16.04 並遇到障礙。有一個 (localhost) 導入腳本,用於ldapdelete -r -Y EXTERNAL -H ldapi:///...刪除一些 OU,然後用新資訊重新填充它們。由於我懷疑是缺少/更改的olcAccess屬性,這失敗了。任何人都知道為什麼這不起作用?

我已經從腳本中手動執行了一行,結果如下:

# ldapdelete -r -Y EXTERNAL -H ldapi:/// "ou=people,dc=my,dc=org"
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
ldap_delete: Insufficient access (50)
       additional info: no write access to parent

我可以使用olcRootDn成功刪除 OU,但這需要將 rootdn 密碼放在我不想這樣做的地方。

# ldapdelete  -x -D "cn=admin,dc=my,dc=org" -W -h ldap1 "ou=people,dc=my,dc=org"
Enter LDAP Password: 

# ldapdelete  -x -D "cn=admin,dc=my,dc=org" -W -h ldap1 "ou=people,dc=my,dc=org"
Enter LDAP Password: 
ldap_delete: No such object (32)
       matched DN: dc=my,dc=org

我已經跑去slapcat查看olcAccess屬性——似乎dn-exact=...條目應該提供正確的權限,但這一定是不正確的。

dn: olcBackend={0}hdb,cn=config
objectClass: olcBackendConfig
olcBackend: {0}hdb

dn: olcDatabase={-1}frontend,cn=config
objectClass: olcDatabaseConfig
objectClass: olcFrontendConfig
olcDatabase: {-1}frontend
olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external
,cn=auth manage by * break
olcAccess: {1}to dn.exact="" by * read
olcAccess: {2}to dn.base="cn=Subschema" by * read
olcSizeLimit: 500

dn: olcDatabase={0}config,cn=config
objectClass: olcDatabaseConfig
olcDatabase: {0}config
olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external
,cn=auth manage by * break

dn: olcDatabase={1}hdb,cn=config
objectClass: olcDatabaseConfig
objectClass: olcHdbConfig
olcDatabase: {1}hdb
olcDbDirectory: /var/lib/ldap
olcSuffix: dc=my,dc=org
olcAccess: {0}to attrs=userPassword by self write by anonymous auth by * none
olcAccess: {1}to attrs=shadowLastChange by self write by * read
olcAccess: {2}to * by * read
olcLastMod: TRUE
olcRootDN: cn=admin,dc=my,dc=org
olcRootPW: {SSHA}(removed)...
olcDbCheckpoint: 512 30
olcDbConfig: {0}set_cachesize 0 2097152 0
olcDbConfig: {1}set_lk_max_objects 1500
olcDbConfig: {2}set_lk_max_locks 1500
olcDbConfig: {3}set_lk_max_lockers 1500
olcDbIndex: objectClass eq
olcDbIndex: cn,uid eq
olcDbIndex: uidNumber,gidNumber eq
olcDbIndex: member,memberUid eq

根據您對**{1}hdb**數據庫的配置,缺少適用於 root 系統使用者的 ACL。您應該添加:

olcAccess: {0}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external ,cn=auth manage by * break

此 ACL必須是此數據庫的第一個(索引 {0})

{-1}前端數據庫中的相同 ACL被附加到**{1}hdb的 ACL 列表中。這意味著添加在此列表的末尾**,即在“olcAccess: {2}to * by * read”之後。“to * by * read”指令導致 ACL 引擎停止處理,只有讀取權限。

OpenLDAP 管理員指南(參見5.2.5.2.):

注意:在前端定義的訪問控製附加到所有其他數據庫的控制。

引用自:https://serverfault.com/questions/935790