執行 sudo 命令時發生 sudoers 檔案語法錯誤

Summary: 設定角色後,您無法執行 sudo 命令,並在 sudoers 檔案中顯示語法錯誤。

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Symptoms

執行「sudo命令」,則可能會在一或多個節點上失敗,例如:

cluster-1# isi_for_array -s sudo date
cluster-1: Fri Sep 12 16:58:29 CDT 2014
cluster-2: Fri Sep 12 16:58:30 CDT 2014
cluster-3: sudo: >>> /usr/local/etc/sudoers: syntax error near line 124 <<<
cluster-3: sudo: parse error in /usr/local/etc/sudoers near line 124
cluster-3: sudo: no valid sudoers sources found, quitting
cluster-3: sudo: unable to initialize policy plugin

Cause

這可能由於各種原因而發生:
 

1.新增至角色的使用者或群組在受影響的節點上無法解析:

在出現此問題的節點上,您可能會看到新增的使用者或群組無法解決:

cluster-1# isi_for_array -n3 'isi auth users view domain\\group'
cluster-3: Failed to find group for 'GROUP:domain\group': No such group

由於使用者或群組無法解析,節點找不到 sudoers 檔,然後查看 /usr/local/etc/sudoers 檔案:

cluster-1# isi_for_array -s "egrep -i 'user_alias.*newrole' /usr/local/etc/sudoers"
cluster-1: User_Alias NEWROLE = %#1000010
cluster-2: User_Alias NEWROLE = %#1000010
cluster-3: User_Alias NEWROLE =

請注意,尚未填入 UID/GID,這會導致語法錯誤。
 

2.建立的角色名稱中包含連字元:

cluster-1# isi auth roles view test-role                                                               
       Name: test-role
Description: -
    Members: DOMAIN\user
 Privileges
             ID : ISI_PRIV_LOGIN_SSH
      Read Only : True

             ID : ISI_PRIV_AUTH
      Read Only : False

cluster-1% sudo date
sudo: >>> /usr/local/etc/sudoers: syntax error near line 124 <<<
sudo: parse error in /usr/local/etc/sudoers near line 124
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

例如,此錯誤存在於第 124 行:

cluster-1# grep -n '' /usr/local/etc/sudoers | grep ^124
124:User_Alias TEST-ROLE = #1000003

 3.使用者或群組沒有關聯的 UID 或 GID。

Resolution

1.如果節點無法將使用者或群組名稱轉換為 UID/GID,我們必須改為新增 UID/GID 指定的使用者/群組。


從角色設定中移除使用者或群組名稱:

cluster-1# isi auth roles modify --role=newrole --remove-group=domain\\group
cluster-1# isi auth roles view newrole                                                          
       Name: newrole
Description: -
    Members: -
 Privileges
             ID : ISI_PRIV_LOGIN_SSH
      Read Only : True

             ID : ISI_PRIV_SMB
      Read Only : False


從可執行作業的節點為使用者取得正確的 UID/GID:

cluster-1# isi auth groups view domain\\group
            Name: DOMAIN\group
              DN: CN=group,CN=Users,DC=domain,DC=com
             SID: S-1-5-21-463481935-3723234361-2963677383-1144
             GID: 1000010
          Domain: DOMAIN
Sam Account Name: group
        Provider: lsa-activedirectory-provider:DOMAIN.COM
   Generated GID: Yes
注意:使用者也可以這樣做,將「groups」替換為「users」,而不是 GID、UID。

套用 UID/GID 而非群組名稱:

cluster-1# isi auth roles modify --role=newrole --add-gid=1000010
cluster-1# isi auth roles view newrole                                                          
       Name: newrole
Description: -
    Members: DOMAIN\group
 Privileges
             ID : ISI_PRIV_LOGIN_SSH
      Read Only : True

             ID : ISI_PRIV_SMB
      Read Only : False

 注意:使用者也可以這樣做,將“add-gid”替換為“add-uid”。

sudoers 檔案組態現在應能正確反映 uid/gid:

cluster-1# isi_for_array -s "egrep -i 'alias.*newrole' /usr/local/etc/sudoers"
cluster-1: User_Alias NEWROLE = %#1000010
cluster-2: User_Alias NEWROLE = %#1000010
cluster-3: User_Alias NEWROLE = %#1000010

此外,sudo 命令應該可以正常工作:

cluster-1# isi_for_array -s sudo date                                                      
cluster-1: Fri Sep 12 17:20:14 CDT 2014
cluster-2: Fri Sep 12 17:20:14 CDT 2014
cluster-3: Fri Sep 12 17:20:14 CDT 2014

 

2.重命名角色,使其不包含“-”。
 

重新命名角色,使其不包含連字元:

cluster-1# isi auth roles modify --role=test-role --name=test_role

 

請注意,不再有語法錯誤:

cluster-1% % sudo date
Password:

 

3.sudoers 檔案需要 UID 或 GID 來識別使用者和群組,確保所有使用者和群組都有相關聯的 UID 或 GID。

Affected Products

PowerScale OneFS
Article Properties
Article Number: 000102433
Article Type: Solution
Last Modified: 22 Dec 2025
Version:  5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.