]> CyberLeo.Net >> Repos - FreeBSD/releng/10.1.git/blob - usr.sbin/sysrc/sysrc.8
Fix multiple OpenSSL vulnerabilities.
[FreeBSD/releng/10.1.git] / usr.sbin / sysrc / sysrc.8
1 .\" Copyright (c) 2011-2014 Devin Teske
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd Jul 18, 2014
28 .Dt SYSRC 8
29 .Os
30 .Sh NAME
31 .Nm sysrc
32 .Nd safely edit system rc files
33 .Sh SYNOPSIS
34 .Nm
35 .Op Fl cdDeFhinNqvx
36 .Op Fl f Ar file
37 .Op Fl j Ar jail | Fl R Ar dir
38 .Ar name Ns Op = Ns Ar value
39 .Ar ...
40 .Nm
41 .Op Fl cdDeFhinNqvx
42 .Op Fl f Ar file
43 .Op Fl j Ar jail | Fl R Ar dir
44 .Fl a | A
45 .Sh DESCRIPTION
46 The
47 .Nm
48 utility retrieves
49 .Xr rc.conf 5
50 variables from the collection of system rc files and allows processes with
51 appropriate privilege to change values in a safe and effective manner.
52 .Pp
53 The following options are available:
54 .Bl -tag -width indent+
55 .It Fl a
56 Dump a list of all non-default configuration variables.
57 .It Fl A
58 Dump a list of all configuration variables
59 .Pq incl. defaults .
60 .It Fl c
61 Check only.
62 For querying, return success if all requested variables are set
63 .Pq even if NULL ,
64 otherwise return error status.
65 For assignments, return success if no changes are required, otherwise failure.
66 If verbose
67 .Pq see Dq Fl v
68 prints a message stating whether variables are set and/or changes are required.
69 .It Fl d
70 Print a description of the given variable.
71 .It Fl D
72 Show default value(s) only (this is the same as setting RC_CONFS to NULL or
73 passing `-f' with a NULL file-argument).
74 .It Fl e
75 Print query results as
76 .Xr sh 1
77 compatible syntax
78 .Pq for example, Ql var=value .
79 Ignored if either
80 .Ql Fl n
81 or
82 .Ql Fl F
83 is specified.
84 .It Fl f Ar file
85 Operate on the specified file(s) instead of the files obtained by reading the
86 .Sq rc_conf_files
87 entry in the
88 .Ev RC_DEFAULTS
89 file.
90 This option can be specified multiple times for additional files.
91 .It Fl F
92 Show only the last
93 .Xr rc.conf 5
94 file each directive is in.
95 .It Fl h
96 Print a short usage message to stderr and exit.
97 .It Fl -help
98 Print a full usage statement to stderr and exit.
99 .It Fl i
100 Ignore unknown variables.
101 .It Fl j Ar jail
102 The
103 .Ar jid
104 or name of the
105 .Ar jail
106 to operate within
107 .Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
108 .It Fl n
109 Show only variable values, not their names.
110 .It Fl N
111 Show only variable names, not their values.
112 .It Fl q
113 Quiet.
114 Disable verbose and hide certain errors.
115 .It Fl R Ar dir
116 Operate within the root directory
117 .Sq Ar dir
118 rather than
119 .Sq / .
120 .It Fl v
121 Verbose.
122 Print the pathname of the specific
123 .Xr rc.conf 5
124 file where the directive was found.
125 .It Fl -version
126 Print version information to stdout and exit.
127 .It Fl x
128 Remove variable(s) from specified file(s).
129 .El
130 .Pp
131 This utility has a similar syntax to
132 .Xr sysctl 8 .
133 It shares the `-e' and `-n' options
134 .Pq detailed above
135 and also has the same
136 .Ql name[=value]
137 syntax for making queries/assignments.
138 .Pp
139 However, while
140 .Xr sysctl 8
141 serves to query/modify MIBs in the entrant kernel,
142 .Nm
143 instead works on values in the system
144 .Xr rc.conf 5
145 configuration files.
146 .Pp
147 The list of system configuration files is configured in the file
148 .Ql /etc/defaults/rc.conf
149 within the variable
150 .Ql rc_conf_files ,
151 which by-default contains a space-separated list of pathnames.
152 On all FreeBSD
153 systems, this defaults to the value "/etc/rc.conf /etc/rc.conf.local".
154 Each
155 pathname is sourced in-order upon startup.
156 It is in the same fashion that
157 .Nm
158 sources the configuration files before returning the value of the given
159 variable.
160 .Pp
161 When supplied a variable name,
162 .Nm
163 will return the value of the variable.
164 If the variable does not appear in any
165 of the configured
166 .Ql rc_conf_files ,
167 an error is printed and error status is returned.
168 .Pp
169 When changing values of a given variable, it does not matter if the variable
170 appears in any of the
171 .Ql rc_conf_files
172 or not.
173 If the variable does not appear in any of the files, it is appended to
174 the end of the first pathname in the
175 .Ql rc_conf_files
176 variable.
177 Otherwise,
178 .Nm
179 will replace only the last-occurrence in the last-file found to contain the
180 variable.
181 This gets the value to take effect next boot without heavily
182 modifying these integral files (yet taking care not to allow the file to
183 grow unwieldy should
184 .Nm
185 be called repeatedly).
186 .Sh ENVIRONMENT
187 The following environment variables are referenced by
188 .Nm :
189 .Bl -tag -width ".Ev RC_DEFAULTS"
190 .It Ev RC_CONFS
191 Override default
192 .Ql rc_conf_files
193 .Pq even if set to NULL .
194 .It Ev RC_DEFAULTS
195 Location of
196 .Ql /etc/defaults/rc.conf
197 file.
198 .El
199 .Sh DEPENDENCIES
200 The following standard commands are required by
201 .Nm :
202 .Pp
203 .Xr awk 1 ,
204 .Xr cat 1 ,
205 .Xr chmod 1 ,
206 .Xr env 1 ,
207 .Xr grep 1 ,
208 .Xr jls 1 ,
209 .Xr mktemp 1 ,
210 .Xr mv 1 ,
211 .Xr rm 1 ,
212 .Xr sh 1 ,
213 .Xr stat 1 ,
214 .Xr tail 1 ,
215 .Xr chown 8
216 and
217 .Xr jexec 8 .
218 .Sh FILES
219 .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
220 .It Pa /etc/defaults/rc.conf
221 .It Pa /etc/rc.conf
222 .It Pa /etc/rc.conf.local
223 .El
224 .Sh EXAMPLES
225 Below are some simple examples of how
226 .Nm
227 can be used to query certain values from the
228 .Xr rc.conf 5
229 collection of system configuration files:
230 .Pp
231 .Nm
232 sshd_enable
233 .Dl returns the value of $sshd_enable, usually YES or NO .
234 .Pp
235 .Nm
236 defaultrouter
237 .Dl returns IP address of default router Pq if configured .
238 .Pp
239 Working on other files, such as
240 .Xr crontab 5 :
241 .Pp
242 .Nm
243 -f /etc/crontab MAILTO
244 .Dl returns the value of the MAILTO setting Pq if configured .
245 .Pp
246 In addition to the above syntax,
247 .Nm
248 also supports inline
249 .Xr sh 1
250 PARAMETER expansion for changing the way values are reported, shown below:
251 .Pp
252 .Nm
253 \&'hostname%%.*'
254 .Dl returns $hostname up to (but not including) first `.' .
255 .Pp
256 .Nm
257 \&'network_interfaces%%[$IFS]*'
258 .Dl returns first word of $network_interfaces .
259 .Pp
260 .Nm
261 \&'ntpdate_flags##*[$IFS]'
262 .Dl returns last word of $ntpdate_flags (time server address) .
263 .Pp
264 .Nm
265 usbd_flags-"default"
266 .Dl returns $usbd_flags or "default" if unset or NULL .
267 .Pp
268 .Nm
269 cloned_interfaces+"alternate"
270 .Dl returns "alternate" if $cloned_interfaces is set .
271 .Pp
272 .Nm
273 \&'#kern_securelevel'
274 .Dl returns length in characters of $kern_securelevel .
275 .Pp
276 .Nm
277 \&'hostname?'
278 .Dl returns NULL and error status 2 if $hostname is unset Pq or if set, returns the value of $hostname with no error status .
279 .Pp
280 .Nm
281 \&'hostname:?'
282 .Dl returns NULL and error status 2 if $hostname is unset or NULL Pq or if set and non-NULL, returns value without error status .
283 .Sh LIMITATIONS
284 The
285 .Nm
286 utility presently does not support the
287 .Ql rc.conf.d
288 collection of system configuration files
289 .Pq which requires a service name to be known during execution .
290 .Pp
291 This will be corrected by a future enhancement.
292 .Sh SEE ALSO
293 .Xr jls 1 ,
294 .Xr rc.conf 5 ,
295 .Xr jail 8 ,
296 .Xr jexec 8 ,
297 .Xr rc 8 ,
298 .Xr sysctl 8
299 .Sh HISTORY
300 A
301 .Nm
302 utility first appeared in
303 .Fx 9.2 .
304 .Sh AUTHORS
305 .An Devin Teske Aq dteske@FreeBSD.org
306 .Sh THANKS TO
307 Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
308 Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
309 Allan Jude, and Lars Engels for suggestions, help, and testing.