summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/pathchk.1
blob: 85cd74612e08ec6d1372ef5198d377d663d078e1 (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
.\" Portions Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
.\"
.TH PATHCHK 1 "Feb 1, 1995"
.SH NAME
pathchk \- check path names
.SH SYNOPSIS
.LP
.nf
\fBpathchk\fR [\fB-p\fR] \fIpath\fR...
.fi

.SH DESCRIPTION
.sp
.LP
The \fBpathchk\fR command will check that one or more path names are valid
(that is, they could be used to access or create a file without causing syntax
errors) and portable (that is, no filename truncation will result). More
extensive portability checks are provided by the \fB-p\fR option.
.sp
.LP
By default, \fBpathchk\fR will check each component of each \fIpath\fR operand
based on the underlying file system. A diagnostic will be written for each
\fIpath\fR operand that:
.RS +4
.TP
.ie t \(bu
.el o
is longer than \fIPATH_MAX\fR bytes.
.RE
.RS +4
.TP
.ie t \(bu
.el o
contains any component longer than \fINAME_MAX\fR bytes in its containing
directory
.RE
.RS +4
.TP
.ie t \(bu
.el o
contains any component in a directory that is not searchable
.RE
.RS +4
.TP
.ie t \(bu
.el o
contains any character in any component that is not valid in its containing
directory.
.RE
.sp
.LP
The format of the diagnostic message is not specified, but will indicate the
error detected and the corresponding \fIpath\fR operand.
.sp
.LP
It will not be considered an error if one or more components of a \fIpath\fR
operand do not exist as long as a file matching the path name specified by the
missing components could be created that does not violate any of the checks
specified above.
.SH OPTIONS
.sp
.LP
The following option is supported:
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Instead of performing checks based on the underlying file system, write a
diagnostic for each \fIpath\fR operand that:
.RS +4
.TP
.ie t \(bu
.el o
is longer than \fB_POSIX_PATH_MAX \fR bytes
.RE
.RS +4
.TP
.ie t \(bu
.el o
contains any component longer than \fB_POSIX_NAME_MAX\fR bytes
.RE
.RS +4
.TP
.ie t \(bu
.el o
contains any character in any component that is not in the portable filename
character set.
.RE
.RE

.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.na
\fB\fIpath\fR\fR
.ad
.RS 8n
A path to be checked.
.RE

.SH USAGE
.sp
.LP
See \fBlargefile\fR(7) for the description of the behavior of \fBpathchk\fR
when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
.SH EXAMPLES
.LP
\fBExample 1 \fRUsing the pathchk command
.sp
.LP
To verify that all paths in an imported data interchange archive are legitimate
and unambiguous on the current system:

.sp
.in +2
.nf
example% \fBpax -f archive | sed -e '/ == .*/s///' | xargs pathchk
if [ $? -eq 0 ]
then
        pax -r -f archive
else
	echo Investigate problems before importing files.
	exit 1
fi\fR
.fi
.in -2
.sp

.sp
.LP
To verify that all files in the current directory hierarchy could be moved to
any system conforming to the X/Open specification that also  supports the
\fBpax\fR(1) command:

.sp
.in +2
.nf
example% \fBfind . -print | xargs pathchk -p
if [ $? \(mieq 0 ]
then
        pax -w -f archive .
else
	echo Portable archive cannot be created.
	exit 1
fi\fR
.fi
.in -2
.sp

.sp
.LP
To verify that a user-supplied path names a readable file and that the
application can create a file extending the given path without truncation and
without overwriting any existing file:

.sp
.in +2
.nf
example% \fBcase $- in
	*C*)    reset="";;
	*)      reset="set +C"
		set -C;;
esac
test -r "$path" && pathchk "$path.out" &&
	rm "$path.out" > "$path.out"
if [ $? -ne 0 ]; then
	printf "%s: %s not found or %s.out fails \e
creation checks.\en" $0 "$path" "$path"
	$reset	# reset the noclobber option in case a trap
		# on EXIT depends on it
	exit 1
fi
$reset
PROCESSING < "$path" > "$path.out"\fR
.fi
.in -2
.sp

.sp
.LP
The following assumptions are made in this example:

.RS +4
.TP
1.
\fBPROCESSING\fR represents the code that will be used by the application to
use \fB$path\fR once it is verified that \fB$path.out\fR will work as intended.
.RE
.RS +4
.TP
2.
The state of the \fBnoclobber\fR option is unknown when this code is invoked
and should be set on exit to the state it was in when this code was invoked.
(The \fBreset\fR variable is used in this example to restore the initial
state.)
.RE
.RS +4
.TP
3.
Note the usage of:
.sp
.in +2
.nf
\fBrm "$path.out" > "$path.out"\fR
.fi
.in -2
.sp

.sp
.ne 2
.na
\fBa.\fR
.ad
.RS 6n
The \fBpathchk\fR command has already verified, at this point, that
\fB$path.out\fR will not be truncated.
.RE

.sp
.ne 2
.na
\fBb.\fR
.ad
.RS 6n
With the \fBnoclobber\fR option set, the shell will verify that \fB$path.out\fR
does not already exist before invoking \fBrm\fR.
.RE

.sp
.ne 2
.na
\fBc.\fR
.ad
.RS 6n
If the shell succeeded in creating \fB$path.out\fR, \fBrm\fR will remove it so
that the application can create the file again in the \fBPROCESSING\fR step.
.RE

.sp
.ne 2
.na
\fBd.\fR
.ad
.RS 6n
If the \fBPROCESSING\fR step wants the file to exist already when it is
invoked, the:
.sp
.in +2
.nf
\fBrm "$path.out" > "$path.out"\fR
.fi
.in -2
.sp

should be replaced with:
.sp
.in +2
.nf
\fB> "$path.out"\fR
.fi
.in -2
.sp

which will verify that the file did not already exist, but leave
\fB$path.out\fR in place for use by \fBPROCESSING\fR.
.RE

.RE
.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBpathchk\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
All \fIpath\fR operands passed all of the checks.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
.TE

.SH SEE ALSO
.sp
.LP
.BR pax (1),
.BR test (1),
.BR attributes (7),
.BR environ (7),
.BR largefile (7),
.BR standards (7)