更新履歴
2026/10/13 パッケージの内容更新にあわせて修正
2024/01/11 起動できない場合、追記
はじめに
Windows10 がいつからか NetBIOS を使わなくなり、Web Service Discovery だけを使うようになったせいで Samba で構築した共有フォルダが Windows10 のネットワーク一覧に表示されなくなってしまいました。(手動でIPかドメイン名を入力すればアクセス可能)
対策としては Windows10 で「SMBv1クライアント」の機能を有効にし、NetBIOS を再び使うように設定する、というのをよく見かけます。しかし古くてセキュリティに問題のあるクライアントを有効にするのはなんとなく抵抗がありますし、Windows が複数台あったら面倒です。
そこで今回は Samba サーバー側で Web Service Discovery を有効にすることにします。
wsdd 設定
いつのまにやら簡単に Web Service Discovery の機能を追加する wsdd なるものが公開されていました。

2017年11月に公開のようなので、問題が表面化した?Windows10 の Fall Creators Update(1709) の2か月後ですね。
wsdd の実体は単なる Pythonスクリプトのようなので、必要なのは Python3 のみのようです。私は CentOS8 を使っているので、以下 CentOS8 での手順を確認していきます。他のOSの場合は上記のサイトを参考にしてください。
インストール
epel レポジトリを追加し
|
1 |
# dnf install wsdd |
インストールします。
|
1 2 |
$ rpm -q wsdd wsdd-0.8-1.el8.noarch |
執筆時点の環境は上記の通りです。
ファイアウォール設定
UDP の 3702を開ける必要があります。dnfでインストールした場合は、firewalld 用のサービスデータが追加されています。
|
1 |
# firewall-cmd --add-service=wsdd --zone=internal |
firewalld を使っているならこんな感じで。
起動
|
1 |
# systemctl start wsdd |
サービスも追加されてるので systemctl から起動できます。
|
1 2 |
# systemctl enable wsdd # firewall-cmd --permanent --add-service=wsdd --zone=internal |
動作確認がうまくいったら自動起動するようにします。firewalldを使っている場合はポートの設定の恒久化も。
起動オプション
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
$ systemctl cat wsdd # /usr/lib/systemd/system/wsdd.service [Unit] Description=Web Services Dynamic Discovery host daemon Documentation=man:wsdd(8) ; Start after the network has been configured After=network-online.target Wants=network-online.target ; It makes sense to have Samba running when wsdd starts, but is not required. ; Thus, the next to lines are disabled and use BindsTo only. ; One may also add any of these services to After for stronger binding. BindsTo=smb.service ;BindsTo=samba.service [Service] Type=simple EnvironmentFile=-/etc/sysconfig/wsdd ; The service is put into an empty runtime directory chroot, ; i.e. the runtime directory which usually resides under /run ExecStart=/usr/bin/wsdd --shortlog --chroot=/run/wsdd $OPTIONS DynamicUser=yes User=wsdd Group=wsdd RuntimeDirectory=wsdd AmbientCapabilities=CAP_SYS_CHROOT [Install] WantedBy=multi-user.target |
執筆時点のバージョンのパッケージで作られるデーモンはこんな感じ。
デフォルトで chroot 化してくれてますしユーザーも定義してくれています。
バージョンによって結構変化が激しかったので今後もここから変わるかもしれませんが、いい感じの設定になっていると思うので、今後は変化しないような気もしています。
追加のオプションを設定する場合は /etc/sysconfig/wsdd を作成しましょう。
|
1 |
# vim /etc/sysconfig/wsdd |
ということで作成してみます。
|
1 |
OPTIONS="-i eno2 -4" |
変数名もバージョンで変化があったので合ってるか確認しながら記述してください。
この例だとNICを指定、ipv4 だけとしています。
動作確認
Windows10のネットワークを開きます。詳細表示にし、項目右クリックから探索方法の表示を追加しました。
wsdd 起動前の例。表示されてるのは自分(Windows10マシン)だけでSambaサーバーは表示されていない状態です。
wsdd を起動してみるとSambaサーバーが追加されました。探索方法もWSDです。
何も表示されない場合は Windows10 側で「Function Discovery Provider Host」と「Function Discovery Resource Publication」のサービスが有効になっているか確認します。
自動で開始する設定にします。
Windows 側でがんばるより、Samba サーバー側を Web Service Discovery に対応させる方が楽で問題も起きにくいと思います。
おまけ
勉強がてら SELinux の設定をしてみたのでメモ。SELinux で wsdd を縛りたい方は参考になれば。
|
1 |
# vim wsdd.te |
ほとんど ChatGPT に頼っていますが…。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
policy_module(wsdd, 1.0) ######################################## # # Types # # # wsdd process domain and entrypoint. # type wsdd_t; type wsdd_exec_t; init_daemon_domain(wsdd_t, wsdd_exec_t) # # wsdd is started by systemd with DynamicUser=yes. # DynamicUser implies NoNewPrivileges=yes, so permit the # init_t -> wsdd_t domain transition under no_new_privs. # init_nnp_daemon_domain(wsdd_t) # # /run/wsdd # # systemd creates this directory through: # # RuntimeDirectory=wsdd # # It is also used as the root of: # # --chroot=/run/wsdd # type wsdd_var_run_t; files_pid_file(wsdd_var_run_t) ######################################## # # Existing SELinux types # gen_require(` type init_t; type wsdapi_port_t; type httpd_config_t; ') ######################################## # # systemd RuntimeDirectory # # # Have systemd create /run/wsdd as wsdd_var_run_t. # files_pid_filetrans(init_t, wsdd_var_run_t, dir, "wsdd") # # wsdd only needs to access the chroot root itself. # allow wsdd_t wsdd_var_run_t:dir { getattr search }; ######################################## # # chroot # # # Required by: # # --chroot=/run/wsdd # allow wsdd_t self:capability sys_chroot; ######################################## # # Python runtime # # # wsdd is a Python program and is ultimately executed by # /usr/libexec/platform-python3.6, labeled bin_t. # # This also permits execution of ordinary bin_t helpers where # Python itself requires them. # corecmd_exec_bin(wsdd_t) # # DynamicUser account lookup. # auth_read_passwd_file(wsdd_t) # # Python ctypes.util may execute: # # /sbin/ldconfig -p # # while resolving shared libraries. # libs_exec_ldconfig(wsdd_t) ######################################## # # Python mimetypes probe # # # Importing Python's http.server initializes mimetypes. # Python probes optional MIME database locations including: # # /etc/httpd/mime.types # /etc/httpd/conf/mime.types # # wsdd does not require access to Apache configuration. # Keep this access denied, but suppress the known harmless AVC. # dontaudit wsdd_t httpd_config_t:dir search; ######################################## # # Network interface discovery # # # wsdd queries IPv4 interface/address information through # NETLINK_ROUTE. # allow wsdd_t self:netlink_route_socket { create bind getattr nlmsg_read read write }; # # wsdd uses SIOCGIFNAME and related interface queries. # allow wsdd_t self:unix_dgram_socket { create ioctl }; ######################################## # # UDP sockets # # WS-Discovery: # # IPv4 UDP/3702 # # UDP/3702 is locally assigned to the existing SELinux type: # # wsdapi_port_t # # The policy deliberately does not grant wsdd_t generic # unreserved_port_type name_bind permission. # allow wsdd_t self:udp_socket { create bind getattr getopt ioctl read setopt write }; # # Restrict UDP bind to ports labeled wsdapi_port_t. # allow wsdd_t wsdapi_port_t:udp_socket name_bind; # # wsdd is explicitly restricted by its command line to eno2 # and IPv4: # # -i eno2 -4 # # eno2 currently uses the generic network-interface type. # corenet_udp_sendrecv_generic_if(wsdd_t) corenet_udp_bind_generic_node(wsdd_t) ######################################## # # TCP sockets # # WSD metadata HTTP endpoint: # # TCP/5357 # # TCP/5357 is already labeled wsdapi_port_t by the standard # SELinux policy. # allow wsdd_t self:tcp_socket { accept bind create getattr getopt ioctl listen read setopt shutdown write }; # # Restrict TCP bind to ports labeled wsdapi_port_t. # allow wsdd_t wsdapi_port_t:tcp_socket name_bind; corenet_tcp_sendrecv_generic_if(wsdd_t) corenet_tcp_bind_generic_node(wsdd_t) |
ポートの定義は wsdapi_port_t を使いまわすことにしています。
wsdd は Python で import http.server をするのですが、その際に /etc/httpd を読めるかチェックしにいってしまうらしく、そこは許可せずログにも出さないように dontaudit してます。
|
1 2 3 4 5 6 7 8 |
# make -f /usr/share/selinux/devel/Makefile wsdd.pp # semodule -i wsdd.pp # semanage fcontext -a -t wsdd_exec_t '/usr/bin/wsdd' # semanage fcontext -a -t wsdd_var_run_t '/var/run/wsdd(/.*)?' # restorecon -RFv /usr/bin/wsdd # restorecon -RFv /run/wsdd # semanage port -a -t wsdapi_port_t -p udp 3702 |




コメント