OSDN Git Service

c855bd97a2fcbba57c44643cdd14a4afdc7d7e60
[linuxjm/LDP_man-pages.git] / release / man3 / getpw.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 19:23:25 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
29 .\"
30 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
31 .\"     all rights reserved.
32 .\" Translated 1997-12-19, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
33 .\" Modified 1999-12-08, Kentaro Shirakata <argrath@yo.rim.or.jp>
34 .\" Modified 2005-09-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\" Modified 2008-07-23, Kentaro Shirakata <argrath@ub32.org>
36 .\"
37 .TH GETPW 3 2010-10-21 "GNU" "Linux Programmer's Manual"
38 .SH 名前
39 getpw \- パスワード行エントリを取得する
40 .SH 書式
41 .nf
42 .BR "#define _GNU_SOURCE" "             /* feature_test_macros(7) 参照 */"
43 .B #include <sys/types.h>
44 .B #include <pwd.h>
45 .sp
46 .BI "int getpw(uid_t " uid ", char *" buf );
47 .fi
48 .SH 説明
49 .BR getpw ()
50 関数は、バッファ \fIbuf\fP に指定ユーザ ID  \fIuid\fP の
51 パスワード行エントリを取得する。
52 返されるバッファは、以下の形式の行を含む。
53 .sp
54 .in +4n
55 .B name:passwd:uid:gid:gecos:dir:shell
56 .in
57 .PP
58 \fIpasswd\fP 構造体は \fI<pwd.h>\fP で以下のように定義されている:
59 .sp
60 .in +4n
61 .nf
62 struct passwd {
63     char   *pw_name;       /* username */
64     char   *pw_passwd;     /* user password */
65     uid_t   pw_uid;        /* user ID */
66     gid_t   pw_gid;        /* group ID */
67     char   *pw_gecos;      /* user information */
68     char   *pw_dir;        /* home directory */
69     char   *pw_shell;      /* shell program */
70 };
71 .fi
72 .in
73 .PP
74 この構造体のフィールドの詳細は
75 .BR passwd (5)
76 を参照のこと。
77 .SH 返り値
78 .BR getpw ()
79 関数は、成功した場合 0 を返す; エラーが発生した場合 \-1 を返し、エラーを
80 示すために
81 .I error
82 がセットされる。
83 .SH エラー
84 .TP
85 .B EINVAL
86 .I buf
87 が NULL。
88 .TP
89 .B ENOENT
90 .I uid
91 に対応するユーザがいない。
92 .TP
93 .B ENOMEM
94 .I passwd
95 構造体を割り当てるためのメモリが不十分。
96 .SH ファイル
97 .TP
98 .I /etc/passwd
99 パスワードデータベースファイル
100 .SH 準拠
101 SVr2
102 .SH バグ
103 .BR getpw ()
104 関数は、与えられたバッファ
105 .I buf
106 がオーバーフローするかもしれないので危険である。
107 この関数は
108 .BR getpwuid (3)
109 によって古いものとなった。
110 .SH 関連項目
111 .BR endpwent (3),
112 .BR fgetpwent (3),
113 .BR getpwent (3),
114 .BR getpwnam (3),
115 .BR getpwuid (3),
116 .BR putpwent (3),
117 .BR setpwent (3),
118 .BR passwd (5)