LoginSignup
0
0

MSアカウントを使用したWindows10 EnterpriseからRHEL9 Sambaにゲストアクセスしたい ~その2~

Last updated at Posted at 2023-06-11

前回からの続きです。

まずはSIDについてちゃんと調べてみました。

MicrosoftからSID情報

以下は上記リンク先からの抜粋です。
image.png
image.png
まさに前回の記事でデバッグログから確認出来た、Win10Entからは渡されず、Win10Proから渡されているSIDです。

SID[ 0]: S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501
SID[ 1]: S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-514

やはりこのSIDがSambaに渡らない限りゲストアクセスとして扱われない、ってことでしょうか。

SIDを調べる

今回デバッグログに出力されているSIDを順に上記の情報と紐付けると以下の状況。

Win10Pro
S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501 上述Guest
S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-514 上述Domain Guests
S-1-22-2-65534 記載無し不明
S-1-1-0 World、全てのユーザーを含む
S-1-5-2 Network、ビルトイングループ
S-1-5-32-546 Guests、ビルトイングループ
S-1-22-1-65534 記載無し不明

お、ビルトイングループとしてのGuestsが渡されていましたね。

Win10Ent
S-1-5-7 Anonymous Logon
S-1-1-0 World、全てのユーザーを含む(Win10Proにも存在)
S-1-5-2 Network、ビルトイングループ(Win10Proにも存在)
S-1-22-1-65534 記載無し不明(Win10Proにも存在)
S-1-22-2-65534 記載無し不明(Win10Proにも存在)

こちらはSIDとしてAnonymous Logonが渡っています。
これによってSambaはANONYMOUS LOGONと認識していたのですね。

識別子機関(Identifier authority)が22のSIDはMSの情報からは見つかりません。
が、見覚えのある末尾65534という数字。
Winbindで検索します。

まずはインストールから。

# dnf install samba-winbind-clients
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 2:51:34 前の 2023年05月21日 12時45分13秒 に実施しました。
依存関係が解決しました。
============================================================================================================================
 パッケージ                      アーキテクチャー バージョン               リポジトリー                               サイズ
============================================================================================================================
インストール:
 samba-winbind-clients           x86_64           4.17.5-102.el9           rhel-9-for-x86_64-appstream-rpms            82 k
依存関係のインストール:
 python3-samba-dc                x86_64           4.17.5-102.el9           rhel-9-for-x86_64-baseos-rpms              346 k
 samba-winbind                   x86_64           4.17.5-102.el9           rhel-9-for-x86_64-baseos-rpms              421 k
 samba-winbind-modules           x86_64           4.17.5-102.el9           rhel-9-for-x86_64-baseos-rpms               65 k
弱い依存関係のインストール:
 samba-tools                     x86_64           4.17.5-102.el9           rhel-9-for-x86_64-baseos-rpms               26 k

トランザクションの概要
============================================================================================================================
インストール  5 パッケージ

ダウンロードサイズの合計: 939 k
インストール後のサイズ: 3.2 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/5): samba-winbind-4.17.5-102.el9.x86_64.rpm                                              1.3 MB/s | 421 kB     00:00    
(2/5): samba-tools-4.17.5-102.el9.x86_64.rpm                                                116 kB/s |  26 kB     00:00    
(3/5): samba-winbind-modules-4.17.5-102.el9.x86_64.rpm                                       52 kB/s |  65 kB     00:01    
(4/5): python3-samba-dc-4.17.5-102.el9.x86_64.rpm                                           235 kB/s | 346 kB     00:01    
(5/5): samba-winbind-clients-4.17.5-102.el9.x86_64.rpm                                       37 kB/s |  82 kB     00:02    
----------------------------------------------------------------------------------------------------------------------------
合計                                                                                        344 kB/s | 939 kB     00:02     
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                    1/1 
  インストール中   : samba-winbind-modules-4.17.5-102.el9.x86_64                                                        1/5 
  インストール中   : python3-samba-dc-4.17.5-102.el9.x86_64                                                             2/5 
  インストール中   : samba-tools-4.17.5-102.el9.x86_64                                                                  3/5 
  scriptletの実行中: samba-winbind-4.17.5-102.el9.x86_64                                                                4/5 
  インストール中   : samba-winbind-4.17.5-102.el9.x86_64                                                                4/5 
  scriptletの実行中: samba-winbind-4.17.5-102.el9.x86_64                                                                4/5 
  インストール中   : samba-winbind-clients-4.17.5-102.el9.x86_64                                                        5/5 
  scriptletの実行中: samba-winbind-clients-4.17.5-102.el9.x86_64                                                        5/5 
  検証             : python3-samba-dc-4.17.5-102.el9.x86_64                                                             1/5 
  検証             : samba-winbind-4.17.5-102.el9.x86_64                                                                2/5 
  検証             : samba-winbind-modules-4.17.5-102.el9.x86_64                                                        3/5 
  検証             : samba-tools-4.17.5-102.el9.x86_64                                                                  4/5 
  検証             : samba-winbind-clients-4.17.5-102.el9.x86_64                                                        5/5 
