OSDN Git Service

e9bcc280e69e8315a282c45cfef0c664982ae3b9
[linuxjm/LDP_man-pages.git] / draft / man5 / utmp.5
1 .\" Copyright (c) 1993 Michael Haardt (michael@cantor.informatik.rwth-aachen.de),
2 .\" Fri Apr  2 11:32:09 MET DST 1993
3 .\"
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\"
9 .\" The GNU General Public License's references to "object code"
10 .\" and "executables" are to be interpreted as the output of any
11 .\" document formatting or typesetting system, including
12 .\" intermediate and printed output.
13 .\"
14 .\" This manual is distributed in the hope that it will be useful,
15 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 .\" GNU General Public License for more details.
18 .\"
19 .\" You should have received a copy of the GNU General Public
20 .\" License along with this manual; if not, write to the Free
21 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
22 .\" USA.
23 .\"
24 .\" Modified 1993-07-25 by Rik Faith (faith@cs.unc.edu)
25 .\" Modified 1995-02-26 by Michael Haardt
26 .\" Modified 1996-07-20 by Michael Haardt
27 .\" Modified 1997-07-02 by Nicolas Lichtmaier <nick@debian.org>
28 .\" Modified 2004-10-31 by aeb, following Gwenole Beauchesne
29 .\"
30 .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako
31 .\"         all rights reserved.
32 .\" Translated 1998-02-16, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
33 .\" Updated 2003-01-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .\" Updated 2005-02-21, Akihiro MOTOKI
35 .\" Updated 2005-10-06, Akihiro MOTOKI
36 .\" Updated 2008-08-11, Akihiro MOTOKI, LDP v3.05
37 .\"
38 .TH UTMP 5 2008-10-10 "Linux" "Linux Programmer's Manual"
39 .\"O .SH NAME
40 .SH Ì¾Á°
41 .\"O utmp, wtmp \- login records
42 utmp, wtmp \- ¥í¥°¥¤¥óµ­Ï¿
43 .\"O .SH SYNOPSIS
44 .SH ½ñ¼°
45 .B #include <utmp.h>
46 .\"O .SH DESCRIPTION
47 .SH ÀâÌÀ
48 .\"O The
49 .\"O .I utmp
50 .\"O file allows one to discover information about who is currently using the
51 .\"O system.
52 .\"O There may be more users currently using the system, because not
53 .\"O all programs use utmp logging.
54 .I utmp
55 ¥Õ¥¡¥¤¥ë¤ò¸«¤ë¤³¤È¤Ç¡¢¸½ºß郎¥·¥¹¥Æ¥à¤ò»È¤Ã¤Æ¤¤¤ë¤«¤È¤¤¤¦¾ðÊó
56 ¤¬ÆÀ¤é¤ì¤ë¡£¤¿¤À¤¹¤Ù¤Æ¤Î¥×¥í¥°¥é¥à¤¬ utmp ¥Õ¥¡¥¤¥ë¤ò
57 ¹¹¿·¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¤Î¤Ç¡¢¼ÂºÝ¤Ë¤Ï¤½¤ì°Ê¾å¤Î¥æ¡¼¥¶¡¼¤¬
58 ¥·¥¹¥Æ¥à¤ò»È¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
59 .PP
60 .\"O .B Warning:
61 .\"O .I utmp
62 .\"O must not be writable by the user class "other",
63 .\"O because many system programs (foolishly)
64 .\"O depend on its integrity.
65 .\"O You risk faked system logfiles and
66 .\"O modifications of system files if you leave
67 .\"O .I utmp
68 .\"O writable to any user other than the owner and group owner of the file.
69 .B ·Ù¹ð:
70 (¶ò¤«¤Ë¤â) Â¿¤¯¤Î¥·¥¹¥Æ¥à¥×¥í¥°¥é¥à¤¬¤½¤ÎÀ°¹çÀ­¤Ë°Í¸¤·¤Æ¤¤¤ë¤Î¤Ç¡¢
71 .I utmp
72 ¥Õ¥¡¥¤¥ë¤Ï "other" ¤ËʬÎव¤ì¤ë¥æ¡¼¥¶¤ËÂФ·¤Æ
73 ½ñ¤­¹þ¤ß²Äǽ¤Ë¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
74 ¥Õ¥¡¥¤¥ë¤Î½êÍ­¼Ô¤È¥°¥ë¡¼¥×¥ª¡¼¥Ê¡¼°Ê³°¤Î¥æ¡¼¥¶¤ËÂФ·¤Æ
75 .I utmp
76 ¥Õ¥¡¥¤¥ë¤ò½ñ¤­¹þ¤ß²Äǽ¤Ê¾õÂ֤ˤ·¤Æ¤ª¤¯¤È¡¢
77 ¥·¥¹¥Æ¥à¤Î¥í¥°¥Õ¥¡¥¤¥ë¤òµ¶Â¤¤µ¤ì¤¿¤ê¡¢¥·¥¹¥Æ¥à¥Õ¥¡¥¤¥ë¤Î
78 ²þ¤¶¤ó¤ò¼õ¤±¤ë¤È¤¤¤Ã¤¿¥ê¥¹¥¯¤òÈȤ¹¤³¤È¤Ë¤Ê¤ë¡£
79 .PP
80 .\"O The file is a sequence of
81 .\"O .I utmp
82 .\"O structures,
83 .\"O declared as follows in
84 .\"O .IR <utmp.h>
85 .\"O (note that this is only one of several definitions
86 .\"O around; details depend on the version of libc):
87 ¤³¤Î¥Õ¥¡¥¤¥ë¤Ï
88 .I utmp
89 ¹½Â¤ÂΤ竤êÊÖ¤·¤Ç¹½À®¤µ¤ì¤ë¡£
90 ¤³¤Î¹½Â¤ÂΤÏ
91 .I <utmp.h>
92 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë
93 (¤³¤³¤Ëµ­½Ò¤·¤Æ¤¢¤ë¤Î¤Ï´ö¤Ä¤«¤ÎÂç¤Þ¤«¤ÊÄêµÁ¤Î¤ß¤Ç¡¢
94 ¾ÜºÙ¤Ï libc ¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤è¤êÊѤï¤ë¤³¤È¤ËÃí°Õ¤¬É¬ÍפǤ¢¤ë)¡£
95 .in +4n
96 .nf
97 .sp
98 /* Values for ut_type field, below */
99
100 #define EMPTY         0 /* Record does not contain valid info
101                            (formerly known as UT_UNKNOWN on Linux) */
102 #define RUN_LVL       1 /* Change in system run-level (see
103                            \fBinit\fP(8)) */
104 #define BOOT_TIME     2 /* Time of system boot (in \fIut_tv\fP) */
105 #define NEW_TIME      3 /* Time after system clock change
106                            (in \fIut_tv\fP) */
107 #define OLD_TIME      4 /* Time before system clock change
108                            (in \fIut_tv\fP) */
109 #define INIT_PROCESS  5 /* Process spawned by \fBinit\fP(8) */
110 #define LOGIN_PROCESS 6 /* Session leader process for user login */
111 #define USER_PROCESS  7 /* Normal process */
112 #define DEAD_PROCESS  8 /* Terminated process */
113 #define ACCOUNTING    9 /* Not implemented */
114
115 #define UT_LINESIZE      32
116 #define UT_NAMESIZE      32
117 #define UT_HOSTSIZE     256
118
119 struct exit_status {              /* Type for ut_exit, below */
120     short int e_termination;      /* Process termination status */
121     short int e_exit;             /* Process exit status */
122 };
123
124 struct utmp {
125     short   ut_type;              /* Type of record */
126     pid_t   ut_pid;               /* PID of login process */
127     char    ut_line[UT_LINESIZE]; /* Device name of tty \- "/dev/" */
128     char    ut_id[4];             /* Terminal name suffix,
129                                      or inittab(5) ID */
130     char    ut_user[UT_NAMESIZE]; /* Username */
131     char    ut_host[UT_HOSTSIZE]; /* Hostname for remote login, or
132                                      kernel version for run-level
133                                      messages */
134     struct  exit_status ut_exit;  /* Exit status of a process
135                                      marked as DEAD_PROCESS; not
136                                      used by Linux init(8) */
137 .\"O     /* The ut_session and ut_tv fields must be the same size when
138 .\"O        compiled 32- and 64-bit.  This allows data files and shared
139 .\"O        memory to be shared between 32- and 64-bit applications. */
140     /* ut_session ¤È ut_tv ¥Õ¥£¡¼¥ë¥É¤Ï¡¢32¥Ó¥Ã¥È¤Ç¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¾ì¹ç¤È
141        64¥Ó¥Ã¥È¤Ç¥³¥ó¥Ñ¥¤¥ë¤µ¤ì¤¿¾ì¹ç¤ÇƱ¤¸¥µ¥¤¥º¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
142        ¤³¤¦¤¹¤ë¤³¤È¤Ç¡¢32¥Ó¥Ã¥È¤È64¥Ó¥Ã¥È¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¡¢
143        ¥Ç¡¼¥¿¥Õ¥¡¥¤¥ë¤È¶¦Í­¥á¥â¥ê¤ò¶¦Í­¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ë¡£ */
144
145 #if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
146     int32_t ut_session;           /* Session ID (\fBgetsid\fP(2)),
147                                      used for windowing */
148     struct {
149         int32_t tv_sec;           /* Seconds */
150         int32_t tv_usec;          /* Microseconds */
151     } ut_tv;                      /* Time entry was made */
152 #else
153      long   ut_session;           /* Session ID */
154      struct timeval ut_tv;        /* Time entry was made */
155 #endif
156
157     int32_t ut_addr_v6[4];        /* Internet address of remote
158                                      host; IPv4 address uses
159                                      just ut_addr_v6[0] */
160     char __unused[20];            /* Reserved for future use */
161 };
162
163 /* Backward compatibility hacks */
164 #define ut_name ut_user
165 #ifndef _NO_UT_TIME
166 #define ut_time ut_tv.tv_sec
167 #endif
168 #define ut_xtime ut_tv.tv_sec
169 #define ut_addr ut_addr_v6[0]
170 .sp
171 .fi
172 .in
173 .\"O This structure gives the name of the special file associated with the
174 .\"O user's terminal, the user's login name, and the time of login in the form
175 .\"O of
176 .\"O .BR time (2).
177 .\"O String fields are terminated by \fB\(aq\e0\(aq\fP
178 .\"O if they are shorter than the size
179 .\"O of the field.
180 ¤³¤Î¹½Â¤ÂΤ«¤é¥æ¡¼¥¶¡¼¤Î»È¤Ã¤Æ¤¤¤ëüËö¤Î¥¹¥Ú¥·¥ã¥ë¥Õ¥¡¥¤¥ë̾¡¢
181 ¥æ¡¼¥¶¡¼¤Î¥í¥°¥¤¥ó̾¡¢
182 .RB ( time (2)
183 ·Á¼°¤Ç¤Î)¥í¥°¥¤¥ó»þ¹ï¤¬¤ï¤«¤ë¡£Ê¸»úÎó¥Õ¥£¡¼¥ë¥É¤Ï¡¢
184 ¥Õ¥£¡¼¥ë¥É¤ÎŤµ¤è¤êʸ»úÎó¤¬Ã»¤¤¾ì¹ç¤Ë¤Ï¡¢\fB\(aq\e0\(aq\fP ¤Ë¤è¤Ã¤Æ½ªÃ¼¤µ¤ì¤ë¡£
185 .PP
186 .\"O The first entries ever created result from
187 .\"O .BR init (8)
188 .\"O processing
189 .\"O .BR inittab (5).
190 .\"O Before an entry is processed, though,
191 .\"O .BR init (8)
192 .\"O cleans up utmp by setting \fIut_type\fP to \fBDEAD_PROCESS\fP, clearing
193 .\"O \fIut_user\fP, \fIut_host\fP, and \fIut_time\fP with null bytes for each
194 .\"O record which \fIut_type\fP is not \fBDEAD_PROCESS\fP or \fBRUN_LVL\fP
195 .\"O and where no process with PID \fIut_pid\fP exists.
196 .\"O If no empty record
197 .\"O with the needed \fIut_id\fP can be found,
198 .\"O .BR init (8)
199 .\"O creates a new one.
200 .\"O It sets \fIut_id\fP from the inittab, \fIut_pid\fP and \fIut_time\fP to the
201 .\"O current values, and \fIut_type\fP to \fBINIT_PROCESS\fP.
202 ºÇ½é¤Î¥¨¥ó¥È¥ê¤Ï
203 .BR init (8)
204 ¥³¥Þ¥ó¥É¤¬
205 .BR inittab (5)
206 ¤ò½èÍý¤¹¤ë¤³¤È¤Çºî¤é¤ì¤ë¡£
207 ¤¢¤ë¥¨¥ó¥È¥ê¤ò½èÍý¤¹¤ëÁ°¤Ë¡¢
208 .BR init (8)
209 ¤Ï \fIut_type\fP ¤ò \fBDEAD_PROCESS\fP ¤Ë½é´ü²½¤¹¤ë¡£
210 ¥ì¥³¡¼¥É¤Î
211 \fIut_type\fP ¤¬ \fBDEAD_PROCESS\fP ¤È \fBRUN_LVL\fP ¤Î¤¤¤º¤ì¤Ç¤â¤Ê¤¯¡¢
212 ¤«¤Ä PID ¤¬ \fIut_pid\fP ¤Ç¤¢¤ë¥×¥í¥»¥¹¤¬¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢\fIut_user\fP,
213 \fIut_host\fP, \fIut_time\fP ¤ò¥Ì¥ë¥Ð¥¤¥È¤Ç¥¯¥ê¥¢¤·¤Æ½é´ü²½¤ò¹Ô¤¦¡£
214 ɬÍפʠ\fIut_id\fP ¤ò»ý¤Ä¶õ¤Î¥ì¥³¡¼¥É¤ò¸«¤Ä¤±¤é¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
215 .BR init (8)
216 ¤Ï¿·¤·¤¤¥ì¥³¡¼¥É¤òºî¤ë¡£inittab ¤«¤é \fIut_id\fP ¤òÀßÄꤷ¡¢
217 \fIut_pid\fP ¤ª¤è¤Ó \fIut_time\fP ¤ò¸½ºßÃͤˡ¢
218 \fIut_type\fP ¤ò \fBINIT_PROCESS\fP ¤ËÀßÄꤹ¤ë¡£
219 .PP
220 .\"O .BR mingetty (8)
221 .\"O (or
222 .\"O .BR agetty (8))
223 .\"O locates the entry by the PID, changes \fIut_type\fP to
224 .\"O \fBLOGIN_PROCESS\fP, changes \fIut_time\fP, sets \fIut_line\fP, and waits
225 .\"O for connection to be established.
226 .\"O .BR login (1),
227 .\"O after a user has been
228 .\"O authenticated, changes \fIut_type\fP to \fBUSER_PROCESS\fP, changes
229 .\"O \fIut_time\fP, and sets \fIut_host\fP and \fIut_addr\fP.
230 .\"O Depending on
231 .\"O .BR mingetty (8)
232 .\"O (or
233 .\"O .BR agetty (8))
234 .\"O and
235 .\"O .BR login (1),
236 .\"O records may be located by
237 .\"O \fIut_line\fP instead of the preferable \fIut_pid\fP.
238 .BR mingetty (8)
239 (¤Þ¤¿¤Ï
240 .BR agetty (8))
241 ¤Ï pid ¤Ç¥¨¥ó¥È¥ê¤òÆÃÄꤷ¡¢
242 \fIut_type\fP ¤ò \fBLOGIN_PROCESS\fP ¤ËÊѹ¹¤·¡¢
243 \fIut_time\fP ¤ò¹¹¿·¤·¡¢\fIut_line\fP¤òÀßÄꤷ¤¿¸å¡¢Àܳ¤¬³ÎΩ¤µ¤ì¤ë¤Î¤òÂԤġ£
244 .BR login (1)
245 ¤Ï¥æ¡¼¥¶¡¼Ç§¾Ú¤¬½ªÎ»¤¹¤ë¤È¡¢
246 \fIut_type\fP ¤ò \fBUSER_PROCESS\fP ¤ËÊѹ¹¤·¡¢
247 \fIut_time\fP ¤ò¹¹¿·¤·¡¢\fIut_host\fP ¤È \fIut_addr\fP¤òÀßÄꤹ¤ë¡£
248 .BR mingetty (8)
249 (¤Þ¤¿¤Ï
250 .BR agetty (8))
251 ¤È
252 .BR login (1)
253 ¤Ë¤è¤ê°Û¤Ê¤ë¤¬¡¢
254 \fIut_pid\fP ¤ÎÂå¤ï¤ê¤Ë
255 \fIut_line\fP ¤ò»È¤Ã¤Æ¥ì¥³¡¼¥É¤ÎÆÃÄ꤬¹Ô¤ï¤ì¤ë¤³¤È¤â¤¢¤ë
256 (\fIut_pid\fP ¤ò»È¤¦Êý¤¬Ë¾¤Þ¤·¤¤) ¡£
257 .PP
258 .\"O When
259 .\"O .BR init (8)
260 .\"O finds that a process has exited, it locates its utmp
261 .\"O entry by \fIut_pid\fP, sets \fIut_type\fP to \fBDEAD_PROCESS\fP, and
262 .\"O clears \fIut_user\fP, \fIut_host\fP and \fIut_time\fP with null bytes.
263 .BR init (8)
264 ¤Ï¥×¥í¥»¥¹¤Î½ªÎ»¤ò¸¡½Ð¤·¤¿¾ì¹ç¡¢
265 \fIut_pid\fP ¤ò¥­¡¼¤È¤·¤Æ utmp ¤Î¥¨¥ó¥È¥ê¤òÆÃÄꤷ¡¢
266 \fIut_type\fP ¤ò \fBDEAD_PROCESS\fP ¤ËÀßÄꤷ¡¢
267 \fIut_user\fP, \fIut_host\fP, \fIut_time\fP ¤ò¥Ì¥ë¥Ð¥¤¥È¤Ç¥¯¥ê¥¢¤¹¤ë¡£
268 .PP
269 .\"O .BR xterm (1)
270 .\"O and other terminal emulators directly create a
271 .\"O \fBUSER_PROCESS\fP record and generate the \fIut_id\fP by using the
272 .\"O string that suffix part of the terminal name (the characters
273 .\"O following \fI/dev/[pt]ty\fP).
274 .\"O If they find a \fBDEAD_PROCESS\fP for this ID,
275 .\"O they recycle it, otherwise they create a new entry.
276 .\"O If they can, they
277 .\"O will mark it as \fBDEAD_PROCESS\fP on exiting and it is advised that
278 .\"O they null \fIut_line\fP, \fIut_time\fP, \fIut_user\fP, and \fIut_host\fP
279 .\"O as well.
280 .BR xterm (1)
281 ¥³¥Þ¥ó¥É¤ä¾¤ÎüËö¥¨¥ß¥å¥ì¡¼¥¿¤Ï
282 ľÀÜ \fBUSER_PROCESS\fP ¤Î¥ì¥³¡¼¥É¤òºî¤ê¡¢
283 üËö̾¤Î¥µ¥Õ¥£¥Ã¥¯¥¹Ê¸»úÎó (\fI/dev/[pt]ty\fP ¤Ë³¤¯Ê¸»úÎó)
284 ¤ò»È¤Ã¤Æ \fIut_id\fP ¤ÎÃͤòÀ¸À®¤¹¤ë¡£
285 ¤³¤Î id ¤ò»ý¤Ä¥¨¥ó¥È¥ê¤¬ \fBDEAD_PROCESS\fP ¤Ç¤¢¤Ã¤¿¾ì¹ç¤Ë¤ÏºÆÍøÍѤ·¡¢
286 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ë¤Ï¿·¤·¤¤¥¨¥ó¥È¥ê¤¬ºî¤é¤ì¤ë¡£
287 ²Äǽ¤Ê¾ì¹ç¤Ë¤Ï¥×¥í¥»¥¹½ªÎ»»þ¤Ë \fBDEAD_PROCESS\fP ¤ÈÀßÄꤷ¡¢
288 ¤µ¤é¤Ë \fIut_line\fP, \fIut_time\fP, \fIut_user\fP, \fIut_host\fP
289 ¤ò¥Ì¥ë¥Ð¥¤¥È¤Ç¥¯¥ê¥¢¤¹¤ë¤³¤È¤¬¾©Î夵¤ì¤Æ¤¤¤ë¡£
290 .PP
291 .\"O sets up a \fBLOGIN_PROCESS\fP entry and leaves the rest to
292 .\"O .BR login (1)
293 .\"O as usual.
294 .\"O After the telnet session ends,
295 .\"O .BR telnetd (8)
296 .\"O cleans up utmp in the described way.
297 .BR telnetd (8)
298 ¤Ï \fBLOGIN_PROCESS\fP ¤òÀßÄꤹ¤ë¤À¤±¤Ç¤è¤¯¡¢
299 »Ä¤ê¤Î½èÍý¤ÏÄ̾ïÄ̤ê
300 .BR login (1)
301 ¤ËǤ¤»¤ì¤Ð¤è¤¤¡£
302 telnet ¤Î¥»¥Ã¥·¥ç¥ó¤¬½ªÎ»¤·¤¿¸å¡¢Á°½Ò¤Î¤è¤¦¤Ë
303 .BR telnetd (8)
304 ¤¬ utmp ¤Î¥¨¥ó¥È¥ê¤ò½é´ü²½¤¹¤ë¡£
305 .PP
306 .\"O The \fIwtmp\fP file records all logins and logouts.
307 .\"O Its format is exactly like \fIutmp\fP except that a null username
308 .\"O indicates a logout
309 .\"O on the associated terminal.
310 .\"O Furthermore, the terminal name \fB~\fP
311 .\"O with username \fBshutdown\fP or \fBreboot\fP indicates a system
312 .\"O shutdown or reboot and the pair of terminal names \fB|\fP/\fB}\fP
313 .\"O logs the old/new system time when
314 .\"O .BR date (1)
315 .\"O changes it.
316 .\"O \fIwtmp\fP is maintained by
317 .\"O .BR login (1),
318 .\"O .BR init (8),
319 .\"O and some versions of
320 .\"O .BR getty (8)
321 .\"O (e.g.,
322 .\"O .BR mingetty (8)
323 .\"O or
324 .\"O .BR agetty (8)).
325 .\"O None of these programs creates the file, so if it is
326 .\"O removed, record-keeping is turned off.
327 \fIwtmp\fP ¥Õ¥¡¥¤¥ë¤Ë¤Ï¡¢¤¹¤Ù¤Æ¤Î¥í¥°¥¤¥ó¤È¥í¥°¥¢¥¦¥È¤¬µ­Ï¿¤µ¤ì¤ë¡£
328 ¤½¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢¥í¥°¥¢¥¦¥ÈºÑ¤ÎüËö¤Ç¥æ¡¼¥¶¡¼Ì¾¤¬¥Ì¥ë¤È¤Ê¤ë¤³¤È°Ê³°¤Ï
329 \fIutmp\fP ¤È¤Þ¤Ã¤¿¤¯Æ±¤¸¤Ç¤¢¤ë¡£
330 ¥æ¡¼¥¶¡¼Ì¾¤¬ \fBshutdown\fP ¤â¤·¤¯¤Ï \fBreboot\fP ¤Ç¤¢¤ë
331 üËö̾ \fB~\fP ¤Ï¥·¥¹¥Æ¥à¤ÎÄä»ß (shutdown) ¤Þ¤¿¤ÏºÆµ¯Æ° (reboot)
332 ¤ò°ÕÌ£¤¹¤ë¡£¤Þ¤¿¤½¤ÎüËö̾¤¬ \fB|\fP ¤È \fB}\fP ¤ÎÂФÏ
333 .BR date (1)
334 ¥³¥Þ¥ó¥É¤ÇÊѹ¹¤·¤¿¿·¡¿µì¤Î¥·¥¹¥Æ¥à»þ¹ï¤òµ­Ï¿¤·¤Æ¤¤¤ë¡£
335 \fIwtmp\fP ¥Õ¥¡¥¤¥ë¤Ï
336 .BR login (1),
337 .BR init (8)
338 ¤ä¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Î
339 .BR getty (8)
340 .RB ( mingetty (8)
341 ¤Þ¤¿¤Ï
342 .BR agetty (8))
343 ¤Ë¤è¤ê´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£
344 ¤³¤ì¤é¤Î¥×¥í¥°¥é¥à¤Ï¤É¤ì¤â¥Õ¥¡¥¤¥ë¤ò¿·¤¿¤ËºîÀ®¤·¤Ê¤¤¤Î¤Ç¡¢
345 ¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¤³¤È¤Ç¾ðÊó¤Îµ­Ï¿ (record-keeping) ¤ò»ß¤á¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
346 .\"O .SH FILES
347 .SH ¥Õ¥¡¥¤¥ë
348 /var/run/utmp
349 .br
350 /var/log/wtmp
351 .\"O .SH "CONFORMING TO"
352 .SH ½àµò
353 .PP
354 .\"O POSIX.1 does not specify a
355 .\"O .I utmp
356 .\"O structure, but rather one named
357 .\"O .IR utmpx ,
358 .\"O with specifications for the fields
359 .\"O .IR ut_type ,
360 .\"O .IR ut_pid ,
361 .\"O .IR ut_line ,
362 .\"O .IR ut_id ,
363 .\"O .IR ut_user ,
364 .\"O and
365 .\"O .IR ut_tv .
366 .\"O POSIX.1 does not specify the lengths of the
367 .\"O .I ut_line
368 .\"O and
369 .\"O .I ut_user
370 .\"O fields.
371 POSIX.1 ¤Ç¤Ï¡¢
372 .I utmp
373 ¹½Â¤ÂΤǤϤʤ¯¡¢
374 .I utmpx
375 ¹½Â¤ÂΤòµ¬Äꤷ¤Æ¤¤¤ë¡£
376 .I utmpx
377 ¹½Â¤ÂΤǵ¬Äꤵ¤ì¤Æ¤¤¤ë¤Î¤Ï¡¢¥Õ¥£¡¼¥ë¥É
378 .IR ut_type ,
379 .IR ut_pid ,
380 .IR ut_line ,
381 .IR ut_id ,
382 .IR ut_user ,
383 .IR ut_tv
384 ¤Ç¤¢¤ë¡£
385 POSIX.1 ¤Ç¤Ï¡¢¥Õ¥£¡¼¥ë¥É
386 .I ut_line
387 ¤È
388 .I ut_user
389 ¤ÎŤµ¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
390
391 .\"O Linux defines the
392 .\"O .I utmpx
393 .\"O structure to be the same as the
394 .\"O .I utmp
395 .\"O structure.
396 Linux ¤Ç¤Ï¡¢
397 .I utmpx
398 ¹½Â¤ÂΤÎÄêµÁ¤Ï
399 .I utmp
400 ¹½Â¤ÂΤÈƱ¤¸¤Ç¤¢¤ë¡£
401 .\"O .SS Comparison with Historical Systems
402 .SS ²áµî¤Î¥·¥¹¥Æ¥à¤È¤ÎÈæ³Ó
403 .\"O Linux utmp entries conform neither to v7/BSD nor to System V; they are a
404 .\"O mix of the two.
405 Linux ¤Ç¤Î utmp ¤Î¥¨¥ó¥È¥ê¤Ï v7/BSD ¤ä System V ¤Î¤¤¤º¤ì¤Ë¤â½àµò¤·¤Æ¤ª¤é¤º¡¢
406 ¤½¤ÎξÊý¤¬º®ºß¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
407
408 .\"O v7/BSD has fewer fields; most importantly it lacks
409 .\"O \fIut_type\fP, which causes native v7/BSD-like programs to display (for
410 .\"O example) dead or login entries.
411 .\"O Further, there is no configuration file
412 .\"O which allocates slots to sessions.
413 .\"O BSD does so because it lacks \fIut_id\fP fields.
414 v7/BSD ¤Ç¤Ï¤è¤ê¾¯¤·¤Î¹àÌܤ·¤«¤Ê¤¤;
415 ¤â¤Ã¤È¤â½ÅÍפʤ³¤È¤Ï¡¢\fIut_type\fP ¤¬Ìµ¤¤¤³¤È¤Ç¤¢¤ë¡£
416 ¤½¤Î¤¿¤á v7/BSD ·Ï¤Î¥×¥í¥°¥é¥à¤Ç¤Ï (¤¿¤È¤¨¤Ð) »à¤ó¤À¾õÂ֤Υ¨¥ó¥È¥ê¤ä
417 ¥í¥°¥¤¥ó¾õÂ֤Υ¨¥ó¥È¥ê¤Þ¤Çɽ¼¨¤µ¤ì¤Æ¤·¤Þ¤¦¤³¤È¤Ë¤Ê¤Ã¤¿¡£
418 ¤µ¤é¤Ë¥»¥Ã¥·¥ç¥óÍѤΥ¹¥í¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë¤¿¤á¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤¬¤Ê¤¤¡£
419 BSD ¤ËÀßÄê¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¤Î¤Ï \fIut_id\fP ¤¬¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
420
421 .\"O In Linux (as in System V), the \fIut_id\fP field of a
422 .\"O record will never change once it has been set, which reserves that slot
423 .\"O without needing a configuration file.
424 .\"O Clearing \fIut_id\fP may result
425 .\"O in race conditions leading to corrupted utmp entries and potential
426 .\"O security holes.
427 .\"O Clearing the abovementioned fields by filling them
428 .\"O with null bytes is not required by System V semantics,
429 .\"O but makes it possible to run
430 .\"O many programs which assume BSD semantics and which do not modify utmp.
431 .\"O Linux uses the BSD conventions for line contents, as documented above.
432 Linux (System V ·Ï)¤Ç¤Ï¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤òɬÍפȤ»¤º
433 ¥»¥Ã¥·¥ç¥óÍѤΥ¹¥í¥Ã¥È¤ò³ä¤êÅö¤Æ¤ë¤Î¤Ç¡¢°ìöÀßÄê
434 ¤µ¤ì¤Æ¤·¤Þ¤¦¤È¥ì¥³¡¼¥É¤Î \fIut_id\fP ¤Ï·è¤·¤ÆÊѹ¹¤µ¤ì¤Ê¤¤¡£
435 \fIut_id\fP ¤ò¥¯¥ê¥¢¤¹¤ë¤È¶¥¹ç¾õÂ֤ˤª¤Á¤¤¤ê¡¢
436 utmp ¤Î¥¨¥ó¥È¥ê¤ò²õ¤·¤¿¤ê¡¢ÀøºßŪ¤Ê¥»¥­¥å¥ê¥Æ¥£¥Û¡¼¥ë¤Ë¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ë¡£
437 ¾å½Ò¤Î¥Õ¥£¡¼¥ë¥É¤ò NULL ¥Ð¥¤¥È¤ÇËä¤á¤Æ¥¯¥ê¥¢¤·¤Æ¤ª¤¯¤Î¤Ï¡¢
438 System V ¤Ç¤Î¼è¤ê·è¤á¤Ç¤ÏɬÍפȤϤµ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
439 BSD ¤Ç¤Î¼è¤ê·è¤á¤òÁ°Äó¤È¤·¤Æ¤¤¤Æ¡¢¤«¤Ä utmp ¤ò¹¹¿·¤·¤Ê¤¤Â¿¤¯¤Î¥×¥í¥°¥é¥à¤¬
440 Æ°ºî¤¹¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¤Ç¤¢¤ë¡£
441 Linux ¤Ç¤Ï¤³¤³¤Þ¤Çµ­½Ò¤·¤Æ¤­¤¿¤è¤¦¤Ë¡¢¹ÔÆâÍƤÎɽ¼¨¤Ï BSD ¤Î´·Îã¤Ë½¾¤Ã¤Æ¤¤¤ë¡£
442 .PP
443 .\"O .\" mtk: What is the referrent of "them" in the following sentence?
444 .\"O .\" System V only uses the type field to mark them and logs
445 .\"O .\" informative messages such as \fB"new time"\fP in the line field.
446 .\"O System V has no \fIut_host\fP or \fIut_addr_v6\fP fields.
447 .\" mtk: What is the referrent of "them" in the following sentence?
448 .\" System V ¤Ç¤Ï ut_type ¤òÌÜ°õ¤Ë¤·¤¿¤ê¡¢¤¿¤È¤¨¤Ð \fB"new time"\fP ¤Î¤è¤¦¤Ê
449 .\" ÄÌÃÎ¥á¥Ã¥»¡¼¥¸¤òµ­Ï¿¤¹¤ë¤¿¤á¤Î¤ß¤Ë»È¤Ã¤Æ¤¤¤ë¡£
450 \fBUT_UNKNOWN\fP ¤Ï Linux ¤Çºî¤é¤ì¤¿¤â¤Î¤Î¤è¤¦¤Ç¤¢¤ë¡£
451 System V ¤Ë¤Ï \fIut_host\fP ¤â \fIut_addr_v6\fP ¤â¸ºß¤·¤Ê¤¤¡£
452 .\"O .SH NOTES
453 .SH Ãí°Õ
454 .PP
455 .\"O Unlike various other
456 .\"O systems, where utmp logging can be disabled by removing the file, utmp
457 .\"O must always exist on Linux.
458 .\"O If you want to disable
459 .\"O .BR who (1)
460 .\"O then
461 .\"O do not make utmp world readable.
462 ¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¤³¤È¤Ç utmp ¤Ø¤Îµ­Ï¿¤ò»ß¤á¤é¤ì¤ë
463 ¾¤ÎÍÍ¡¹¤Ê¥·¥¹¥Æ¥à¤È¤Ï°ã¤¤¡¢Linux ¤Ç¤Ï utmp ¥Õ¥¡¥¤¥ë¤òɬ¤º¤ª¤¤¤Æ
464 ¤ª¤¯É¬Íפ¬¤¢¤ë¡£
465 .BR who (1)
466 ¥³¥Þ¥ó¥É¤¬µ¡Ç½¤·¤Ê¤¤¤è¤¦¤Ë¤·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢
467 utmp ¥Õ¥¡¥¤¥ë¤ÎÁ´¥æ¡¼¥¶¡¼¤ËÂФ¹¤ëÆɤ߼è¤êµö²Ä¤òÀßÄꤷ¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£
468 .PP
469 .\"O The file format is machine-dependent, so it is recommended that it be
470 .\"O processed only on the machine architecture where it was created.
471 ¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¥Þ¥·¥ó¤Ë°Í¸¤¹¤ë¤Î¤Ç¡¢¥Õ¥¡¥¤¥ë¤¬ºî¤é¤ì¤¿
472 ¥Þ¥·¥ó¤â¤·¤¯¤ÏƱ°ì¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Î¥Þ¥·¥ó¾å¤Ç¤Î¤ß½èÍý¤¹¤ë¤³¤È¤ò¿ä¾©¤¹¤ë¡£
473 .PP
474 .\"O Note that on \fIbiarch\fP platforms, that is, systems which can run both
475 .\"O 32-bit and 64-bit applications (x86-64, ppc64, s390x, etc.),
476 .\"O \fIut_tv\fP is the same size in 32-bit mode as in 64-bit mode.
477 .\"O The same goes for \fIut_session\fP and \fIut_time\fP if they are present.
478 .\"O This allows data files and shared memory to be shared between
479 .\"O 32-bit and 64-bit applications.
480 Ãí°Õ¤¹¤Ù¤­ÅÀ¤È¤·¤Æ¤Ï¡¢
481 \fIbiarch\fP ¤Ê¥×¥é¥Ã¥È¥Õ¥©¡¼¥à¡¢¤Ä¤Þ¤ê 32¥Ó¥Ã¥È¤È 64¥Ó¥Ã¥È¤ÎξÊý¤Î
482 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ò¼Â¹Ô¤Ç¤­¤ë¥·¥¹¥Æ¥à (x86-64, ppc64, s390x ¤Ê¤É) ¤Ç¤Ï¡¢
483 \fIut_tv\fP ¤Î¥µ¥¤¥º¤Ï 32¥Ó¥Ã¥È¥â¡¼¥É¤È 64¥Ó¥Ã¥È¥â¡¼¥É¤ÇƱ¤¸¤Ç¤¢¤ë¡£
484 \fIut_session\fP ¤È \fIut_time\fP ¤â¡¢Â¸ºß¤¹¤ë¾ì¹ç¤Ë¤ÏƱÍͤËƱ¤¸¥µ¥¤¥º
485 ¤Ç¤¢¤ë¡£¤³¤ì¤Ë¤è¤ê¡¢32¥Ó¥Ã¥È¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤È 64¥Ó¥Ã¥È¥¢¥×¥ê¥±¡¼¥·¥ç¥ó
486 ¤Î´Ö¤Ç¥Ç¡¼¥¿¥Õ¥¡¥¤¥ë¤È¶¦Í­¥á¥â¥ê¤ò¶¦Í­¤¹¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤ë¡£
487 .\"O This is achieved by changing the type of
488 .\"O .I ut_session
489 .\"O to
490 .\"O .IR int32_t ,
491 .\"O and that of
492 .\"O .I ut_tv
493 .\"O to a struct with two
494 .\"O .I int32_t
495 .\"O fields
496 .\"O .I tv_sec
497 .\"O and
498 .\"O .IR tv_usec .
499 ¤½¤Î¤¿¤á¤Ë¤Ï¡¢
500 .I ut_session
501 ¤ò
502 .I int32_t
503 ·¿¤Ë¡¢
504 .I ut_tv
505 ¤ò 2¤Ä¤Î
506 .I int32_t
507 ·¿¤Î¥Õ¥£¡¼¥ë¥É
508 .IR tv_sec ,
509 .I tv_usec
510 ¤ò»ý¤Ä¹½Â¤ÂΤËÊѹ¹¤¹¤ì¤Ð¤è¤¤
511 .\"O Since \fIut_tv\fP may not be the same as \fIstruct timeval\fP,
512 .\"O then instead of the call:
513 \fIut_tv\fP ¤Ï \fIstruct timeval\fP ¤ÈƱ¤¸¥µ¥¤¥º¤È¤Ï¸Â¤é¤Ê¤¤¤Î¤Ç¡¢
514 .in +4n
515 .nf
516 .sp
517 gettimeofday((struct timeval *) &ut.ut_tv, NULL);
518 .fi
519 .in
520
521 ¤Î¤è¤¦¤Ê¸Æ¤Ó½Ð¤·¤ò¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢
522 .\"O the following method of setting this field is recommended:
523 °Ê²¼¤Î¤è¤¦¤Ë³Æ¥Õ¥£¡¼¥ë¥É¤òÀßÄꤹ¤ëÊýË¡¤¬¿ä¾©¤µ¤ì¤ë:
524 .in +4n
525 .nf
526 .sp
527 struct utmp ut;
528 struct timeval tv;
529
530 gettimeofday(&tv, NULL);
531 ut.ut_tv.tv_sec = tv.tv_sec;
532 ut.ut_tv.tv_usec = tv.tv_usec;
533 .fi
534 .in
535 .PP
536 .\"O Note that the \fIutmp\fP struct from libc5 has changed in libc6.
537 .\"O Because of this,
538 .\"O binaries using the old libc5 struct will corrupt
539 .\"O .IR /var/run/utmp " and/or " /var/log/wtmp .
540 utmp ¹½Â¤ÂΤϠlibc5 ¤«¤é libc6 ¤ÇÊѹ¹¤µ¤ì¤¿¡£¤½¤Î¤¿¤áÀΤΠlibc5 ¤Î¹½Â¤ÂÎ
541 ¤ò»È¤Ã¤¿¥×¥í¥°¥é¥à¤Ï
542 .IR /var/run/utmp " ¤ä " /var/log/wtmp
543 ¥Õ¥¡¥¤¥ë¤ò²õ¤·¤Æ¤·¤Þ¤¦¡£
544 .\"O .SH BUGS
545 .SH ¥Ð¥°
546 .\"O This man page is based on the libc5 one, things may work differently now.
547 ¤³¤Î man ¥Ú¡¼¥¸¤Ï libc5 ¤Ë´ð¤Å¤¤¤Æºî¤é¤ì¤Æ¤¤¤Æ¡¢
548 ºÇ¿·¤Î¤â¤Î¤Ç¤Ï°ã¤Ã¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
549 .\"O .SH "SEE ALSO"
550 .SH ´ØÏ¢¹àÌÜ
551 .BR ac (1),
552 .BR date (1),
553 .BR last (1),
554 .BR login (1),
555 .BR who (1),
556 .BR getutent (3),
557 .BR getutmp (3),
558 .BR login (3),
559 .BR logout (3),
560 .BR logwtmp (3),
561 .BR updwtmp (3),
562 .BR init (8)