getpass
Section: C Library Functions (3)
Updated: 2026-02-08
Index
JM Home Page
roff page
名前
getpass - パスワードを取得する
ライブラリ
標準 C ライブラリ (libc,~-lc)
書式
#include <unistd.h>
[[deprecated]] char *getpass(const char *prompt);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
getpass():
Since glibc 2.2.2:
_XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L)
|| /* glibc >= 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE
Before glibc 2.2.2:
none
説明
This function is obsolete. Do not use it. See NOTES. If you want to read
input without terminal echoing enabled, see the description of the ECHO
flag in termios(3).
getpass() 関数は /dev/tty (プロセスの制御端末) をオープンし、文字列 prompt を出力する。そして
echo をオフにし、一行 (「パスワード」) を読み込み、端末の状態を元に戻して、再び /dev/tty をクローズする。
返り値
The function getpass() returns a pointer to a static buffer containing
(the first PASS_MAX bytes of) the password without the trailing newline,
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 to indicate the error, and NULL is returned.
エラー
- ENXIO
-
プロセスが制御端末を持っていない。
ファイル
/dev/tty
属性
この節で使用されている用語の説明については、 attributes(7) を参照。
| インターフェース | 属性 | 値
|
|
getpass()
| Thread safety | MT-Unsafe term
|
標準規格
なし。
歴史
Version 7 AT&T UNIX. Present in SUSv2, but marked LEGACY. Removed in
POSIX.1-2001.
注意
You should use instead readpassphrase(3bsd), provided by libbsd.
GNU C ライブラリの実装では、 /dev/tty がオープンできない場合は prompt は stderr
に書き出され、パスワードは stdin から読み込まれた。 パスワードの長さには制限はなく、 行編集も無効にはされなかった。
SUSv2 によれば、 PASS_MAX の値が 8 以下の場合は、この値は <limits.h>
で定義されていなければならない。 いずれの場合でもこの値は sysconf(_SC_PASS_MAX) によって取得できる。
しかし、POSIX.2 は定数 PASS_MAX, _SC_PASS_MAX と関数 getpass() を取り下げた。 glibc
版は _SC_PASS_MAX を受け付け、 BUFSIZE (例えば 8192) を返す。
バグ
この関数を呼び出したプロセスは、 できる限り早くそのパスワードを消去 (ゼロクリア) し、 クリアテキストのパスワードが
そのプロセスのアドレス空間で見えないようにすべきである。
関連項目
crypt(3)
Index
- 名前
-
- ライブラリ
-
- 書式
-
- 説明
-
- 返り値
-
- エラー
-
- ファイル
-
- 属性
-
- 標準規格
-
- 歴史
-
- 注意
-
- バグ
-
- 関連項目
-
This document was created by
man2html,
using the manual pages.