1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright 1995 James R. Van Zandt <jrv@vanzandt.mv.com>
.\"
.\" 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.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Changed Tue Sep 19 01:49:29 1995, aeb: moved from man2 to man3
.\" added ref to /etc/utmp, added BUGS section, etc.
.\" modified 2003 Walter Harms, aeb - added getlogin_r, note on stdin use
.\"
.\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
.\" Translated 1998-03-01, NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated & Modified 1999-08-21, NAKANO Takeo <nakano@apm.seikei.ac.jp>
.\" Updated & Modified 2005-03-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.TH GETLOGIN 3 2007-07-26 "GNU" "Linux Programmer's Manual"
.SH ̾
getlogin, getlogin_r, cuserid \- 桼̾
.SH
.B #include <unistd.h>
.sp
.B "char *getlogin(void);"
.br
.BI "int getlogin_r(char *" buf ", size_t " bufsize );
.sp
.B #include <stdio.h>
.sp
.BI "char *cuserid(char *" string );
.sp
.in -4n
glibc εǽޥ
.RB ( feature_test_macros (7)
):
.in
.sp
.BR getlogin_r ():
_REENTRANT || _POSIX_C_SOURCE\ >=\ 199506L
.br
.BR cuserid ():
_XOPEN_SOURCE
.SH
.BR getlogin ()
ϡߤΥץü˥Ƥ桼̾ʸؤ
ݥ֤桼̾Ǥʤ null ݥ֤
ʸŪΰ˳ƤƤꡢθǤδؿ
.BR cuserid ()
ƤӽФ줿ݤ˾뤳Ȥ롣
.PP
.BR getlogin_r ()
ϡ嵭Ʊ桼̾礭
.I bufsize
.I buf
֤
.PP
.BR cuserid ()
ϡߤΥץμ¸桼ID б桼̾
ʸؤΥݥ֤
\fIstring\fP null ݥʳξ硢\fIstring\fP ϾʤȤ
\fBL_cuserid\fP ʸݻǤǤʤФʤʤ
\fIstring\fP null ݥξˤϡŪΰ֤줿ʸؤ
ݥ֤롣ʸŪΰ˳ƤƤꡢ
δؿ
.BR getlogin ()
ƤӽФ줿ݤ˾뤳Ȥ롣
.PP
ޥ \fBL_cuserid\fP integer ǡ桼̾ݻ뤿
ɬפĹ \fBL_cuserid\fP \fBstdio.h\fP
롣
.PP
δؿȤȡץ¹ԤƤ桼
.RB ( cuserid ())
Υå˥Ƥ桼
.RB ( getlogin ())
Τꤹ뤳ȤǤ
( set-user-ID ץǤϡ㤦Ȥ⤢)
.PP
ƤŪǤϡ桼ˤϴĶѿ \fBLOGNAME\fP Ĵ
ۤǤ롣LOGNAME ѿϥ桼ͳǤΤ
бǽˤʤ롣
.SH ֤
.BR getlogin ()
ϥ桼̾ؤΥݥ֤Ԥ NULL ֤
.BR getlogin_r ()
0 ֤Ԥ 0 ʳ֤
.SH 顼
POSIX ǤϰʲΥ顼ꤵƤ:
.TP
.B EMFILE
ƤӽФץץƤեǤ˥ץ
¤ãƤ롣
.TP
.B ENFILE
ƥΤǥץƤեǤ˾¤ãƤ롣
.TP
.B ENXIO
ƤӽФץˤüʤ
.TP
.B ERANGE
(getlogin_r)
(ü NULL ХȤޤ) 桼̾Ĺ
.I bufsize
Ĺ
.LP
Linux/glibc ˤϰʲΥ顼⤢롣
.TP
.B ENOENT
utmp եб륨ȥ꤬ʤä
.TP
.B ENOMEM
passwd ¤ΤƤΤ˽ʬʥ꤬ʤ
.SH ե
.TP
\fI/etc/passwd\fP
ѥɥǡ١Υե
.TP
\fI/var/run/utmp\fP
(Ūˤ \fI/etc/utmp\fP ȤƤ;
libc ˤ \fI/var/adm/utmp\fP ȤΤ⤢)
.SH
.BR getlogin ()
.BR getlogin_r ()
POSIX.1-2001 ǵꤵƤ롣
System V ˤ
.BR cuserid ()
뤬
ϼ¸桼 ID ǤϤʤ¥桼 ID Ѥ롣
.BR cuserid ()
ؿ 1988 ǯǤ POSIX ˤϴޤޤƤ
1990 ǯǤǤϺ줿
SUSv2 ¸ߤPOSIX.1-2001 Ǻ줿
.LP
OpenBSD ˤ
.BR getlogin ()
.BR setlogin ()
ꡢ
åб桼̾롣üʤ
åξǤäƤ⡢б桼̾롣
.SH Х
ǰʤ顢
.BR getlogin ()
ޤΤϤۤȤǤϤʤ̤Υץब utmp ե
ƤޤȡưʤȤ⤢롣ޤ̾κǽ 8 ʸ
֤ʤȤ¿ޤץ椷Ƥ tty
ߥƤ桼ϡץ¹Ԥ
桼Ǥʤ⤢롣
ƥӤˤ
.BR getlogin ()
Ѥ٤ǤϤʤ
.LP
glibc POSIX ͤˤϽäƤ餺
.I /dev/tty
ǤϤʤ
.I "ɸ (stdin)"
ȤϥХǤ롣
(SunOS 5.8 HP-UX 11.11 FreeBSD 4.8 Ȥä¾κǶΥƥϤ⡢
.I ɸ
쥯Ȥ줿Ǥ֤̾)
.LP
.BR cuserid ()
ԤäƤΤºݤΤȤΤäƤԤï⤤ʤ;
ܿץǤ
.BR cuserid ()
ϻȤ٤ǤϤʤ
ȤɤʥץǤȤ٤ǤϤʤ:
.I getpwuid(geteuid())
Ѥ٤Ǥ
(줬տޤƤ뤳ȤʤС)
.BR cuserid ()
ϡֻȤʤפȡ
.SH Ϣ
.BR geteuid (2),
.BR getuid (2)
|