Sun Cluster 系統管理指南(適用於 Solaris 作業系統)

Procedure如何經由指令行建立角色

步驟
  1. 以超級使用者身份登入或成為可以建立其他角色的角色。

  2. 選取建立角色的方法﹕

    • 對於本機範圍內的角色,請使用 roleadd(1M) 指令指定新的本機角色及其特性。

    • 或者,對於本機範圍內的角色,可以使用 type=role 來編輯 user_attr(4) 檔案,以增加使用者。

      建議僅在緊急情況下使用此方法,因為此方法在輸入時很容易出錯。

    • 對於名稱服務內的角色,請使用 smrole(1M) 指令指定新角色及其特性。

      此指令需要超級使用者授權或能夠建立其他角色的角色授權。您可以將 smrole 套用至所有的名稱服務。此指令作為 Solaris 管理主控台伺服器的用戶端執行。

  3. 啟動與停止名稱服務快取常駐程式。

    新角色直到重新啟動名稱服務快取常駐程式後才會生效。作為 root,請輸入以下內容﹕


    # /etc/init.d/nscd stop
    # /etc/init.d/nscd start
    

範例 2–1 使用 smrole 指令建立自訂操作者角色

以下序列說明了如何使用 smrole 指令建立角色。在此範例中,建立了新版本的操作者角色,並且為其指定了標準操作者許可權設定檔以及媒體復原許可權設定檔。


% su primaryadmin 
# /usr/sadm/bin/smrole add -H myHost -- -c "Custom Operator" -n oper2 -a johnDoe \
-d /export/home/oper2 -F "Backup/Restore Operator" -p "Operator" -p "Media Restore"

Authenticating as user: primaryadmin

Type /? for help, pressing <enter> accepts the default denoted by [ ]
Please enter a string value for: password :: <type primaryadmin password>

Loading Tool: com.sun.admin.usermgr.cli.role.UserMgrRoleCli from myHost
Login to myHost as user primaryadmin was successful.
Download of com.sun.admin.usermgr.cli.role.UserMgrRoleCli from myHost was successful.

Type /? for help, pressing <enter> accepts the default denoted by [ ]
Please enter a string value for: password ::<type oper2 password>

# /etc/init.d/nscd stop
# /etc/init.d/nscd start

若要檢視新建立的角色 (以及任何其他角色),請使用帶 list 選項的 smrole,如下所示:


# /usr/sadm/bin/smrole list --
Authenticating as user: primaryadmin

Type /? for help, pressing <enter> accepts the default denoted by [ ]
Please enter a string value for: password :: <type  primaryadmin password>

Loading Tool: com.sun.admin.usermgr.cli.role.UserMgrRoleCli from myHost
Login to myHost as user primaryadmin was successful.
Download of com.sun.admin.usermgr.cli.role.UserMgrRoleCli from myHost was successful.
root                    0               Super-User
primaryadmin            100             Most powerful role
sysadmin                101             Performs non-security admin tasks
oper2                   102             Custom Operator