/
ckwtmpx.1
186 lines (172 loc) · 3.89 KB
/
ckwtmpx.1
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
'\" te
.\" Copyright 2010 Martin Carpenter, mcarpenter@free.fr.
.TH ckwtmpx 1 "19 Jun 2010" "SunOS 5.10" "User Commands"
.SH NAME
ckwtmpx \- check Solaris wtmpx files for corruption, and perform optional repairs.
.SH SYNOPSIS
.LP
.nf
\fBckwtmpx\fR [\fB-d\fR] [\fB-o\fR \fIoutput_file\fR] [\fB-e\fR \fIerror_file\fR] [\fB-t\fR \fItime_travel\fR]
\fBckwtmpx\fR \fB-h\fR
\fBckwtmpx\fR \fB-v\fR
.fi
.SH DESCRIPTION
.sp
.LP
It sometimes happens, either malevolently or otherwise, that Solaris'
binary format accounting file \fB/var/adm/wtmpx\fR becomes corrupted. The only
normal symptom of this is that standard tools such as \fBlast\fR stop
processing the file as soon as the corrupt data is encountered (\fBlast\fR
produces neither an error message nor a non-zero return code).
.sp
.LP
\fBckwtmpx\fR attempts to read a \fBwtmpx\fR file from standard input one record at
a time. Valid records are copied to the (optional) output file (\fB-o\fR), and
bytes that are discarded are copied to the (optional) error file (\fB-e\fR).
.sp
.LP
When an invalid record is encountered, \fBckwtmpx\fR moves forward through
the standard input one character at a time until the start of a valid
record is found. Skipped bytes are written to the error file as they are
discarded. Errors and debug information are sent to stderr.
.sp
.LP
A valid record fulfills the following criteria:
.sp
.in +4
Epoch time (ut_tv) is greater than 0 (was written after 1 Jan 1970).
.sp
Epoch time (ut_tv) is before now (was not written in the future).
.sp
The \fBwtmpx\fR record type (ut_type) is valid.
.sp
Either this is the first valid record found or it is not more than
70 seconds younger than the previous record found. (Some systems may
buffer output to \fBwtmpx\fR resulting occasional temporal misordering of
records, see the \fB-t\fR flag below).
.in -4
.sp
See \fB<utmpx.h>\fR and \fB<utmp.h>\fR for more details on the binary record format,
in particular \fBstruct futmpx\fR in \fB<utmpx.h>\fR for details of the record
serialization.
.SH OPTIONS
.sp
.LP
Flags \fB-d\fR, \fB-e\fR and \fB-o\fR may be combined as required but note that
.sp
.in +4
ckwtmpx -o /var/adm/wtmpx </var/adm/wtmpx
.in -4
.sp
will almost certainly cause pain. Use a temporary file.
.sp
The following options are supported:
.sp
.ne 2
.mk
.na
\fB\fB-d\fR\fR
.ad
.RS 25n
.rt
Enable debug output to stderr.
.RE
.sp
.ne 2
.mk
.na
\fB\fB-h\fR\fR
.ad
.RS 25n
.rt
Print usage to stdout and exit.
.RE
.sp
.ne 2
.mk
.na
\fB\fB-e\fR \fIerror_file\fR\fR
.ad
.RS 25n
.rt
Writes skipped bytes from the corrected \fBwtmpx\fR file to \fIerror_file\fR.
.RE
.sp
.ne 2
.mk
.na
\fB\fB-o\fR \fIoutput_file\fR\fR
.ad
.RS 25n
.rt
Writes the corrected \fBwtmpx\fR file to \fIoutput_file\fR.
.RE
.sp
.ne 2
.mk
.na
\fB\fB-t\fR \fItime_travel\fR\fR
.ad
.RS 25n
.rt
Specifies the number of seconds by which a record may be younger
than its predecessor and still be considered valid. One might expect
that records would be written in strict chronological order but this
is not so. The default of 70 seconds seems appropriate for most
cases.
.RE
.sp
.ne 2
.mk
.na
\fB\fB-v\fR\fR
.ad
.RS 25n
.rt
Print version to stdout and exit.
.RE
.SH RETURN VALUE
.sp
.LP
Returns 0 if the \fBwtmpx\fR file is okay, 1 if it is corrupt and 2 on
fatal errors (syntax, file permissions, ...) so \fBckwtmpx\fR can be run
with no arguments for testing file validity without spurious output:
.sp
.in +4
if ! ckwtmpx </var/adm/wtmpx ; then
...
.in -4
.sp
.SH EXAMPLES
.sp
.in +4
ckwtmpx -e /tmp/err -o /tmp/out </var/adm/wtmpx
.in -4
.sp
Writes corrected binary file to \fB/tmp/out\fR and skipped bytes to
\fB/tmp/err\fR.
.sp
.in +4
ckwtmpx -d </var/adm/wtmpx
.in -4
.sp
Writes debug information (details of each record and skip/seek attempts) to stderr.
.SH AUTHOR
.sp
.LP
Martin Carpenter, mcarpenter@free.fr, Copyright 2010.
.SH FILES
.sp
.ne 2
.mk
.na
\fB\fB/var/adm/wtmpx\fR\fR
.ad
.RS 18n
.rt
accounting file
.RE
.SH SEE ALSO
.sp
.LP
\fBlast\fR(1), \fButmpx\fR(4)