sudoとsssdはユーザーグループでは機能しません

sudoとsssdはユーザーグループでは機能しません

ldapを使用して異なるsudo権限を持つグループを保存すると、sssdとのsudo統合が正しく機能しません。 LDAPに直接アクセスするようにsudoを設定すると、うまく機能します。

これが私たちのシナリオです。

ldapでカスタマイズ: waynea

Wayneaは2つのグループに属します。 gcadmin グループを使用すると、特定のコマンドを root として実行できます。別のグループであるgcoracleを使用すると、ローカル(ldapで定義されていない)ユーザーoracleで特定のコマンドを実行できます。

waynea@pgc501> id
uid=5091(waynea) gid=5000(mcsuser) groups=5000(mcsuser),5022(gcadmin),5024(gcoracle)

以下は、2つのグループのldap sudo定義です。

waynea@pgc501> ldapsearch -h pld101.foo.com -x "(cn=%gcadmin)"
# %gcadmin, SUDOers, foo.com
dn: cn=%gcadmin,ou=SUDOers,dc=foo,dc=com
cn: %gcadmin
objectClass: sudoRole
objectClass: top
sudoCommand: /usr/bin/id
sudoCommand: /bin/ps
sudoCommand: /u01/oracle/12.1.0/agent12c/agent_inst/bin/emctl
sudoHost: ALL
sudoUser: %gcadmin
sudoRunAs: ALL

waynea@pgc501> ldapsearch -h pld101.foo.com -x "(cn=%gcadmin)"
# %gcoracle, SUDOers, foo.com
dn: cn=%gcoracle,ou=SUDOers,dc=foo,dc=com
cn: %gcoracle
objectClass: sudoRole
objectClass: top
sudoCommand: /bin/sh
sudoCommand: /u01/oracle/12.1.0/agent12c/sbin/nmosudo *
sudoHost: ALL
sudoRunAs: oracle
sudoUser: %gcoracle

これで、sudoをldapに直接接続するときです。 IE /etc/nsswitch.confには次のものがあります。

sudoers:       files ldap

「sudo -ll」を実行すると、次のような結果が表示されます。

waynea@pgc501 > sudo -ll
Matching Defaults entries for waynea on this host:
    requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL
    PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES",
    env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User waynea may run the following commands on this host:
    RunAsUsers: oracle
    Commands:
        /bin/sh
        /u01/oracle/12.1.0/agent12c/sbin/nmosudo *
    RunAsUsers: root
    Commands:
        /usr/bin/id
        /u01/oracle/12.1.0/agent12c/agent_inst/bin/emctl

みんな大丈夫です。

sssdを使用するためにsudoを切り替えると、

sudoers:       files sss

私達はこれを得ます:

waynea@pgc501 > sudo -ll
Matching Defaults entries for waynea on this host:
    requiretty, !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL
    PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES",
    env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY",
    secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin

User waynea may run the following commands on this host:
    RunAsUsers: root
    Commands:
        /bin/sh
        /u01/oracle/12.1.0/agent12c/sbin/nmosudo *
    RunAsUsers: root
    Commands:
        /usr/bin/id
        /u01/oracle/12.1.0/agent12c/agent_inst/bin/emctl

Wayneaには、rootとしてシェル(/bin/sh)を起動する権限があります。

以下は/etc/sssd/sssd.confの関連項目です。

[domain/default]
id_provider = ldap
auth_provider = ldap
sudo_provider = ldap
ldap_sudo_search_base = ou=SUDOers,dc=foo,dc=com
ldap_uri = ldap://pld101.foo.com,ldap://pld301.foo.com/
ldap_search_base = dc=foo,dc=com
ldap_user_search_base = ou=People,dc=foo,dc=com
ldap_group_object_class = posixGroup
ldap_group_search_base = ou=Group,dc=foo,dc=com
ldap_group_name = cn
ldap_group_member = memberUid
ldap_id_use_start_tls = False
chpass_provider = ldap
cache_credentials = true

[sudo]
ldap_sudo_full_refresh_interval = 86400
ldap_sudo_smart_refresh_interval = 3600

どんな助けでも大変感謝します! SSDを活用したいのですが、これがやや邪魔になります。

OS/rpm バージョンは次のとおりです。

Linux 6.5  (OEL)
sssd-1.9.2-129.el6_5.4.x86_64
sudo-1.8.6p3-12.el6.x86_64
libsss_sudo-1.9.2-129.el6_5.4.x86_64
sssd-client-1.9.2-129.el6_5.4.x86_64

ベストアンサー1

ユーザーはwayneaログアウトして再度ログインする必要があります。


sudo -ll次のように印刷してください。

[WanJie@svr-master root]$ sudo -ll
Matching Defaults entries for WanJie on this host:
    !visiblepw, always_set_home, env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE", env_keep+="LC_COLLATE LC_IDENTIFICATION
    LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin, !visiblepw,
    always_set_home, env_reset, requiretty

ユーザーはWanJieこのホストで次のコマンドを実行できます。

SSSD Role: %admin
    RunAsUsers: ALL
    Options: !authenticate
    Commands:
        /root/aaa.sh

SSSD Role: WanJie
    RunAsUsers: ALL
    Options: !authenticate
    Commands:
        /root/sudo.sh

おすすめ記事