Unix や Unix 互換の OS のほとんどには su という現ユーザID、現グ ループIDを他のユーザのものに変更するコマンドがあります。
この su は何を意味しているかご存じでしょうか? 頭文字をとったもの(acronym)? 何かの単語の一部?
よくみかけるのは
くらいでしょうか...
pilot-tech-ml という Palm デバイス(互換機含む)に関する技術的なことに ついて議論するメイリングリストがあります。 技術的といっても、プログラム開発に関する話題が大半です。 オフトピックの帝王みたいな人もいますが... 裏付けのないことや前 提条件があいまいな情報や前提条件を示さない見解を平気でメイルする (しかも内容に結構間違いが多いんですよね、これが。)ので皆でつっ こまないといけなくなるという困ったちゃんです。
つい最近、この「su コマンドは何の略なのか?」というのが話題になり (なんでじゃ!)、そのとき調べてわかったことをここに記しておこうと 思います.
「最初は Super User の頭文字だったが、その後は Substitute User になった。」が正解です。
まず Version 6 の su のマニュアルは以下の通りとなっています。 (groff -man でうまく出力できなかったので手作業でフォーマットして あります。)
NAME su - become privileged user SYNOPSIS su DESCRIPTION Su allows one to become the super-user, who has all sorts of marvelous (and correspondingly dangerous) powers. In order for su to do its magic, the user mustsupply a password. If the password is correct, su will execute the Shell with the UID set to that of the super-user. To restore normal UID privileges, type an end-of-file to the super-user Shell. The password demanded is that of the entry ``root'' in the system's password file. To remind the super-user of his responsibilities, the Shell substitutes `#' for its usual prompt `%'. SEE ALSO sh (I)
SYNOPSIS の項に注目。現在の Unix などでは su には引数が あって、オプションや変更したいユーザのユーザIDを指定する ようになっているものがほとんどだと思いますが、ここには それがありません。
su.c (su のソースファイル。たったの 48 行しかありません。) を見ると、パスワードのチェックをしたあと、
setuid(0);
し(引数が 0 すなわちユーザID 0 のスーパユーザです。)その後 シェルを exec(2) しているだけなのです。
つまり Version 6 では su は Super User にしかなれないわけです。
Version 7 ではどうなっているかというと
SU(1) SU(1) NAME su - substitute user id temporarily SYNOPSIS su [ userid ] DESCRIPTION Su demands the password of the specified userid, and if it is given, changes to that userid and invokes the Shell sh(1) without changing the current directory or the user environment (see environ(5)). The new user ID stays in force until the Shell exits. If no userid is specified, `root' is assumed. To remind the super-user of his responsibilities, the Shell substi- tutes `#' for its usual prompt. SEE ALSO sh(1)
となっており、Super User 以外のユーザに変更する機能が追加 されていることがわかります。
こういった Unix の初期のソースが個人でも入手できるよになり、 Unix 関係の都市伝説はなくなっていくだろうと楽観しています。
Comments, suggestions, and donations are welcome.
Go to index page
Copyright (c) 1999-2003 IKEDA Shigeru. ALL RIGHTS RESERVED.
Last modified $Date: 2003/10/06 10:38:41 $