OSDN Git Service

06b4010e33cc5216790b345aa039d98cde6de8a9
[linuxjm/LDP_man-pages.git] / draft / man3 / getpass.3
1 .\" Copyright (c) 2000 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya
24 .\"         all rights reserved.
25 .\" Translated Mon Sep 21 20:47:50 JST 1998 by Hiroaki Nagoya <nagoya@is.titech.ac.jp>
26 .\" Updated&Modified Fri 9 Feb 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
27 .\"
28 .TH GETPASS 3  2010-09-20 "Linux" "Linux Programmer's Manual"
29 .\"O .SH NAME
30 .\"O getpass \- get a password
31 .SH 名前
32 getpass \- パスワードを取得する
33 .\"O .SH SYNOPSIS
34 .SH 書式
35 .B #include <unistd.h>
36 .sp
37 .BI "char *getpass( const char *" prompt );
38 .sp
39 .in -4n
40 .\"O Feature Test Macro Requirements for glibc (see
41 .\"O .BR feature_test_macros (7)):
42 glibc 向けの機能検査マクロの要件
43 .RB ( feature_test_macros (7)
44 参照):
45 .in
46 .sp
47 .BR getpass ():
48 .ad l
49 .RS 4
50 .PD 0
51 .TP 4
52 .\"O Since glibc 2.2.2:
53 glibc 2.2.2 以降:
54 .nf
55 _BSD_SOURCE ||
56     (_XOPEN_SOURCE\ >=\ 500 ||
57         _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED) &&
58     !(_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600)
59 .fi
60 .TP 4
61 .\"O Before glibc 2.2.2: none
62 glibc 2.2.2 より前: なし
63 .PD
64 .RE
65 .ad b
66 .\"O .SH DESCRIPTION
67 .SH 説明
68 .\"O This function is obsolete.
69 .\"O Do not use it.
70 この関数は obsolete である。用いないこと。
71 .PP
72 .\"O The
73 .\"O .BR getpass ()
74 .\"O function opens
75 .\"O .I /dev/tty
76 .\"O (the controlling terminal of the process), outputs the string
77 .\"O .IR prompt ,
78 .\"O turns off echoing, reads one line (the "password"),
79 .\"O restores the terminal state and closes
80 .\"O .I /dev/tty
81 .\"O again.
82 .BR getpass ()
83 関数は
84 .I /dev/tty
85 (プロセスの制御端末) をオープンし、文字列
86 .I prompt
87 を出力する。そして echo をオフにし、一行 (「パスワード」)
88 を読み込み、端末の状態を元に戻して、再び
89 .I /dev/tty
90 をクローズする。
91 .\"O .SH "RETURN VALUE"
92 .SH 返り値
93 .\"O The function
94 .\"O .BR getpass ()
95 .\"O returns a pointer to a static buffer containing (the first
96 .\"O .B PASS_MAX
97 .\"O bytes of) the password without the trailing
98 .\"O newline, terminated by a null byte (\(aq\\0\(aq).
99 .\"O This buffer may be overwritten by a following call.
100 .\"O On error, the terminal state is restored,
101 .\"O .I errno
102 .\"O is set appropriately, and NULL is returned.
103 .BR getpass ()
104 関数は入力されたパスワード
105 (の最初の
106 .B PASS_MAX
107 バイトまで) が書きこまれた、
108 スタティックなバッファーへのポインターを返す。
109 末尾の改行は含まれない。この文字列は NULL バイト (\(aq\\0\(aq) で終端される。
110 このバッファーは、以降の関数コールで上書きされるかもしれない。
111 エラーが起こると、端末の状態を復元し、
112 .I errno
113 を適切な値に設定して、NULL を返す。
114 .\"O .SH ERRORS
115 .SH エラー
116 .\"O The function may fail if
117 この関数は以下のような場合に失敗しうる。
118 .TP
119 .B ENXIO
120 .\"O The process does not have a controlling terminal.
121 プロセスが制御端末を持っていない。
122 .\"O .SH FILES
123 .SH ファイル
124 .I /dev/tty
125 .\"O .\" .SH HISTORY
126 .\" .SH 履歴
127 .\"O .\" A
128 .\"O .\" .BR getpass ()
129 .\"O .\" function appeared in Version 7 AT&T UNIX.
130 .\" .BR getpass ()
131 .\" 関数は Version 7 AT&T UNIX で登場した。
132 .\"O .SH "CONFORMING TO"
133 .SH 準拠
134 .\"O Present in SUSv2, but marked LEGACY.
135 .\"O Removed in POSIX.1-2001.
136 SUSv2 には存在するが、過去の名残 (LEGACY) と位置付けられている。
137 POSIX.1-2001 で削除された。
138 .\"O .SH NOTES
139 .SH 注意
140 .\"O For libc4 and libc5, the prompt is not written to
141 .\"O .I /dev/tty
142 .\"O but to
143 .\"O .IR stderr .
144 .\"O Moreover, if
145 .\"O .I /dev/tty
146 .\"O cannot be opened, the password is read from
147 .\"O .IR stdin .
148 .\"O The static buffer has length 128 so that only the first 127
149 .\"O bytes of the password are returned.
150 .\"O While reading the password, signal generation
151 .\"O .RB ( SIGINT ,
152 .\"O .BR SIGQUIT ,
153 .\"O .BR SIGSTOP ,
154 .\"O .BR SIGSTOP )
155 .\"O is disabled and the corresponding characters
156 .\"O (usually control-C, control-\e, control-Z and control-Y)
157 .\"O are transmitted as part of the password.
158 .\"O Since libc 5.4.19 also line editing is disabled, so that also
159 .\"O backspace and the like will be seen as part of the password.
160 libc4 と libc5 では、
161 .I prompt
162
163 .I /dev/tty
164 にではなく
165 .I stderr
166 に出力された。さらに、
167 .I /dev/tty
168 がオープンできない場合は、パスワードは
169 .I stdin
170 から読み込まれた。
171 スタティックなバッファーの長さは 128 バイトだったので、
172 パスワードの最初の 127 文字だけが返された。
173 パスワードを読んでいる途中には、シグナルの発行
174 .RB ( SIGINT ,
175 .BR SIGQUIT ,
176 .BR SIGSTOP ,
177 .BR SIGSTOP )
178 は無効にされ、
179 それぞれに対応する文字 (通常は Ctrl-C, Ctrl-\e, Ctrl-Z, Ctrl-Y)
180 はそのままパスワードの一部として渡された。
181 libc 5.4.19 からは行編集が無効にされ、
182 したがってバックスペースなどもパスワードの一部とみなされるようになった。
183 .PP
184 .\"O For glibc2, if
185 .\"O .I /dev/tty
186 .\"O cannot be opened, the prompt is written to
187 .\"O .I stderr
188 .\"O and the password is read from
189 .\"O .IR stdin .
190 .\"O There is no limit on the length of the password.
191 .\"O Line editing is not disabled.
192 glibc2 では、
193 .I /dev/tty
194 がオープンできない場合は
195 .I prompt
196
197 .I stderr
198 に書き出され、パスワードは
199 .I stdin
200 から読み込まれた。
201 パスワードの長さには制限はなく、
202 行編集も無効にはされなかった。
203 .PP
204 .\"O According to the SUSv2, the value of
205 .\"O .B PASS_MAX
206 .\"O must be defined in
207 .\"O .I <limits.h>
208 .\"O in case it is smaller than 8, and can in any case be obtained using
209 .\"O .IR sysconf(_SC_PASS_MAX) .
210 .\"O However, POSIX.2 withdraws the constants
211 .\"O .B PASS_MAX
212 .\"O and
213 .\"O .BR _SC_PASS_MAX ,
214 .\"O and the function
215 .\"O .BR getpass ().
216 .\"O Libc4 and libc5 have never supported
217 .\"O .B PASS_MAX
218 .\"O or
219 .\"O .BR _SC_PASS_MAX .
220 .\"O Glibc2 accepts
221 .\"O .B _SC_PASS_MAX
222 .\"O and returns
223 .\"O .B BUFSIZ
224 .\"O (e.g., 8192).
225 SUSv2 によれば、
226 .B PASS_MAX
227 の値が 8 以下の場合は、この値は
228 .I <limits.h>
229 で定義されていなければならない。
230 いずれの場合でもこの値は
231 .I sysconf(_SC_PASS_MAX)
232 によって取得できる。
233 しかし、POSIX.2 は定数
234 .BR PASS_MAX ,
235 .B _SC_PASS_MAX
236 と関数
237 .BR getpass ()
238 を取り下げた。
239 libc4 と libc5 では、
240 .B PASS_MAX
241
242 .B _SC_PASS_MAX
243 は一度もサポートされたことはない。
244 glibc2 は
245 .B _SC_PASS_MAX
246 を受付け、
247 .B BUFSIZE
248 (例えば 8192) を返す。
249 .\"O .SH BUGS
250 .SH バグ
251 .\"O The calling process should zero the password as soon as possible to avoid
252 .\"O leaving the cleartext password visible in the process's address space.
253 この関数を呼び出したプロセスは、
254 できる限り早くそのパスワードを消去 (ゼロクリア) し、
255 クリアテキストのパスワードが
256 そのプロセスのアドレス空間で見えないようにすべきである。
257 .\"O .SH "SEE ALSO"
258 .SH 関連項目
259 .BR crypt (3)