.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
.\" <mtk.manpages@gmail.com>
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" References consulted:
.\" Linux libc source code
.\" Modified 2003-11-15 by aeb
.\" 2008-11-07, mtk, Added an example program for getpwnam_r().
.\"
+.\"*******************************************************************
+.\"
+.\" This file was generated with po4a. Translate the source file.
+.\"
+.\"*******************************************************************
+.\"
.\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
.\" all rights reserved.
.\" Translated 1997-12-18, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
.\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated & Modified 2005-10-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2008-12-24, Akihiro MOTOKI, LDP v3.14
+.\" Updated 2012-05-01, Akihiro MOTOKI <amotoki@gmail.com>
+.\" Updated 2013-08-16, Akihiro MOTOKI <amotoki@gmail.com>
.\"
-.TH GETPWNAM 3 2009-03-30 "GNU" "Linux Programmer's Manual"
-.\"O .SH NAME
-.SH ̾Á°
-.\"O getpwnam, getpwnam_r, getpwuid, getpwuid_r \- get password file entry
-getpwnam, getpwnam_r, getpwuid, getpwuid_r \- ¥Ñ¥¹¥ï¡¼¥É¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤Î¼èÆÀ
-.\"O .SH SYNOPSIS
-.SH ½ñ¼°
+.TH GETPWNAM 3 2013\-07\-22 GNU "Linux Programmer's Manual"
+.SH 名前
+getpwnam, getpwnam_r, getpwuid, getpwuid_r \- パスワードファイルのエントリーの取得
+.SH 書式
.nf
-.B #include <sys/types.h>
-.B #include <pwd.h>
+\fB#include <sys/types.h>\fP
+\fB#include <pwd.h>\fP
.sp
-.BI "struct passwd *getpwnam(const char *" name );
+\fBstruct passwd *getpwnam(const char *\fP\fIname\fP\fB);\fP
.sp
-.BI "struct passwd *getpwuid(uid_t " uid );
+\fBstruct passwd *getpwuid(uid_t \fP\fIuid\fP\fB);\fP
.sp
-.BI "int getpwnam_r(const char *" name ", struct passwd *" pwd ,
+\fBint getpwnam_r(const char *\fP\fIname\fP\fB, struct passwd *\fP\fIpwd\fP\fB,\fP
.br
-.BI " char *" buf ", size_t " buflen ", struct passwd **" result );
+\fB char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct passwd **\fP\fIresult\fP\fB);\fP
.sp
-.BI "int getpwuid_r(uid_t " uid ", struct passwd *" pwd ,
+\fBint getpwuid_r(uid_t \fP\fIuid\fP\fB, struct passwd *\fP\fIpwd\fP\fB,\fP
.br
-.BI " char *" buf ", size_t " buflen ", struct passwd **" result );
+\fB char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB, struct passwd **\fP\fIresult\fP\fB);\fP
.fi
.sp
.in -4n
-.\"O Feature Test Macro Requirements for glibc (see
-.\"O .BR feature_test_macros (7)):
-glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
-.RB ( feature_test_macros (7)
-»²¾È):
+glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照):
.in
.sp
.ad l
-.BR getpwnam_r (),
-.BR getpwuid_r ():
-_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
-_SVID_SOURCE || _POSIX_SOURCE
+\fBgetpwnam_r\fP(), \fBgetpwuid_r\fP():
+.RS 4
+_POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE
+|| _POSIX_SOURCE
+.RE
.ad b
-.\"O .SH DESCRIPTION
-.SH ÀâÌÀ
-.\"O The
-.\"O .BR getpwnam ()
-.\"O function returns a pointer to a structure containing
-.\"O the broken-out fields of the record in the password database
-.\"O (e.g., the local password file
-.\"O .IR /etc/passwd ,
-.\"O NIS, and LDAP)
-.\"O that matches the username
-.\"O .IR name .
-.BR getpwnam ()
-´Ø¿ô¤Ï¡¢¥æ¡¼¥¶Ì¾
-.I name
-¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
-Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹
-(¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÎã:
-¥í¡¼¥«¥ë¤Î¥Ñ¥¹¥ï¡¼¥É¥Õ¥¡¥¤¥ë
-.IR /etc/passwd ,
-NIS, LDAP)¡£
+.SH 説明
+\fBgetpwnam\fP() 関数は、ユーザー名 \fIname\fP にマッチするパスワードデータベースのエントリーを
+要素毎に分解し、各要素を格納した構造体へのポインターを返す (パスワードデータベースの例: ローカルのパスワードファイル \fI/etc/passwd\fP,
+NIS, LDAP)。
.PP
-.\"O The
-.\"O .BR getpwuid ()
-.\"O function returns a pointer to a structure containing
-.\"O the broken-out fields of the record in the password database
-.\"O that matches the user ID
-.\"O .IR uid .
-.BR getpwuid ()
-´Ø¿ô¤Ï¡¢¥æ¡¼¥¶ ID
-.I uid
-¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥¨¥ó¥È¥ê¤ò
-Í×ÁÇËè¤Ëʬ²ò¤·¡¢³ÆÍ×ÁǤò³ÊǼ¤·¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
+\fBgetpwuid\fP() 関数は、ユーザー ID \fIuid\fP にマッチするパスワードデータベースのエントリーを
+要素毎に分解し、各要素を格納した構造体へのポインターを返す。
.PP
-.\"O The
-.\"O .BR getpwnam_r ()
-.\"O and
-.\"O .BR getpwuid_r ()
-.\"O functions obtain the same information, but store the retrieved
-.\"O .I passwd
-.\"O structure in the space pointed to by
-.\"O .IR pwd .
-.BR getpwnam_r ()
-¤È
-.BR getpwuid_r ()
-´Ø¿ô¤Ï (¾åµ¤Î´Ø¿ô¤È) Ʊ¤¸¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¬¡¢
-¼èÆÀ¤·¤¿
-.I passwd
-¹½Â¤ÂΤò
-.I pwd
-¤¬»Ø¤¹Îΰè¤Ë³ÊǼ¤¹¤ë¡£
-.\"O This
-.\"O .I passwd
-.\"O structure contains pointers to strings, and these strings
-.\"O are stored in the buffer
-.\"O .I buf
-.\"O of size
-.\"O .IR buflen .
-¤³¤Î
-.I passwd
-¹½Â¤ÂΤˤÏʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬´Þ¤Þ¤ì¡¢
-¤³¤ì¤é¤Îʸ»úÎó¤Ï¥µ¥¤¥º
-.I buflen
-¤Î¥Ð¥Ã¥Õ¥¡
-.I buf
-¤Ë³ÊǼ¤µ¤ì¤ë¡£
-.\"O A pointer to the result (in case of success) or NULL (in case no entry
-.\"O was found or an error occurred) is stored in
-.\"O .IR *result .
-À®¸ù¤·¤¿¾ì¹ç
-.I *result
-¤Ë¤Ï·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
-¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ë¤Ï
-.I *result
-¤Ë¤Ï NULL ¤¬Æþ¤ë¡£
-.PP
-.\"O The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
-\fIpasswd\fP ¹½Â¤ÂΤϡ¢\fI<pwd.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
+\fIpasswd\fP 構造体は、\fI<pwd.h>\fP で以下のように定義されている:
.sp
.in +4n
.nf
struct passwd {
-.\"O char *pw_name; /* username */
-.\"O char *pw_passwd; /* user password */
-.\"O uid_t pw_uid; /* user ID */
-.\"O gid_t pw_gid; /* group ID */
-.\"O char *pw_gecos; /* real name */
-.\"O char *pw_dir; /* home directory */
-.\"O char *pw_shell; /* shell program */
- char *pw_name; /* ¥æ¡¼¥¶Ì¾ */
- char *pw_passwd; /* ¥æ¡¼¥¶¤Î¥Ñ¥¹¥ï¡¼¥É */
- uid_t pw_uid; /* ¥æ¡¼¥¶ ID */
- gid_t pw_gid; /* ¥°¥ë¡¼¥× ID */
- char *pw_gecos; /* ¼Â̾ */
- char *pw_dir; /* ¥Û¡¼¥à¥Ç¥£¥ì¥¯¥È¥ê */
- char *pw_shell; /* ¥·¥§¥ë¥×¥í¥°¥é¥à */
+ char *pw_name; /* ユーザー名 */
+ char *pw_passwd; /* ユーザーのパスワード */
+ uid_t pw_uid; /* ユーザー ID */
+ gid_t pw_gid; /* グループ ID */
+ char *pw_gecos; /* ユーザー情報 */
+ char *pw_dir; /* ホームディレクトリ */
+ char *pw_shell; /* シェルプログラム */
};
.fi
.in
.PP
-.\"O The maximum needed size for
-.\"O .I buf
-.\"O can be found using
-.\"O .BR sysconf (3)
-.\"O with the argument
-.\"O .BR _SC_GETPW_R_SIZE_MAX .
-.I buf
-¤ËºÇÂçɬÍפʥµ¥¤¥º¤Ï¡¢
-.BR sysconf (3)
-¤Ë°ú¤¿ô
-.B _SC_GETPW_R_SIZE_MAX
-¤ò»ØÄꤷ¤Æ¼Â¹Ô¤¹¤ë¤³¤È¤Çʬ¤«¤ë¡£
-.\"O .SH "RETURN VALUE"
-.SH ÊÖ¤êÃÍ
-.\"O The
-.\"O .BR getpwnam ()
-.\"O and
-.\"O .BR getpwuid ()
-.\"O functions return a pointer to a
-.\"O .I passwd
-.\"O structure, or NULL if the matching entry is not found or
-.\"O an error occurs.
-.BR getpwnam ()
-¤È
-.BR getpwuid ()
-´Ø¿ô¤Ï¡¢
-.I passwd
-¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
-°ìÃפ¹¤ë¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤ä¡¢¥¨¥é¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï NULL ¤òÊÖ¤¹¡£
-.\"O If an error occurs,
-.\"O .I errno
-.\"O is set appropriately.
-.\"O If one wants to check
-.\"O .I errno
-.\"O after the call, it should be set to zero before the call.
-¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
-.I errno
-¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
-¸Æ¤Ó½Ð¤·¤Î¸å¤Ç
-.I errno
-¤ò¥Á¥§¥Ã¥¯¤·¤¿¤¤¾ì¹ç¤Ï¡¢
-¸Æ¤Ó½Ð¤·¤ÎÁ°¤Ë (¤³¤ÎÃͤò) 0 ¤ËÀßÄꤷ¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
+これらのフィールドの詳しい情報については \fBpasswd\fP(5) を参照のこと。
+.PP
+\fBgetpwnam_r\fP() と \fBgetpwuid_r\fP() 関数は、それぞれ\fBgetpwnam\fP() と
+\fBgetpwuid\fP() と同じ情報を取得するが、取得した \fIpasswd\fP 構造体を
+\fIpwd\fP が指す領域に格納する。\fIpasswd\fP 構造体のメンバーが指す文字列は、
+サイズ \fIbuflen\fP のバッファー \fIbuf\fP に格納される。成功した場合
+\fI*result\fP には結果へのポインターが格納される。エントリーが見つからなかった
+場合やエラーが発生した場合には \fI*result\fP には NULL が入る。
+.PP
+呼び出し
+
+ sysconf(_SC_GETPW_R_SIZE_MAX)
+
+は、 \fIerrno\fP を変更せずに \-1 を返すか、 \fIbuf\fP の初期サイズの推奨値を
+返す。(このサイズが小さすぎる場合、呼び出しは \fBERANGE\fP で失敗し、この
+場合には呼び出し側はバッファーを大きくしてから再度呼び出すことができる。)
+.SH 返り値
+\fBgetpwnam\fP() と \fBgetpwuid\fP() 関数は、 \fIpasswd\fP 構造体へのポインターを返す。
+一致するエントリーが見つからなかった場合や、エラーが発生した場合は NULL を返す。 エラーが起こった場合、 \fIerrno\fP が適切に設定される。
+呼び出しの後で \fIerrno\fP をチェックしたい場合は、 呼び出しの前に (この値を) 0 に設定しておくべきである。
.LP
-.\"O The return value may point to a static area, and may be overwritten
-.\"O by subsequent calls to
-.\"O .BR getpwent (3),
-.\"O .BR getpwnam (),
-.\"O or
-.\"O .BR getpwuid ().
-.\"O (Do not pass the returned pointer to
-.\"O .BR free (3).)
-ÊÖ¤êÃͤÏÀÅŪ¤ÊÎΰè¤ò»Ø¤·¤Æ¤ª¤ê¡¢¤½¤Î¸å¤Î
-.BR getpwent (3),
-.BR getpwnam (),
-.BR getpwuid ()
-¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-(ÊÖ¤µ¤ì¤¿¥Ý¥¤¥ó¥¿¤ò
-.BR free (3)
-¤ËÅϤµ¤Ê¤¤¤³¤È¡£)
+返り値は静的な領域を指しており、その後の \fBgetpwent\fP(3), \fBgetpwnam\fP(), \fBgetpwuid\fP()
+の呼び出しで上書きされるかもしれない。 (返されたポインターを \fBfree\fP(3) に渡さないこと。)
.LP
-.\"O On success,
-.\"O .BR getpwnam_r ()
-.\"O and
-.\"O .BR getpwuid_r ()
-.\"O return zero, and set
-.\"O .IR *result
-.\"O to
-.\"O .IR pwd .
-.\"O If no matching password record was found,
-.\"O these functions return 0 and store NULL in
-.\"O .IR *result .
-.\"O In case of error, an error number is returned, and NULL is stored in
-.\"O .IR *result .
-À®¸ù¤¹¤ë¤È¡¢
-.BR getpwnam_r ()
-¤È
-.BR getpwuid_r ()
-¤Ï 0 ¤òÊÖ¤·¡¢
-.I *result
-¤Ë
-.I pwd
-¤òÀßÄꤹ¤ë¡£
-¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¹¥ï¡¼¥É¡¦¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
-0 ¤òÊÖ¤·¡¢
-.I *result
-¤Ë NULL ¤òÀßÄꤹ¤ë¡£
-¥¨¥é¡¼¤Î¾ì¹ç¡¢¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤·¡¢
-.I *result
-¤Ë NULL ¤òÀßÄꤹ¤ë¡£
-.\"O .SH ERRORS
-.SH ¥¨¥é¡¼
-.TP
-.\"O .BR 0 " or " ENOENT " or " ESRCH " or " EBADF " or " EPERM " or ... "
-.BR 0 " ¤Þ¤¿¤Ï " ENOENT " ¤Þ¤¿¤Ï " ESRCH " ¤Þ¤¿¤Ï " EBADF " ¤Þ¤¿¤Ï " EPERM " ¤Þ¤¿¤Ï ... "
-.\"O The given
-.\"O .I name
-.\"O or
-.\"O .I uid
-.\"O was not found.
-»ØÄꤵ¤ì¤¿
-.I name
-¤Þ¤¿¤Ï
-.I uid
-¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
-.TP
-.B EINTR
-.\"O A signal was caught.
-¥·¥°¥Ê¥ë¤¬¥¥ã¥Ã¥Á¤µ¤ì¤¿¡£
-.TP
-.B EIO
-.\"O I/O error.
-I/O ¥¨¥é¡¼¡£
-.TP
-.B EMFILE
-.\"O The maximum number
-.\"O .RB ( OPEN_MAX )
-.\"O of files was open already in the calling process.
-¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Ë¤ª¤¤¤Æ¡¢
-´û¤ËºÇÂç¿ô (OPEN_MAX) ¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
-.TP
-.B ENFILE
-.\"O The maximum number of files was open already in the system.
-¥·¥¹¥Æ¥à¾å¤Ç´û¤ËºÇÂç¿ô¤Î¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤ë¡£
-.TP
-.B ENOMEM
+成功すると、 \fBgetpwnam_r\fP() と \fBgetpwuid_r\fP() は 0 を返し、 \fI*result\fP に \fIpwd\fP
+を設定する。 マッチするパスワードエントリーが見つからなかった場合には、 0 を返し、 \fI*result\fP に NULL を設定する。
+エラーの場合、エラー番号を返し、 \fI*result\fP に NULL を設定する。
+.SH エラー
+.TP
+\fB0\fP または \fBENOENT\fP または \fBESRCH\fP または \fBEBADF\fP または \fBEPERM\fP または ...
+指定された \fIname\fP または \fIuid\fP が見つからなかった。
+.TP
+\fBEINTR\fP
+シグナルが捕捉された。
+.TP
+\fBEIO\fP
+I/O エラー。
+.TP
+\fBEMFILE\fP
+呼び出し元プロセスがオープンしているファイル数が すでに上限 (\fBOPEN_MAX\fP) であった。
+.TP
+\fBENFILE\fP
+システムでオープンされているファイル数がすでに上限であった。
+.TP
+\fBENOMEM\fP
.\" not in POSIX
-.\"O Insufficient memory to allocate
-.\"O .I passwd
-.\"O structure.
-.\"O .\" This structure is static, allocated 0 or 1 times. No memory leak. (libc45)
-.\" POSIX ¤Ë¤Ï¤Ê¤¤¡£
-.I passwd
-¹½Â¤ÂΤò³ä¤êÅö¤Æ¤ë¤¿¤á¤Î¥á¥â¥ê¤¬ÉÔ½½Ê¬¡£
-.\" ¤³¤Î¹½Â¤ÂΤÏÀÅŪ¤Ç¤¢¤ê¡¢0 ²ó¤Þ¤¿¤Ï 1 ²ó³ä¤êÅö¤Æ¤é¤ì¤ë¡£
-.\" ¥á¥â¥ê¥ê¡¼¥¯¤Ï̵¤¤¡£(libc45)
-.TP
-.B ERANGE
-.\"O Insufficient buffer space supplied.
-Í¿¤¨¤é¤ì¤¿¥Ð¥Ã¥Õ¥¡¶õ´Ö¤¬ÉÔ½½Ê¬¤Ç¤¢¤ë¡£
-.\"O .SH FILES
-.SH ¥Õ¥¡¥¤¥ë
-.TP
-.I /etc/passwd
-.\"O local password database file
-¥í¡¼¥«¥ë¤Î¥Ñ¥¹¥ï¡¼¥É¡¦¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë
-.\"O .SH "CONFORMING TO"
-.SH ½àµò
-SVr4, 4.3BSD, POSIX.1-2001.
-.\"O .SH NOTES
-.SH Ãí°Õ
-.\"O The formulation given above under "RETURN VALUE" is from POSIX.1-2001.
-¾åµ¤Î¡ÖÊÖ¤êÃ͡װʲ¼¤Îµ½Ò¤Ï POSIX.1-2001 ¤Ëµò¤ë¡£
-.\"O It does not call "not found" an error, and hence does not specify what value
-.\"O .I errno
-.\"O might have in this situation.
-.\"O But that makes it impossible to recognize
-.\"O errors.
-.\"O One might argue that according to POSIX
-.\"O .I errno
-.\"O should be left unchanged if an entry is not found.
-.\"O Experiments on various
-.\"O Unix-like systems show that lots of different values occur in this
-.\"O situation: 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM and probably others.
-¤³¤Îɸ½à¤Ï¡Ö(¥¨¥ó¥È¥ê¤¬) ¸«¤Ä¤«¤é¤Ê¤¤¤³¤È¡×¤ò¥¨¥é¡¼¤È¤·¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢
-¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë
-.I errno
-¤¬¤É¤Î¤è¤¦¤ÊÃͤˤʤ뤫¤òÄê¤á¤Æ¤¤¤Ê¤¤¡£
-¤½¤Î¤¿¤á¡¢¥¨¥é¡¼¤òǧ¼±¤¹¤ë¤³¤È¤ÏÉÔ²Äǽ¤Ç¤¢¤ë¡£
-POSIX ¤Ë½àµò¤·¤Æ¡¢¥¨¥ó¥È¥ê¤¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï
-.I errno
-¤òÊѹ¹¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡¢¤È¼çÄ¥¤¹¤ë¿Í¤â¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-ÍÍ¡¹¤Ê Unix ·Ï¤Î¥·¥¹¥Æ¥à¤Ç»î¤·¤Æ¤ß¤ë¤È¡¢¤½¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï
-0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM ¤È¤¤¤Ã¤¿ÍÍ¡¹¤ÊÃͤ¬ÊÖ¤µ¤ì¤ë¡£
-¾¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
-.\"O .\" more precisely:
-.\"O .\" AIX 5.1 - gives ESRCH
-.\"O .\" OSF1 4.0g - gives EWOULDBLOCK
-.\"O .\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
-.\"O .\" glibc since version 2.7 - give 0
-.\"O .\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
-.\"O .\" SunOS 5.8 - gives EBADF
-.\"O .\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
-.\" ¤è¤êÀµ³Î¤Ë¤Ï:
-.\" AIX 5.1 ¤Ï ESRCH ¤òÊÖ¤¹¡£
-.\" OSF1 4.0g ¤Ï EWOULDBLOCK ¤òÊÖ¤¹¡£
-.\" libc, glibc (¥Ð¡¼¥¸¥ç¥ó 2.6 ¤Þ¤Ç), Irix 6.5 ¤Ï ENOENT ¤òÊÖ¤¹¡£
-.\" glibc (¥Ð¡¼¥¸¥ç¥ó 2.7 °Ê¹ß) ¤Ï 0 ¤òÊÖ¤¹¡£
-.\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 ¤Ï EPERM ¤òÊÖ¤¹¡£
-.\" SunOS 5.8 ¤Ï EBADF ¤òÊÖ¤¹¡£
-.\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 ¤Ï 0 ¤òÊÖ¤¹¡£
+.\" This structure is static, allocated 0 or 1 times. No memory leak. (libc45)
+\fIpasswd\fP 構造体に割り当てるメモリーが十分なかった。
+.TP
+\fBERANGE\fP
+与えられたバッファー空間が不十分である。
+.SH ファイル
+.TP
+\fI/etc/passwd\fP
+ローカルのパスワードデータベースファイル
+.SH 属性
+.SS "マルチスレッディング (pthreads(7) 参照)"
+関数 \fBgetpwnam\fP() と \fBgetpwuid\fP() はスレッドセーフではない。
+.LP
+関数 \fBgetpwnam_r\fP() と \fBgetpwuid_r\fP() はスレッドセーフである。
+.SH 準拠
+SVr4, 4.3BSD, POSIX.1\-2001. \fIpw_gecos\fP フィールドは POSIX では規定されていないが、
+ほとんどの実装に存在する。
+.SH 注意
+.\" more precisely:
+.\" AIX 5.1 - gives ESRCH
+.\" OSF1 4.0g - gives EWOULDBLOCK
+.\" libc, glibc up to version 2.6, Irix 6.5 - give ENOENT
+.\" glibc since version 2.7 - give 0
+.\" FreeBSD 4.8, OpenBSD 3.2, NetBSD 1.6 - give EPERM
+.\" SunOS 5.8 - gives EBADF
+.\" Tru64 5.1b, HP-UX-11i, SunOS 5.7 - give 0
+上記の「返り値」以下の記述は POSIX.1\-2001 に拠る。 この標準は「(エントリーが) 見つからないこと」をエラーとしていないので、
+そのような場合に \fIerrno\fP がどのような値になるかを定めていない。 そのため、エラーを認識することは不可能である。 POSIX
+に準拠して、エントリーが見つからない場合は \fIerrno\fP を変更しないようにすべきである、と主張する人もいるかもしれない。 様々な UNIX
+系のシステムで試してみると、そのような場合には 0, ENOENT, EBADF, ESRCH, EWOULDBLOCK, EPERM
+といった様々な値が返される。 他の値が返されるかもしれない。
-.\"O The
-.\"O .I pw_dir
-.\"O field contains the name of the initial working directory of the user.
-¥Õ¥£¡¼¥ë¥É
-.I pw_dir
-¤Ë¤Ï¡¢¥æ¡¼¥¶¤Îºî¶È¥Ç¥£¥ì¥¯¥È¥ê̾¤Î½é´üÃͤ¬³ÊǼ¤µ¤ì¤ë¡£
-.\"O Login programs use the value of this field to initialize the
-.\"O .B HOME
-.\"O environment variable for the login shell.
-.\"O An application that wants to determine its user's home directory
-.\"O should inspect the value of
-.\"O .B HOME
-.\"O (rather than the value
-.\"O .IR getpwuid(getuid())\->pw_dir )
-.\"O since this allows the user to modify their notion of
-.\"O "the home directory" during a login session.
-.\"O To determine the (initial) home directory of another user,
-.\"O it is necessary to use
-.\"O .I getpwnam("username")\->pw_dir
-.\"O or similar.
-¥í¥°¥¤¥ó¥×¥í¥»¥¹¤Ï¡¢¤³¤Î¥Õ¥£¡¼¥ë¥É¤ÎÃͤò»È¤Ã¤Æ¡¢
-¥í¥°¥¤¥ó¥·¥§¥ë¤Î
-.B HOME
-´Ä¶ÊÑ¿ô¤ò½é´ü²½¤¹¤ë¡£
-¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¡¢¥æ¡¼¥¶¤Î¥Û¡¼¥à¡¦¥Ç¥£¥ì¥¯¥È¥ê¤ò·èÄꤹ¤ë¾ì¹ç¤Ë¤Ï¡¢
-.RI ( getpwuid(getuid())\->pw_dir
-¤ÎÃͤǤϤʤ¯)
-.B HOME
-¤ÎÃͤò¸¡ºº¤¹¤ë¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
-¤Ê¤¼¤Ê¤é¡¢¤³¤Î¤è¤¦¤Ë¤¹¤ë¤³¤È¤Ç¡¢¥æ¡¼¥¶¤¬¥í¥°¥¤¥ó¡¦¥»¥Ã¥·¥ç¥óÃæ¤Ç
-¡Ö¥Û¡¼¥à¡¦¥Ç¥£¥ì¥¯¥È¥ê¡×¤Î°ÕÌ£¤òÊѹ¹¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ë¤«¤é¤Ç¤¢¤ë¡£
-Ê̤Υ桼¥¶¤Î¥Û¡¼¥à¡¦¥Ç¥£¥ì¥¯¥È¥ê (¤Î½é´üÃÍ) ¤òÃΤë¤Ë¤Ï
-.I getpwnam("username")\->pw_dir
-¤«Æ±ÍͤÎÊýË¡¤ò»È¤¦É¬Íפ¬¤¢¤ë¡£
-.\"O .SH EXAMPLE
-.SH Îã
-.\"O The program below demonstrates the use of
-.\"O .BR getpwnam_r ()
-.\"O to find the full username and user ID for the username
-.\"O supplied as a command-line argument.
-°Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï
-.BR getpwnam_r ()
-¤Î»ÈÍÑÎã¤ò¼¨¤·¤¿¤â¤Î¤Ç¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤¿ô¤ÇÅϤµ¤ì¤¿¥æ¡¼¥¶Ì¾¤ËÂФ¹¤ë
-´°Á´¤Ê¥æ¡¼¥¶Ì¾¤È¥æ¡¼¥¶ ID ¤òõ¤¹¤â¤Î¤Ç¤¢¤ë¡£
+フィールド \fIpw_dir\fP には、ユーザーの作業ディレクトリ名の初期値が格納される。 ログインプロセスは、このフィールドの値を使って、
+ログインシェルの \fBHOME\fP 環境変数を初期化する。 アプリケーションが、ユーザーのホームディレクトリを決定する場合には、
+(\fIgetpwuid(getuid())\->pw_dir\fP の値ではなく) \fBHOME\fP の値を検査するようにすべきである。
+なぜなら、このようにすることで、ユーザーがログインセッション中で 「ホームディレクトリ」の意味を変更できるようになるからである。
+別のユーザーのホームディレクトリ (の初期値) を知るには \fIgetpwnam("username")\->pw_dir\fP
+か同様の方法を使う必要がある。
+.SH 例
+以下のプログラムは \fBgetpwnam_r\fP() の使用例を示したもので、コマンドライン引き数で渡されたユーザー名に対する
+完全なユーザー名とユーザー ID を探すものである。
.nf
#include <pwd.h>
int s;
if (argc != 2) {
- fprintf(stderr, "Usage: %s username\\n", argv[0]);
+ fprintf(stderr, "Usage: %s username\en", argv[0]);
exit(EXIT_FAILURE);
}
bufsize = sysconf(_SC_GETPW_R_SIZE_MAX);
-.\"O if (bufsize == \-1) /* Value was indeterminate */
-.\"O bufsize = 16384; /* Should be more than enough */
- if (bufsize == \-1) /* Ãͤò·èÄê¤Ç¤¤Ê¤«¤Ã¤¿ */
- bufsize = 16384; /* ½½Ê¬Â礤ÊÃͤˤ¹¤Ù¤ */
+ if (bufsize == \-1) /* 値を決定できなかった */
+ bufsize = 16384; /* 十分大きな値にすべき */
buf = malloc(bufsize);
if (buf == NULL) {
s = getpwnam_r(argv[1], &pwd, buf, bufsize, &result);
if (result == NULL) {
if (s == 0)
- printf("Not found\\n");
+ printf("Not found\en");
else {
errno = s;
perror("getpwnam_r");
exit(EXIT_FAILURE);
}
- printf("Name: %s; UID: %ld\\n", pwd.pw_gecos, (long) pwd.pw_uid);
+ printf("Name: %s; UID: %ld\en", pwd.pw_gecos, (long) pwd.pw_uid);
exit(EXIT_SUCCESS);
}
.fi
-.\"O .SH "SEE ALSO"
-.SH ´ØÏ¢¹àÌÜ
-.BR endpwent (3),
-.BR fgetpwent (3),
-.BR getgrnam (3),
-.BR getpw (3),
-.BR getpwent (3),
-.BR getspnam (3),
-.BR putpwent (3),
-.BR setpwent (3),
-.BR passwd (5)
+.SH 関連項目
+\fBendpwent\fP(3), \fBfgetpwent\fP(3), \fBgetgrnam\fP(3), \fBgetpw\fP(3),
+\fBgetpwent\fP(3), \fBgetspnam\fP(3), \fBputpwent\fP(3), \fBsetpwent\fP(3), \fBpasswd\fP(5)
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。