.\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl) .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, .\" USA. .\" .\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya .\" all rights reserved. .\" Translated Mon Sep 21 20:47:50 JST 1998 by Hiroaki Nagoya .\" Updated&Modified Fri 9 Feb 2001 by NAKANO Takeo .\" .TH GETPASS 3 2010-09-20 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .\"O getpass \- get a password .SH 名前 getpass \- パスワードを取得する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "char *getpass( const char *" prompt ); .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR getpass (): .ad l .RS 4 .PD 0 .TP 4 .\"O Since glibc 2.2.2: glibc 2.2.2 以降: .nf _BSD_SOURCE || (_XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) .fi .TP 4 .\"O Before glibc 2.2.2: none glibc 2.2.2 より前: なし .PD .RE .ad b .\"O .SH DESCRIPTION .SH 説明 .\"O This function is obsolete. .\"O Do not use it. この関数は obsolete である。用いないこと。 .PP .\"O The .\"O .BR getpass () .\"O function opens .\"O .I /dev/tty .\"O (the controlling terminal of the process), outputs the string .\"O .IR prompt , .\"O turns off echoing, reads one line (the "password"), .\"O restores the terminal state and closes .\"O .I /dev/tty .\"O again. .BR getpass () 関数は .I /dev/tty (プロセスの制御端末) をオープンし、文字列 .I prompt を出力する。そして echo をオフにし、一行 (「パスワード」) を読み込み、端末の状態を元に戻して、再び .I /dev/tty をクローズする。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O The function .\"O .BR getpass () .\"O returns a pointer to a static buffer containing (the first .\"O .B PASS_MAX .\"O bytes of) the password without the trailing .\"O newline, terminated by a null byte (\(aq\\0\(aq). .\"O This buffer may be overwritten by a following call. .\"O On error, the terminal state is restored, .\"O .I errno .\"O is set appropriately, and NULL is returned. .BR getpass () 関数は入力されたパスワード (の最初の .B PASS_MAX バイトまで) が書きこまれた、 スタティックなバッファーへのポインターを返す。 末尾の改行は含まれない。この文字列は NULL バイト (\(aq\\0\(aq) で終端される。 このバッファーは、以降の関数コールで上書きされるかもしれない。 エラーが起こると、端末の状態を復元し、 .I errno を適切な値に設定して、NULL を返す。 .\"O .SH ERRORS .SH エラー .\"O The function may fail if この関数は以下のような場合に失敗しうる。 .TP .B ENXIO .\"O The process does not have a controlling terminal. プロセスが制御端末を持っていない。 .\"O .SH FILES .SH ファイル .I /dev/tty .\"O .\" .SH HISTORY .\" .SH 履歴 .\"O .\" A .\"O .\" .BR getpass () .\"O .\" function appeared in Version 7 AT&T UNIX. .\" .BR getpass () .\" 関数は Version 7 AT&T UNIX で登場した。 .\"O .SH "CONFORMING TO" .SH 準拠 .\"O Present in SUSv2, but marked LEGACY. .\"O Removed in POSIX.1-2001. SUSv2 には存在するが、過去の名残 (LEGACY) と位置付けられている。 POSIX.1-2001 で削除された。 .\"O .SH NOTES .SH 注意 .\"O For libc4 and libc5, the prompt is not written to .\"O .I /dev/tty .\"O but to .\"O .IR stderr . .\"O Moreover, if .\"O .I /dev/tty .\"O cannot be opened, the password is read from .\"O .IR stdin . .\"O The static buffer has length 128 so that only the first 127 .\"O bytes of the password are returned. .\"O While reading the password, signal generation .\"O .RB ( SIGINT , .\"O .BR SIGQUIT , .\"O .BR SIGSTOP , .\"O .BR SIGSTOP ) .\"O is disabled and the corresponding characters .\"O (usually control-C, control-\e, control-Z and control-Y) .\"O are transmitted as part of the password. .\"O Since libc 5.4.19 also line editing is disabled, so that also .\"O backspace and the like will be seen as part of the password. libc4 と libc5 では、 .I prompt は .I /dev/tty にではなく .I stderr に出力された。さらに、 .I /dev/tty がオープンできない場合は、パスワードは .I stdin から読み込まれた。 スタティックなバッファーの長さは 128 バイトだったので、 パスワードの最初の 127 文字だけが返された。 パスワードを読んでいる途中には、シグナルの発行 .RB ( SIGINT , .BR SIGQUIT , .BR SIGSTOP , .BR SIGSTOP ) は無効にされ、 それぞれに対応する文字 (通常は Ctrl-C, Ctrl-\e, Ctrl-Z, Ctrl-Y) はそのままパスワードの一部として渡された。 libc 5.4.19 からは行編集が無効にされ、 したがってバックスペースなどもパスワードの一部とみなされるようになった。 .PP .\"O For glibc2, if .\"O .I /dev/tty .\"O cannot be opened, the prompt is written to .\"O .I stderr .\"O and the password is read from .\"O .IR stdin . .\"O There is no limit on the length of the password. .\"O Line editing is not disabled. glibc2 では、 .I /dev/tty がオープンできない場合は .I prompt は .I stderr に書き出され、パスワードは .I stdin から読み込まれた。 パスワードの長さには制限はなく、 行編集も無効にはされなかった。 .PP .\"O According to the SUSv2, the value of .\"O .B PASS_MAX .\"O must be defined in .\"O .I .\"O in case it is smaller than 8, and can in any case be obtained using .\"O .IR sysconf(_SC_PASS_MAX) . .\"O However, POSIX.2 withdraws the constants .\"O .B PASS_MAX .\"O and .\"O .BR _SC_PASS_MAX , .\"O and the function .\"O .BR getpass (). .\"O Libc4 and libc5 have never supported .\"O .B PASS_MAX .\"O or .\"O .BR _SC_PASS_MAX . .\"O Glibc2 accepts .\"O .B _SC_PASS_MAX .\"O and returns .\"O .B BUFSIZ .\"O (e.g., 8192). SUSv2 によれば、 .B PASS_MAX の値が 8 以下の場合は、この値は .I で定義されていなければならない。 いずれの場合でもこの値は .I sysconf(_SC_PASS_MAX) によって取得できる。 しかし、POSIX.2 は定数 .BR PASS_MAX , .B _SC_PASS_MAX と関数 .BR getpass () を取り下げた。 libc4 と libc5 では、 .B PASS_MAX と .B _SC_PASS_MAX は一度もサポートされたことはない。 glibc2 は .B _SC_PASS_MAX を受付け、 .B BUFSIZE (例えば 8192) を返す。 .\"O .SH BUGS .SH バグ .\"O The calling process should zero the password as soon as possible to avoid .\"O leaving the cleartext password visible in the process's address space. この関数を呼び出したプロセスは、 できる限り早くそのパスワードを消去 (ゼロクリア) し、 クリアテキストのパスワードが そのプロセスのアドレス空間で見えないようにすべきである。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR crypt (3)