xref: /netbsd-src/usr.sbin/extattrctl/extattrctl.8 (revision d7b84b20f6330f1aaf565cd658743b4afe32d43b)
1.\"	$NetBSD: extattrctl.8,v 1.5 2011/06/17 18:20:40 wiz Exp $
2.\"
3.\" Copyright (c) 2000-2001 Robert N. M. Watson
4.\" All rights reserved.
5.\"
6.\" This software was developed by Robert Watson for the TrustedBSD Project.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\" $FreeBSD: src/usr.sbin/extattrctl/extattrctl.8,v 1.24 2005/02/09 18:04:40 ru Exp $
30.\"
31.\" Developed by the TrustedBSD Project.
32.\" Support for file system extended attribute.
33.\"
34.Dd June 17, 2011
35.Dt EXTATTRCTL 8
36.Os
37.Sh NAME
38.Nm extattrctl
39.Nd manage UFS1 extended attributes
40.Sh SYNOPSIS
41.Nm
42.Cm start
43.Ar path
44.Nm
45.Cm stop
46.Ar path
47.Nm
48.Cm initattr
49.Op Fl f
50.Op Fl p Ar path
51.Ar attrsize
52.Ar attrfile
53.Nm
54.Cm showattr
55.Ar attrfile
56.Nm
57.Cm enable
58.Ar path
59.Ar attrnamespace
60.Ar attrname
61.Ar attrfile
62.Nm
63.Cm disable
64.Ar path
65.Ar attrnamespace
66.Ar attrname
67.Sh DESCRIPTION
68The
69.Nm
70utility
71is the management utility for extended attributes over the UFS1 file system.
72It allows the starting and stopping of extended attributes on a file system,
73as well as initialization of attribute backing files, and enabling and
74disabling of specific extended attributes on a file system.
75.Pp
76The first argument on the command line indicates the operation to be
77performed.
78Operation must be one of the following:
79.Bl -tag -width indent
80.It Cm start Ar path
81Start extended attribute support on the file system named using
82.Ar path .
83The file system must be a UFS1 file system, and the
84.Dv UFS_EXTATTR
85kernel option must have been enabled.
86If
87.Pa .attribute/user
88and
89.Pa .attribute/system
90exist at the filesystem root, extended attributes backed by files
91in these directories will be automatically enabled.
92Note that extended attributes can be automatically started at mount
93time by using the
94.Cm -o extattr
95option to
96.Xr mount 8 .
97.It Cm stop Ar path
98Stop extended attribute support on the file system named using
99.Ar path .
100Extended attribute support must previously have been started.
101.It Cm initattr Oo Fl f Oc Oo Fl p Ar path Oc Ar attrsize attrfile
102Create and initialize a file to use as an attribute backing file.
103You must specify a maximum per-inode size for the attribute in bytes in
104.Ar attrsize ,
105as well as the file where the attribute will be stored, using
106.Ar attrfile .
107.Pp
108The
109.Fl f
110argument may be used to indicate that it is alright to overwrite an
111existing attribute backing file; otherwise, if the target file exists,
112an error will be returned.
113.Pp
114The
115.Fl p Ar path
116argument may be used to preallocate space for all attributes rather than
117relying on sparse files to conserve space.
118This has the advantage of guaranteeing that space will be available
119for attributes when they are written, preventing low disk space conditions
120from denying attribute service.
121.Pp
122This file should not exist before running
123.Cm initattr .
124.Pp
125When a user attempts to set a
126.Dq user
127or
128.Dq system
129extended attribute that lacks a backing file,
130the kernel will attempt to automatically create it, provided
131.Pa .attribute/user
132or
133.Pa .attribute/system
134exist and are writable by the requesting user.
135.It Cm showattr Ar attrfile
136Show the attribute header values in the attribute file named by
137.Ar attrfile .
138.It Cm enable Ar path attrnamespace attrname attrfile
139Enable an attribute named
140.Ar attrname
141in the namespace
142.Ar attrnamespace
143on the file system identified using
144.Ar path ,
145and backed by initialized attribute file
146.Ar attrfile .
147Available namespaces are
148.Dq user
149and
150.Dq system .
151The backing file must have been initialized using
152.Cm initattr
153before its first use.
154Attributes must have been started on the file system prior to the
155enabling of any attributes.
156.It Cm disable Ar path attrnamespace attrname
157Disable the attributed named
158.Ar attrname
159in namespace
160.Ar attrnamespace
161on the file system identified by
162.Ar path .
163Available namespaces are
164.Dq user
165and
166.Dq system .
167The file system must have attributes started on it, and the attribute
168most have been enabled using
169.Cm enable .
170.El
171.Sh EXAMPLES
172.Dl extattrctl start /
173.Pp
174Start extended attributes on the root file system.
175.Pp
176.Dl extattrctl initattr 17 /.attribute/system/md5
177.Pp
178Create an attribute backing file in
179.Pa /.attribute/system/md5 ,
180and set the maximum size of each attribute to 17 bytes, with a
181sparse file used for storing the attributes.
182.Pp
183.Dl extattrctl enable / system md5 /.attribute/system/md5
184.Pp
185Enable an attribute named md5 on the root file system, backed from the file
186.Pa /.attribute/system/md5 .
187.Pp
188.Dl extattrctl disable / md5
189.Pp
190Disable the attribute named md5 on the root file system.
191.Pp
192.Dl extattrctl stop /
193.Pp
194Stop extended attributes on the root file system.
195.Sh SEE ALSO
196.Xr getextattr 1 ,
197.Xr extattr_get_file 2 ,
198.\" .Xr ffs 7 ,
199.Xr extattr 9
200.Sh HISTORY
201Extended attribute support was developed as part of the TrustedBSD
202Project, and introduced in
203.Fx 5.0
204and
205.Nx 4.0 .
206It was developed to support security extensions requiring additional
207labels to be associated with each file or directory.
208Backing file autocreation was added in
209.Nx 6.0 .
210.Sh AUTHORS
211.An Robert N M Watson
212.Sh BUGS
213.Nm
214works only on UFS1 file systems.
215The kernel support for extended attribute backing files and this
216control program should be generalized for any file system that
217lacks native extended attribute support.
218