2019年12月27日金曜日

Mac で sh/bash/zsh などシェルログイン時に Wireshark: Permission denied と出力される

Mac に Wireshark をインストールしてから、ターミナル起動時に

Wireshark: Permission denied

と出力されるようになってしまった。

別に ~/.bashrc 等の中で Wireshark を実行している形跡もない。

試しに他のシェルを起動してみると、 zsh でも sh でも発生する。

となると、 /etc/profile あたり?

  :
if [ -x /usr/libexec/path_helper ]; then
	eval `/usr/libexec/path_helper -s`
fi
  :

正解。

Permission denied/usr/libexec/path_helper -s を実行する際に出力されていることがわかった。

$ /usr/libexec/path_helper -s
Wireshark: Permission denied
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/djeeno/google-cloud-sdk/bin:/Users/djeeno/.asdf/shims:/Users/djeeno/.asdf/bin:/Users/djeeno/.asdf/installs/golang/1.13.5/go/bin:/Users/djeeno/go/bin"; export PATH;

path_helper について調べる。

path_helper ($PATHを設定するコマンド) (macOS, /etc/paths.d, /etc/paths, shell間をまたいだパス設定) - いろいろ備忘録日記

デフォルトのパス設定は、/etc/pathsファイルから読み取られる。
残りは、/etc/paths.dディレクトリの下から読み取られる。

なるほど。

/etc/paths.d を見てみる。

$ ls -l /etc/paths.d
total 8
-rw-------  1 root  wheel  43 11 21 08:19 Wireshark

いた。

このファイルのパーミッションが 600 で読み込み権限が無いため、 Permission denied が出ていた。

ので、読み込めるようにする。

$ sudo chmod 644 /etc/paths.d/Wireshark
Password:
$ ls -l /etc/paths.d
total 8
-rw-r--r--  1 root  wheel  43 11 21 08:19 Wireshark

これで Permission denied は出なくなった。


参考