xref: /netbsd-src/usr.bin/extattr/getextattr.1 (revision 82d56013d7b633d116a93943de88e08335357a7c)
1.\"	$NetBSD: getextattr.1,v 1.5 2011/07/14 22:14:03 wiz Exp $
2.\"
3.\"-
4.\" Copyright (c) 2000, 2001 Robert N. M. Watson
5.\" Copyright (c) 2002 Networks Associates Technology, Inc.
6.\" All rights reserved.
7.\"
8.\" This software was developed for the FreeBSD Project by Poul-Henning
9.\" Kamp and Network Associates Laboratories, the Security Research Division
10.\" of Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035
11.\" ("CBOSS"), as part of the DARPA CHATS research program
12.\"
13.\" Redistribution and use in source and binary forms, with or without
14.\" modification, are permitted provided that the following conditions
15.\" are met:
16.\" 1. Redistributions of source code must retain the above copyright
17.\"    notice, this list of conditions and the following disclaimer.
18.\" 2. Redistributions in binary form must reproduce the above copyright
19.\"    notice, this list of conditions and the following disclaimer in the
20.\"    documentation and/or other materials provided with the distribution.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $FreeBSD: src/usr.sbin/extattr/rmextattr.8,v 1.4 2003/02/24 22:53:25 ru Exp $
35.\"
36.Dd January 2, 2005
37.Dt GETEXTATTR 1
38.Os
39.Sh NAME
40.Nm getextattr ,
41.Nm lsextattr ,
42.Nm rmextattr ,
43.Nm setextattr
44.Nd manipulate extended attributes
45.Sh SYNOPSIS
46.Nm getextattr
47.Op Fl fhq
48.Op Fl s | Fl x | Fl v Ar style
49.Op Ar namespace
50.Ar attrname
51.Ar filename ...
52.Nm lsextattr
53.Op Fl fhq
54.Ar namespace
55.Ar filename ...
56.Nm rmextattr
57.Op Fl fhq
58.Op Ar namespace
59.Ar attrname
60.Ar filename ...
61.Nm setextattr
62.Op Fl fhnq
63.Op Ar namespace
64.Ar attrname
65.Ar attrvalue
66.Ar filename ...
67.Nm setextattr
68.Op Fl fhnq
69.Fl i Ar valuefile
70.Op Ar namespace
71.Ar attrname
72.Ar filename ...
73.Sh DESCRIPTION
74These utilities are user tools to manipulate the named extended
75attributes on files and directories.
76.Pp
77The
78.Ar namespace
79argument should be the namespace of the attribute to retrieve: legal
80values are
81.Cm user
82and
83.Cm system .
84For all operations except
85.Nm lsextattr ,
86the namespace argument may be omitted if the attribute name is namespace
87prefixed, like in
88.Cm user.test .
89In that later case, the
90.Cm user
91namespace prefix obviously selects
92.Cm user
93namespace.
94.Cm system ,
95.Cm security ,
96and
97.Cm trusted
98namespace prefixes select the
99.Cm system
100namespace.
101.Pp
102The
103.Ar attrname
104argument should be the name of the attribute,
105.Ar filename
106the name of the target file or directory,
107.Ar attrvalue
108a string to store in the attribute.
109.Pp
110The following options are available:
111.Bl -tag -width indent
112.It Fl f
113(Force.)
114Ignore errors on individual filenames and continue with
115the remaining arguments.
116.It Fl h
117(No follow.)
118If the file is a symbolic link, perform the operation on the
119link itself rather than the file that the link points to.
120.It Fl i Ar valuefile
121(Input file.)
122Read the attribute value from file
123.Ar valuefile .
124Use this flag in order to set a binary value for an attribute.
125.It Fl n
126.Dv ( NUL Ns
127-terminate.)
128.Dv NUL Ns
129-terminate the extent content written out.
130.It Fl q
131(Quiet.)
132Do not print out the pathname and suppress error messages.
133.It Fl s
134(Stringify.)
135Escape nonprinting characters and put quotes around the output.
136.It Fl v Ar style
137(Visual.)
138Process the attribute value through
139.Xr vis 3 ,
140using
141.Ar style .
142Valid values for
143.Ar style
144are:
145.Bl -tag -width indent
146.It Ar default
147Use default
148.Xr vis 3
149encoding.
150.It Ar c
151Use C-style backslash sequences, like in
152.Nm vis Fl c .
153.It Ar http
154Use URI encoding from RFC 1808, like in
155.Nm vis Fl h .
156.It Ar octal
157Display in octal, like in
158.Nm vis Fl o .
159.It Ar vis
160Alias for
161.Ar default .
162.It Ar cstyle
163Alias for
164.Ar c .
165.It Ar httpstyle
166Alias for
167.Ar http .
168.El
169.It Fl x
170(Hex.)
171Print the output in hexadecimal.
172.El
173.Sh EXAMPLES
174.Bd -literal
175setextattr system md5 `md5 -q /boot/kernel/kernel` /boot/kernel/kernel
176getextattr system md5 /boot/kernel/kernel
177lsextattr system /boot/kernel/kernel
178rmextattr system md5 /boot/kernel/kernel
179.Ed
180.Pp
181Examples omitting namespace (and attribute value) argument:
182.Bd -literal
183setextattr -i valuefile trusted.gfid /export/wd3a
184getextattr -x trusted.gfid /export/wd3a
185.Ed
186.Sh SEE ALSO
187.\" .Xr extattr 2 ,
188.Xr extattr 3 ,
189.Xr extattrctl 8 ,
190.Xr extattr 9
191.Sh HISTORY
192Extended attribute support was developed as part of the
193.Tn TrustedBSD
194Project,
195and introduced in
196.Fx 5.0
197and
198.Nx 3.0 .
199It was developed to support security extensions requiring additional labels
200to be associated with each file or directory.
201.Pp
202Extended attribute support was resurrected and made more usable in
203.Nx 5.2 .
204.Sh AUTHORS
205.An Robert N M Watson
206.An Poul-Henning Kamp
207.An Emmanuel Dreyfus
208