インストール済みの製品が更新されています。

インストール済み:
  python3-samba-dc-4.17.5-102.el9.x86_64                       samba-tools-4.17.5-102.el9.x86_64                           
  samba-winbind-4.17.5-102.el9.x86_64                          samba-winbind-clients-4.17.5-102.el9.x86_64                 
  samba-winbind-modules-4.17.5-102.el9.x86_64                 

完了しました!
#

起動します。

# systemctl status winbind
○ winbind.service - Samba Winbind Daemon
     Loaded: loaded (/usr/lib/systemd/system/winbind.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: man:winbindd(8)
             man:samba(7)
             man:smb.conf(5)
# systemctl start winbind
# systemctl status winbind
● winbind.service - Samba Winbind Daemon
     Loaded: loaded (/usr/lib/systemd/system/winbind.service; disabled; preset: disabled)
     Active: active (running) since Wed 2023-05-21 15:49:56 JST; 1s ago
       Docs: man:winbindd(8)
             man:samba(7)
             man:smb.conf(5)
   Main PID: 67436 (winbindd)
     Status: "winbindd: ready to serve connections..."
      Tasks: 4 (limit: 407656)
     Memory: 10.5M
        CPU: 488ms
     CGroup: /system.slice/winbind.service
             ├─67436 /usr/sbin/winbindd --foreground --no-process-group
             ├─67438 /usr/sbin/winbindd --foreground --no-process-group
             ├─67440 /usr/libexec/samba/samba-dcerpcd --libexec-rpcds --ready-signal-fd=23 --np-helper --debuglevel=0
             └─67451 /usr/libexec/samba/rpcd_lsad --configfile=/etc/samba/smb.conf --worker-group=1 --worker-index=5 --debu>

 5月 21 15:49:56 XXXX systemd[1]: Starting Samba Winbind Daemon...
 5月 21 15:49:56 XXXX winbindd[67436]: [2023/05/21 15:49:56.222426,  0] ../../source3/winbindd/winbindd.c:1440(main)
 5月 21 15:49:56 XXXX winbindd[67436]:   winbindd version 4.17.5 started.
 5月 21 15:49:56 XXXX winbindd[67436]:   Copyright Andrew Tridgell and the Samba Team 1992-2022
 5月 21 15:49:56 XXXX winbindd[67436]: [2023/05/21 15:49:56.229018,  0] ../../source3/winbindd/winbindd_cache.c:3116(initia>
 5月 21 15:49:56 XXXX winbindd[67436]:   initialize_winbindd_cache: clearing cache and re-creating with version number 2
 5月 21 15:49:56 XXXX systemd[1]: Started Samba Winbind Daemon.
#

検索します。

# wbinfo --lookup-sids S-1-22-1-65534
S-1-22-1-65534 -> <none>\nobody 1
# wbinfo --lookup-sids S-1-22-2-65534
S-1-22-2-65534 -> <none>\nobody 2
#

やはりnobodyでした。

"ANONYMOUS LOGON"ってユーザーを作ってみる

SIDとしてAnonymous Logonが渡されているのだから、RHEL9上に"ANONYMOUS LOGON"ってユーザーを作ってみてSamba上でguest accountに設定したらどうだろうか、と考えてみました。
想定では、Win10Ent側からゲストのSIDが渡らないのだから、アカウント名云々したってアクセス出来ないだろう、です。

先ずはユーザー作成から。「スペースを含んだユーザーってRHEL9上で作成出来るの?」って思いながらトライしてみたのでこちらも共有しておきます。
以下の通り--badnameオプションでいけますが、日本語のman pageには出てこないので注意です。

# useradd --badname -M -d / -s /sbin/nologin -u 65533 "ANONYMOUS LOGON"
useradd warning: ANONYMOUS LOGON's uid 65533 outside of the UID_MIN 1000 and UID_MAX 60000 range.
# groupmod -g 65533 "ANONYMOUS LOGON"
# getent passwd "ANONYMOUS LOGON"
ANONYMOUS LOGON:x:65533:65533::/:/sbin/nologin
#

vipwを使わないとダメかなぁ、と思ってましたが--badnameというオプションだったとは。
ちなみに、LegacyなコマンドですけどvipwやvigrはRHEL9でも使えます。またgroupaddコマンドではスペースの入ったグループは作れませんでした。それこそvigrですね。今回は上記の通り、useraddで無理やり作ってgroupmodでGIDを変更してます。UID及びGIDはnobodyの一つ手前の65533としています。

smb.confの[global]にguest account = ANONYMOUS LOGON行を追加し、/smb_shareのOwnerとGroupを"ANONYMOUS LOGON"に変更します。
以下smb.confの抜粋。

[global]
	security = user
	map to guest = bad user
	guest account = ANONYMOUS LOGON
[share]
	path = /smb_share
	read only = No
	guest ok = Yes
# ls -ld /smb_share
drwx------. 2 ANONYMOUS LOGON ANONYMOUS LOGON 6  5月  8 02:09 /smb_share
#

アクセステスト

アクセステストを行います。
想定通り、Win10ProからはアクセスOKで、Win10Entからはアクセス不可でした。
Win10Pro側から。

:
:
  Security token SIDs (7):
    SID[  0]: S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501
    SID[  1]: S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-514
    SID[  2]: S-1-22-2-65533
    SID[  3]: S-1-1-0
    SID[  4]: S-1-5-2
    SID[  5]: S-1-5-32-546
    SID[  6]: S-1-22-1-65533
   Privileges (0x               0):
   Rights (0x               0):
:
:

渡されるSIDに変化がありました。末尾の数字からおそらくANONYMOUS LOGONです。調べます。

# wbinfo --lookup-sids=S-1-22-1-65533,S-1-22-2-65533
S-1-22-1-65533 -> <none>\ANONYMOUS LOGON 1
S-1-22-2-65533 -> <none>\ANONYMOUS LOGON 2
#

予想通りでした。

次にWin10Entです。
渡っているSIDはやはり5つで、Win10Pro側と同じく末尾が65533に変化しています。
from cacheとなっていますが、最初ゲストSIDとしてパーミッション評価がされています。
SID=S-1-22-2-65533はグループとして評価されていますね。
この辺は前回のログにも出ていましたが明記しました。
最終的に、NT_STATUS_ACCESS_DENIEDです。

:
:
  Security token SIDs (5):
    SID[  0]: S-1-5-7
    SID[  1]: S-1-1-0
    SID[  2]: S-1-5-2
    SID[  3]: S-1-22-1-65533
    SID[  4]: S-1-22-2-65533
   Privileges (0x               0):
   Rights (0x               0):
:
:
  xid_to_sid: UID 65533 -> S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501 from cache
:
  xid_to_sid: GID 65533 -> S-1-22-2-65533 fallback
:
  canon_ace index 0. Type = allow SID = S-1-1-0 other SMB_ACL_OTHER ace_flags = 0x0 perms ---
:
  canon_ace index 1. Type = allow SID = S-1-22-2-65533 gid 65533 SMB_ACL_GROUP_OBJ ace_flags = 0x0 perms ---
:
  canon_ace index 2. Type = allow SID = S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501 uid 65533 SMB_ACL_USER_OBJ ace_flags = 0x0 perms rwx
:
  print_canon_ace_list: canonicalise_acl: ace entries after arrange  canon_ace index 0. Type = allow SID = S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501 uid 65533 SMB_ACL_USER_OBJ ace_flags = 0x0 perms rwx
:
  canon_ace index 1. Type = allow SID = S-1-22-2-65533 gid 65533 SMB_ACL_GROUP_OBJ ace_flags = 0x0 perms ---
:
  canon_ace index 2. Type = allow SID = S-1-1-0 other SMB_ACL_OTHER ace_flags = 0x0 perms ---
:
  smbd_check_access_rights_sd: File [.] requesting [0x100081] returning [0x100001] (NT_STATUS_ACCESS_DENIED):
:
:
       sd: struct security_descriptor
          revision                 : SECURITY_DESCRIPTOR_REVISION_1 (1)
          type                     : 0x9004 (36868)
                 0: SEC_DESC_OWNER_DEFAULTED 
                 0: SEC_DESC_GROUP_DEFAULTED 
                 1: SEC_DESC_DACL_PRESENT    
                 0: SEC_DESC_DACL_DEFAULTED  
                 0: SEC_DESC_SACL_PRESENT    
                 0: SEC_DESC_SACL_DEFAULTED  
                 0: SEC_DESC_DACL_TRUSTED    
                 0: SEC_DESC_SERVER_SECURITY 
                 0: SEC_DESC_DACL_AUTO_INHERIT_REQ
                 0: SEC_DESC_SACL_AUTO_INHERIT_REQ
                 0: SEC_DESC_DACL_AUTO_INHERITED
                 0: SEC_DESC_SACL_AUTO_INHERITED
                 1: SEC_DESC_DACL_PROTECTED  
                 0: SEC_DESC_SACL_PROTECTED  
                 0: SEC_DESC_RM_CONTROL_VALID
                 1: SEC_DESC_SELF_RELATIVE   
          owner_sid                : *
              owner_sid                : S-1-5-xx-xxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxx-501
          group_sid                : *
              group_sid                : S-1-22-2-65533
:
:

ということでやはりゲストのSIDが渡らない限りはゲストアクセスにはならないようです。

そこで今度はsmbpasswdで"ANONYMOUS LOGON"をsambaユーザーとして登録すると・・・、なーんて頭を過りましたが、そうするともはやゲストアクセスでも何でもありませんのでやめました。

更に次回、このログを眺めていて気がついたこと、に続く。

//

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0