OSDN Git Service

(split) Fixed #25191 (typo in fenv.3).
[linuxjm/LDP_man-pages.git] / release / man3 / getutent.3
1 .\" Copyright 1995 Mark D. Roth (roth@uiuc.edu)
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 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Solaris manpages
26 .\"
27 .\" Modified Thu Jul 25 14:43:46 MET DST 1996 by Michael Haardt
28 .\"     <michael@cantor.informatik.rwth-aachen.de>
29 .\"
30 .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
31 .\" Translated 1998-03-15, NAKANO Takeo <nakano@apm.seikei.ac.jp>
32 .\" Updated 2001-10-16, Kentaro Shirakata <argrath@ub32.org>
33 .\" Updated 2002-01-03, Kentaro Shirakata <argrath@ub32.org>
34 .\" Updated 2005-03-18, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\" Updated 2008-08-11, Akihiro MOTOKI, LDP v3.05
36 .\"
37 .TH GETUTENT 3 2008-06-29 "" "Linux Programmer's Manual"
38 .SH Ì¾Á°
39 getutent, getutid, getutline, pututline, setutent, endutent, utmpname \-
40 utmp ¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥È¥ê¤Ë¥¢¥¯¥»¥¹¤¹¤ë
41 .SH ½ñ¼°
42 .B #include <utmp.h>
43 .sp
44 .B struct utmp *getutent(void);
45 .br
46 .BI "struct utmp *getutid(struct utmp *" ut );
47 .br
48 .BI "struct utmp *getutline(struct utmp *" ut );
49 .sp
50 .BI "struct utmp *pututline(struct utmp *" ut );
51 .sp
52 .B void setutent(void);
53 .br
54 .B void endutent(void);
55 .sp
56 .BI "int utmpname(const char *" file );
57 .SH ÀâÌÀ
58 ¿·¤·¤¤¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢¤³¤ì¤é¤Î´Ø¿ô¤Î "utmpx" ÈǤò»ÈÍѤ¹¤Ù¤­¤Ç¤¢¤ë¡£
59 ¤³¤ì¤é¤Ï POSIX.1 ¤Çµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£¡Ö½àµò¡×¤ÎÀá¤ò»²¾È¡£
60
61 .BR utmpname ()
62 ¤Ï¡¢Â¾¤Î utmp ´Ø¿ô¤¬¥¢¥¯¥»¥¹¤¹¤ë (utmp ¥Õ¥©¡¼¥Þ¥Ã¥È¤Î)
63 ¥Õ¥¡¥¤¥ë¤Î̾Á°¤ò»ØÄꤹ¤ë¡£Â¾¤Î´Ø¿ô¤ò»È¤¦Á°¤Ë
64 .BR utmpname ()
65 ¤ò»È¤Ã¤Æ
66 ¥Õ¥¡¥¤¥ë̾¤Î»ØÄê¤ò¹Ô¤ï¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢ \fI<path.h>\fP ¤Ç
67 ÄêµÁ¤µ¤ì¤Æ¤¤¤ë \fB_PATH_UTMP\fP ¤¬¥Õ¥¡¥¤¥ë̾¤È¤ß¤Ê¤µ¤ì¤ë¡£
68 .PP
69 .BR setutent ()
70 ¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤ò utmp ¥Õ¥¡¥¤¥ë¤ÎÀèƬ¤Ë°ÜÆ°¤¹¤ë¡£
71 °ìÈÌŪ¤Ë¤Ï¡¢Â¾¤Î´Ø¿ô¤ò»È¤¦Á°¤Ë¤³¤Î´Ø¿ô¤ò¸Æ¤Ó½Ð¤·¤Æ¤ª¤¯¤ÈÎɤ¤¤À¤í¤¦¡£
72 .PP
73 .BR endutent ()
74 ¤Ï utmp ¥Õ¥¡¥¤¥ë¤ò¥¯¥í¡¼¥º¤¹¤ë¡£¥æ¡¼¥¶¡¼¥³¡¼¥É¤Ç
75 ¾¤Î´Ø¿ô¤ò»È¤Ã¤Æ¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¥¢¥¯¥»¥¹¤ò¹Ô¤Ã¤¿»þ¤Ï¡¢ºÇ¸å¤Ë¤³¤Î´Ø¿ô¤ò
76 ¸Æ¤Ó½Ð¤¹¤Ù¤­¤Ç¤¢¤ë¡£
77 .PP
78 .BR getutent ()
79 ¤Ï utmp ¥Õ¥¡¥¤¥ë¤Î¸½ºß¤Î¥Õ¥¡¥¤¥ë°ÌÃÖ¤«¤é°ì¹ÔÆɤ߹þ¤ß¡¢
80 ¹Ô¤Î³Æ¥Õ¥£¡¼¥ë¥É¤ÎÆâÍƤò¼ý¤á¤¿¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤òÊÖ¤¹¡£
81 ¤³¤Î¹½Â¤ÂΤÎÄêµÁ¤Ï
82 .BR utmp (5)
83 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¡£
84 .PP
85 .BR getutid ()
86 ¤Ï¡¢ utmp ¥Õ¥¡¥¤¥ëÃæ¤Î¸½ºß¤Î°ÌÃÖ¤«¤é½çÊý¸þ
87 (ËöÈø¤Ë¸þ¤«¤¦Êý¸þ) ¤Ø \fIut\fP ¤Ë´ð¤¯¸¡º÷¤ò¹Ô¤¦¡£ \fIut\fP\->ut_type ¤¬
88 \fBRUN_LVL\fP, \fBBOOT_TIME\fP, \fBNEW_TIME\fP, \fBOLD_TIME\fP ¤Î
89 ¤¤¤º¤ì¤«¤Ê¤é¡¢
90 .BR getutid ()
91 ¤Ï \fBut_type\fP ¥Õ¥£¡¼¥ë¥É¤¬
92 \fIut\fP\->ut_type ¤Ë°ìÃפ¹¤ëºÇ½é¤Î¥¨¥ó¥È¥ê¤òõ¤¹¡£
93 \fIut\fP\->ut_type ¤¬ \fBINIT_PROCESS\fP, \fBLOGIN_PROCESS\fP,
94 \fBUSER_PROCESS\fP, \fBDEAD_PROCESS\fP ¤Î¤¤¤º¤ì¤«¤Ê¤é¡¢
95 .BR getutid ()
96 ¤Ï
97 .I ut_id
98 ¥Õ¥£¡¼¥ë¥É¤¬ \fIut\fP\->ut_id ¤Ë
99 °ìÃפ¹¤ëºÇ½é¤Î¥¨¥ó¥È¥ê¤òõ¤¹¡£
100 .PP
101 .BR getutline ()
102 ¤Ï¡¢ utmp ¥Õ¥¡¥¤¥ë¤Î¸½ºß¤Î°ÌÃÖ¤«¤éËöÈø¤Ë¸þ¤«¤Ã¤Æ¸¡º÷¤ò¹Ô¤¦¡£
103 .I ut_type
104 ¤¬ \fBUSER_PROCESS\fP ¤Þ¤¿¤Ï \fBLOGIN_PROCESS\fP ¤Ç¡¢
105 .I ut_line
106 ¥Õ¥£¡¼¥ë¥É¤¬ \fIut\fP->ut_line ¤Ë¥Þ¥Ã¥Á¤¹¤ëºÇ½é¤Î¹Ô¤òÊÖ¤¹¡£
107 .PP
108 .BR pututline ()
109 ¤Ï
110 .I utmp
111 ¹½Â¤ÂΠ\fIut\fP ¤ÎÆâÍƤò utmp ¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹¡£
112 .BR pututline ()
113 ¤Ï
114 .BR getutid ()
115 ¤òÍѤ¤¤Æ¡¢¿·¤¿¤Ê¥¨¥ó¥È¥ê¤ò
116 ÁÞÆþ¤¹¤ë¤Î¤Ë¤Õ¤µ¤ï¤·¤¤¾ì½ê¤òõ¤¹¡£ \fIut\fP ¤òÁÞÆþ¤¹¤ë¤Õ¤µ¤ï¤·¤¤¾ì½ê¤¬
117 ¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¡¢¿·¤¿¤Ê¥¨¥ó¥È¥ê¤ò¥Õ¥¡¥¤¥ë¤ÎËöÈø¤ËÄɲ乤롣
118 .SH ÊÖ¤êÃÍ
119 .BR getutent (),
120 .BR getutid (),
121 .BR getutline ()
122 ¤Ï¡¢À®¸ù¤¹¤ë¤È \fIstruct utmp\fP ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
123 ¼ºÇÔ¤¹¤ë¤È NULL ¤òÊÖ¤¹ (¥ì¥³¡¼¥É¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¾ì¹ç¤â¼ºÇԤȤʤë)¡£
124 ¤³¤Î \fIstruct utmp\fP ¤ÏÀÅŪ¤Êµ­²±Îΰè¤Ë³ÎÊݤµ¤ì¡¢¼¡¤Ë¤³¤ì¤é¤Î´Ø¿ô¤ò
125 ¸Æ¤Ó½Ð¤·¤¿ºÝ¤Ë¾å½ñ¤­¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
126
127 .BR pututline ()
128 ¤ÏÀ®¸ù¤¹¤ë¤È
129 .I ut
130 ¤òÊÖ¤¹¡£¼ºÇÔ¤¹¤ë¤È NULL ¤òÊÖ¤¹¡£
131
132 .BR utmpname ()
133 ¤Ï¡¢¿·¤·¤¤Ì¾Á°¤Î³ÊǼ¤ËÀ®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤·¡¢¼ºÇÔ¤¹¤ë¤È \-1 ¤òÊÖ¤¹¡£
134 .SH ¥¨¥é¡¼
135 .TP
136 .B ENOMEM
137 ¥á¥â¥êÉÔ­¡£
138 .TP
139 .B ESRCH
140 ¥ì¥³¡¼¥É¤¬¸«¤Ä¤«¤é¤Ê¤«¤Ã¤¿¡£
141 .PP
142 ´Ø¿ô
143 .BR setutent (),
144 .BR pututline (),
145 .BR getut* ()
146 ¤Ï
147 .BR open (2)
148 ¤Ë½ñ¤«¤ì¤Æ¤¤¤ëÍýͳ¤Ç¤â¼ºÇÔ¤¹¤ë¤³¤È¤¬¤¢¤ë¡£
149 .SH ¥Õ¥¡¥¤¥ë
150 /var/run/utmp     ¸½ºß¥í¥°¥¤¥óÃæ¤Î¥æ¡¼¥¶¡¼¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹
151 .br
152 /var/log/wtmp     ²áµî¤Î¥æ¡¼¥¶¡¼¥í¥°¥¤¥ó¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹
153 .SH ½àµò
154 XPG2, SVr4.
155 .LP
156 XPG2 ¤È SVID 2 ¤Ç¤Ï¡¢
157 .BR pututline ()
158 ´Ø¿ô¤ÏÃͤòÊÖ¤µ¤Ê¤¤¤È¤µ¤ì¤Æ¤ª¤ê¡¢
159 (AIX, HP-UX, Linux libc5 ¤Ê¤É¤Î) Â¿¤¯¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¤½¤¦¤Ê¤Ã¤Æ¤¤¤ë¡£
160 HP-UX ¤Ç¤Ï¡¢¾å½Ò¤Î
161 .BR pututline ()
162 ¤ÈƱ¤¸¥×¥í¥È¥¿¥¤¥×¤ò»ý¤Ä
163 ¿·¤·¤¤´Ø¿ô
164 .BR _pututline ()
165 ¤¬Æ³Æþ¤µ¤ì¤Æ¤¤¤ë
166 (¤³¤Î´Ø¿ô¤Ï Linux libc5 ¤Ë¤â¤¢¤ë)¡£
167 .LP
168 ¸½ºß¤Ç¤Ï¡¢Linux °Ê³°¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢¤³¤ì¤é¤Î´Ø¿ô¤ÏÁ´¤ÆÇѻߤµ¤ì¤Æ¤¤¤ë¡£
169 SUSv1 ¤Î¸å¤Ë½Ð¤Æ¤­¤¿ POSIX.1-2001 ¤Ç¤Ï¡¢¤â¤Ï¤ä¤³¤ì¤é¤Î´Ø¿ô¤Ï¤Ê¤¯¡¢
170 Âå¤ï¤ê¤Ë°Ê²¼¤Î¤â¤Î¤ò»È¤¦¡£
171 .sp
172 .B #include <utmpx.h>
173 .sp
174 .B struct utmpx *getutxent(void);
175 .br
176 .B struct utmpx *getutxid(const struct utmpx *);
177 .br
178 .B struct utmpx *getutxline(const struct utmpx *);
179 .br
180 .B struct utmpx *pututxline(const struct utmpx *);
181 .br
182 .B void setutxent(void);
183 .br
184 .B void endutxent(void);
185 .PP
186 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc ¤Ë¤è¤êÄ󶡤µ¤ì¤Æ¤ª¤ê¡¢
187 "x" ¤¬¤Ê¤¤´Ø¿ô¤ÈƱ¤¸½èÍý¤ò¹Ô¤¦¤¬¡¢
188 .I "struct utmpx"
189 ¤ò»ÈÍѤ¹¤ë¡£
190 Linux ¤Ç¤Ï¡¢¤³¤Î¹½Â¤ÂΤÎÄêµÁ¤Ï
191 .I "struct utmp"
192 ¤ÈƱ¤¸¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
193 ´°Á´¤ò´ü¤¹¤¿¤á¤Ë¡¢glibc ¤Ç¤Ï
194 .BR utmpxname ()
195 ¤âÄ󶡤·¤Æ¤¤¤ë¡£¤³¤Î´Ø¿ô¤Ï POSIX.1 ¤Ç¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
196 .PP
197 Linux °Ê³°¤Î¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
198 \fIutmpx\fP ¹½Â¤ÂΤϠ\fIutmp\fP ¹½Â¤ÂΤξå°Ì½¸¹ç (superset) ¤Ë¤Ê¤Ã¤Æ¤¤¤Æ¡¢
199 ÄɲäΥե£¡¼¥ë¥É¤¬¤¢¤Ã¤¿¤ê¡¢´û¸¤Î¥Õ¥£¡¼¥ë¥É¤Î¥µ¥¤¥º¤¬Â礭¤¯¤Ê¤Ã¤Æ¤¤¤¿¤ê
200 ¤¹¤ë¤â¤Î¤â¤¢¤ë¡£Ê£¿ô¤Î¥Õ¥¡¥¤¥ë¤¬»ÈÍѤµ¤ì¤Æ¤¤¤ë¾ì¹ç¤â¤¢¤ê¡¢Â¿¤¯¤Î¾ì¹ç
201 .I /var/*/utmpx
202 ¤È
203 .I /var/*/wtmpx
204 ¤È¤¤¤¦¥Õ¥¡¥¤¥ë¤¬»È¤ï¤ì¤ë¡£
205 .LP
206 °ìÊý¡¢ Linux glibc ¤Ç¤ÏÊ£¿ô¤Î \fIutmpx\fP ¥Õ¥¡¥¤¥ë ¤Ï»È¤ï¤ì¤Æ¤¤¤Ê¤¤¡£
207 \fIutmp\fP ¹½Â¤ÂΤ¬½½Ê¬¤ËÂ礭¤¤¤«¤é¤Ç¤¢¤ë¡£
208 \fIgetutxent\fP() ¤Ê¤É¤Î´Ø¿ô¤Ï \fIgetutent\fP() ¤Ê¤É¤ÎÊÌ̾¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
209 .SH Ãí°Õ
210 .SS glibc ¤Ç¤ÎÃí°Õ
211 ¾åµ­¤Î´Ø¿ô·²¤Ï¥¹¥ì¥Ã¥É¡¦¥»¡¼¥Õ¤Ç¤Ï¤Ê¤¤¡£
212 glibc ¤Ë¤Ï¥ê¥¨¥ó¥È¥é¥ó¥ÈÈÇ (reentrant) ¤¬Äɲ䵤ì¤Æ¤¤¤ë¡£
213 .sp
214 .nf
215 .BR "#define _GNU_SOURCE" "    /* or _SVID_SOURCE or _BSD_SOURCE;
216 .RB "\&                          " feature_test_macros(7) " »²¾È */"
217 .B #include <utmp.h>
218 .sp
219 .BI "int getutent_r(struct utmp *" ubuf ", struct utmp **" ubufp );
220 .sp
221 .BI "int getutid_r(struct utmp *" ut ,
222 .BI "              struct utmp *" ubuf ", struct utmp **" ubufp );
223 .sp
224 .BI "int getutline_r(struct utmp *" ut ,
225 .BI "                struct utmp *" ubuf ", struct utmp **" ubufp );
226 .fi
227 .sp
228 ¤³¤ì¤é¤Î´Ø¿ô¤Ï GNU ¤Ç¤Î³ÈÄ¥¤Ç¤¢¤ê¡¢ËöÈø¤Î _r ¤ò¤È¤Ã¤¿Ì¾Á°¤Î´Ø¿ô¤È
229 ƱÍͤε¡Ç½¤ò»ý¤Ä¡£
230 .I ubuf
231 ¥Ñ¥é¥á¡¼¥¿¤Ï·ë²Ì¤ò³ÊǼ¤¹¤ë¾ì½ê¤ò»ØÄꤹ¤ë¡£
232 À®¸ù¤¹¤ë¤È 0 ¤òÊÖ¤·¡¢·ë²Ì¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò
233 .I *ubufp
234 ¤Ë½ñ¤­¹þ¤à¡£¥¨¥é¡¼¤Î¾ì¹ç \-1 ¤òÊÖ¤¹¡£
235 ¾åµ­¤Î´Ø¿ô¤ËÂбþ¤¹¤ë utmpx ÈǤϸºß¤·¤Ê¤¤
236 (POSIX.1 ¤Ç¤Ï¤³¤ì¤é¤Î´Ø¿ô¤òµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤)¡£
237 .SH Îã
238 °Ê²¼¤ÎÎã¤Ç¤Ï¡¢ utmp ¤Î¥ì¥³¡¼¥É¤ÎÄɲᦺï½ü¤ò¹Ô¤Ã¤Æ¤¤¤ë¡£¤³¤Î¥³¡¼¥É¤Ï¡¢
239 µ¼»÷üËö (pseudo terminal) ¤«¤é¼Â¹Ô¤µ¤ì¤ë¤³¤È¤òÁÛÄꤷ¤Æ¤¤¤ë¡£
240 ¼ÂºÝ¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï
241 .BR getpwuid (3)
242 ¤È
243 .BR ttyname (3)
244 ¤ÎÌá¤êÃͤò¸¡ºº¤¹¤ë¤Ù¤­¤Ç¤¢¤ë¡£
245 .PP
246 .nf
247 #include <string.h>
248 #include <stdlib.h>
249 #include <pwd.h>
250 #include <unistd.h>
251 #include <utmp.h>
252
253 int
254 main(int argc, char *argv[])
255 {
256     struct utmp entry;
257
258     system("echo before adding entry:;who");
259
260     entry.ut_type = USER_PROCESS;
261     entry.ut_pid = getpid();
262     strcpy(entry.ut_line, ttyname(STDIN_FILENO) + strlen("/dev/"));
263     /* only correct for ptys named /dev/tty[pqr][0\-9a\-z] */
264     strcpy(entry.ut_id, ttyname(STDIN_FILENO) + strlen("/dev/tty"));
265     time(&entry.ut_time);
266     strcpy(entry.ut_user, getpwuid(getuid())\->pw_name);
267     memset(entry.ut_host, 0, UT_HOSTSIZE);
268     entry.ut_addr = 0;
269     setutent();
270     pututline(&entry);
271
272     system("echo after adding entry:;who");
273
274     entry.ut_type = DEAD_PROCESS;
275     memset(entry.ut_line, 0, UT_LINESIZE);
276     entry.ut_time = 0;
277     memset(entry.ut_user, 0, UT_NAMESIZE);
278     setutent();
279     pututline(&entry);
280
281     system("echo after removing entry:;who");
282
283     endutent();
284     exit(EXIT_SUCCESS);
285 }
286 .fi
287 .SH ´ØÏ¢¹àÌÜ
288 .BR getutmp (3),
289 .BR utmp (5)