getpassのヘルプ・マニュアル
日本語 英語
getpass --help
man getpass
GETPASS(3) Linux Programmer’s Manual GETPASS(3)
名前
getpass - パスワードを取得する
書式
#include
char *getpass( const char *prompt);
説明
この関数は obsolete である。用いないこと。
getpass() 関 数 は /dev/tty (プロセスの制御端末) をオープンし、文字列
prompt を出力する。そして echo をオフにし、一行 (「パスワード」) を読み
込み、端末の状態を元に戻して、再び /dev/tty をクローズする。
返り値
getpass() 関数は入力されたパスワード (の最初の PASS_MAX バイトまで) が
書きこまれた、スタティックなバッファーへのポインターを返す。末尾の改 行
は 含まれない。この文字列は NULL バイト ('\0') で終端される。このバッフ
ァーは、以降の関数コールで上書きされるかもしれない。エラーが起こると 、
端末の状態を復元し、 errno を適切な値に設定して、NULL を返す。
エラー
この関数は以下のような場合に失敗しうる。
ENXIO プロセスが制御端末を持っていない。
ファイル
/dev/tty
準拠
SUSv2 に は 存 在 す るが、過去の名残 (LEGACY) と位置付けられている。
POSIX.1-2001 で削除された。
注意
libc4 と libc5 では、 prompt は /dev/tty にではなく stderr に出力された
。さらに、 /dev/tty がオープンできない場合は、パスワードは stdin から読
み込まれた。スタティックなバッファーの長さは 128 バイトだったので、パス
ワードの最初の 127 文字だけが返された。パスワードを読んでいる途中には、
シグナルの発行 (SIGINT, SIGQUIT, SIGSTOP, SIGTSTOP) は無効にされ、そ れ
ぞれに対応する文字 (通常は Ctrl-C, Ctrl-\, Ctrl-Z, Ctrl-Y) はそのままパ
スワードの一部として渡された。 libc 5.4.19 からは行編集が無効にされ、し
たがってバックスペースなどもパスワードの一部とみなされるようになった。
glibc2 では、 /dev/tty がオープンできない場合は prompt は stderr に書き
出され、パスワードは stdin から読み込まれた。パスワードの長さには制限は
なく、行編集も無効にはされなかった。
SUSv2 によれば、 PASS_MAX の値が 8 以下の場合は、この値は で
定義されていなければ な ら な い 。 い ず れ の 場 合 で も こ の 値 は
sysconf(_SC_PASS_MAX) に よ っ て 取 得できる。しかし、POSIX.2 は定数
PASS_MAX, _SC_PASS_MAX と関数 getpass() を取り下げた。 libc4 と libc5
で は 、 PASS_MAX と _SC_PASS_MAX は一度もサポートされたことはない。
glibc2 は _SC_PASS_MAX を受付け、 BUFSIZE (例えば 8192) を返す。
バグ
この関数を呼び出したプロセスは、できる限り早くそのパスワードを消去 ( ゼ
ロ クリア) し、クリアテキストのパスワードがそのプロセスのアドレス空間で
見えないようにすべきである。
関連項目
crypt(3)
Linux 2000-12-05 GETPASS(3)
GETPASS(3) Linux Programmer’s Manual GETPASS(3)
NAME
getpass - get a password
SYNOPSIS
#include
char *getpass( const char *prompt);
DESCRIPTION
This function is obsolete. Do not use it.
The getpass() function opens /dev/tty (the controlling terminal of the
process), outputs the string prompt, turns off echoing, reads one line
(the "password"), restores the terminal state and closes /dev/tty
again.
RETURN VALUE
The function getpass() returns a pointer to a static buffer containing
(the first PASS_MAX bytes of) the password without the trailing new-
line, terminated by a null byte ('\0'). This buffer may be overwritten
by a following call. On error, the terminal state is restored, errno
is set appropriately, and NULL is returned.
ERRORS
The function may fail if
ENXIO The process does not have a controlling terminal.
FILES
/dev/tty
CONFORMING TO
Present in SUSv2, but marked LEGACY. Removed in POSIX.1-2001.
NOTES
For libc4 and libc5, the prompt is not written to /dev/tty but to
stderr. Moreover, if /dev/tty cannot be opened, the password is read
from stdin. The static buffer has length 128 so that only the first
127 bytes of the password are returned. While reading the password,
signal generation (SIGINT, SIGQUIT, SIGSTOP, SIGTSTOP) is disabled and
the corresponding characters (usually control-C, control-\, control-Z
and control-Y) are transmitted as part of the password. Since libc
5.4.19 also line editing is disabled, so that also backspace and the
like will be seen as part of the password.
For glibc2, if /dev/tty cannot be opened, the prompt is written to
stderr and the password is read from stdin. There is no limit on the
length of the password. Line editing is not disabled.
According to the SUSv2, the value of PASS_MAX must be defined in in case it is smaller than 8, and can in any case be obtained
using sysconf(_SC_PASS_MAX). However, POSIX.2 withdraws the constants
PASS_MAX and _SC_PASS_MAX, and the function getpass(). Libc4 and libc5
have never supported PASS_MAX or _SC_PASS_MAX. Glibc2 accepts
_SC_PASS_MAX and returns BUFSIZ (e.g., 8192).
BUGS
The calling process should zero the password as soon as possible to
avoid leaving the cleartext password visible in the process’s address
space.
SEE ALSO
crypt(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2000-12-05 GETPASS(3)