LoginSignup
9
5

More than 5 years have passed since last update.

chshがないのでlchshを使ったけど何が違うの?

Posted at

Linuxにはログインシェルを変更するchshというコマンドがあったのだがFedoraでは使えなくなっていた。

"chsh" Command is missing in Fedora 24 fresh install!

答え

util-linux-userをインストールすればいい。

のだけれど、似て非なるコマンドにlchshというのがあり、こちらは最初から使えるので、本来はこちらを使うべきなんだろうと思う。

Bugzillaによれば、コンテナ向けイメージで必要無かったので消した、らしい。なんと乱暴な。

違い

manによれば、機能の上では/etc/shellsを無視するか否か (lchshはShellのリストを無視する) くらいの違いしか無さそう。

どうもchshはLinux由来 (util-linux) で、lchshlibuser由来のようで、つまり出自が違う。

もうちょっと調べてみると、CVEが出てきて、

libuser 脆弱性 (CVE-2015-3245 および CVE-2015-3246)

これによると

passwdchfn、および chshなどの従来のプログラムは/etc/passwdの一時コピーを使用して機能し、最終的には rename()機能を使って一時コピーの名前を変更しますが、libuser/etc/passwdを直接変更します。

という動作の違いがあるようだ。

結論

え、じゃあchshのほうがよくね……?

9
5
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
9
5