1 .\" Copyright (c) 2011-2015 Devin Teske
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
32 .Nd safely edit system rc files
37 .Op Fl j Ar jail | Fl R Ar dir
38 .Ar name Ns Op Ns Oo +|- Oc Ns = Ns Ar value
43 .Op Fl j Ar jail | Fl R Ar dir
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.
53 The following options are available:
54 .Bl -tag -width indent+
56 Dump a list of all non-default configuration variables.
58 Dump a list of all configuration variables
62 For querying, return success if all requested variables are set
64 otherwise return error status.
65 For assignments, return success if no changes are required, otherwise failure.
68 prints a message stating whether variables are set and/or changes are required.
70 Print a description of the given variable.
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).
75 Print query results as
78 .Pq for example, Ql var=value .
85 Operate on the specified file(s) instead of the files obtained by reading the
90 This option can be specified multiple times for additional files.
94 file each directive is in.
96 Print a short usage message to stderr and exit.
98 Print a full usage statement to stderr and exit.
100 Ignore unknown variables.
107 .Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 .
109 Show only variable values, not their names.
111 Show only variable names, not their values.
114 Disable verbose and hide certain errors.
116 Operate within the root directory
122 Print the pathname of the specific
124 file where the directive was found.
126 Print version information to stdout and exit.
128 Remove variable(s) from specified file(s).
131 This utility has a similar syntax to
133 It shares the `-e' and `-n' options
135 and also has the same
137 syntax for making queries/assignments.
139 .Pq but unlike Xr sysctl 8 ,
141 is supported for adding items to values
142 .Pq see APPENDING VALUES
145 is supported for removing items from values
146 .Pq see SUBTRACTING VALUES .
150 serves to query/modify MIBs in the entrant kernel,
152 instead works on values in the system
156 The list of system configuration files is configured in the file
157 .Ql /etc/defaults/rc.conf
160 which by-default contains a space-separated list of pathnames.
162 systems, this defaults to the value "/etc/rc.conf /etc/rc.conf.local".
164 pathname is sourced in-order upon startup.
165 It is in the same fashion that
167 sources the configuration files before returning the value of the given
170 When supplied a variable name,
172 will return the value of the variable.
173 If the variable does not appear in any
176 an error is printed and error status is returned.
178 When changing values of a given variable, it does not matter if the variable
179 appears in any of the
182 If the variable does not appear in any of the files, it is appended to
183 the end of the first pathname in the
188 will replace only the last-occurrence in the last-file found to contain the
190 This gets the value to take effect next boot without heavily
191 modifying these integral files (yet taking care not to allow the file to
194 be called repeatedly).
198 syntax to add items to existing values,
199 the first character of the value is taken as the delimiter separating items
200 .Pq usually Qo \ Qc or Qo , Qc .
201 For example, in the following statement:
202 .Bl -tag -width indent+
205 cloned_interfaces+=" gif0"
208 the first character is a space, informing
210 that existing values are to be considered separated by whitespace.
213 is not found in the existing value for
214 .Va cloned_interfaces ,
216 .Pq with delimiter only if existing value is non-NULL .
218 For convenience, if the first character is alpha-numeric
219 .Pq letters A-Z, a-z, or numbers 0-9 ,
221 uses the default setting of whitespace as separator.
222 For example, the above and below statements are equivalent since
224 starts with an alpha-numeric character
225 .Pq the letter Li g :
227 .Bl -tag -width indent+
230 cloned_interfaces+=gif0
233 Take the following sequence for example:
234 .Bl -tag -width indent+
237 cloned_interfaces= # start with NULL
240 cloned_interfaces+=gif0
241 .Dl # NULL -> `gif0' Pq NB: no preceding delimiter
244 cloned_interfaces+=gif0 # no change
247 cloned_interfaces+="tun0 gif0"
248 .Dl # `gif0' -> `gif0 tun0' Pq NB: no duplication
252 prevents the same value from being added if already there.
253 .Sh SUBTRACTING VALUES
256 syntax to remove items from existing values,
257 the first character of the value is taken as the delimiter separating items
258 .Pq usually Qo \ Qc or Qo , Qc .
259 For example, in the following statement:
261 .Dl Nm cloned_interfaces-=" gif0"
263 the first character is a space, informing
265 that existing values are to be considered separated by whitespace.
268 is found in the existing value for
269 .Va cloned_interfaces ,
271 .Pq extra delimiters removed .
273 For convenience, if the first character is alpha-numeric
274 .Pq letters A-Z, a-z, or numbers 0-9 ,
276 uses the default setting of whitespace as separator.
277 For example, the above and below statements are equivalent since
279 starts with an alpha-numeric character
280 .Pq the letter Li g :
282 .Bl -tag -width indent+
285 cloned_interfaces-=gif0
288 Take the following sequence for example:
289 .Bl -tag -width indent+
292 foo="bar baz" # start
295 foo-=bar # `bar baz' -> `baz'
298 foo-=baz # `baz' -> NULL
302 removes all occurrences of all items provided
303 and collapses extra delimiters between items.
305 The following environment variables are referenced by
307 .Bl -tag -width ".Ev RC_DEFAULTS"
311 .Pq even if set to NULL .
314 .Ql /etc/defaults/rc.conf
318 The following standard commands are required by
337 .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact
338 .It Pa /etc/defaults/rc.conf
340 .It Pa /etc/rc.conf.local
343 Below are some simple examples of how
345 can be used to query certain values from the
347 collection of system configuration files:
351 .Dl returns the value of $sshd_enable, usually YES or NO .
355 .Dl returns IP address of default router Pq if configured .
357 Working on other files, such as
361 -f /etc/crontab MAILTO
362 .Dl returns the value of the MAILTO setting Pq if configured .
364 Appending to existing values:
367 \&cloned_interfaces+=gif0
368 .Dl appends Qo gif0 Qc to $cloned_interfaces Pq see APPENDING VALUES .
371 \&cloned_interfaces-=gif0
372 .Dl removes Qo gif0 Qc from $cloned_interfaces Pq see SUBTRACTING VALUES .
374 In addition to the above syntax,
378 PARAMETER expansion for changing the way values are reported, shown below:
382 .Dl returns $hostname up to (but not including) first `.' .
385 \&'network_interfaces%%[$IFS]*'
386 .Dl returns first word of $network_interfaces .
389 \&'ntpdate_flags##*[$IFS]'
390 .Dl returns last word of $ntpdate_flags (time server address) .
394 .Dl returns $usbd_flags or "default" if unset or NULL .
397 cloned_interfaces+"alternate"
398 .Dl returns "alternate" if $cloned_interfaces is set .
401 \&'#kern_securelevel'
402 .Dl returns length in characters of $kern_securelevel .
406 .Dl returns NULL and error status 2 if $hostname is unset Pq or if set, returns the value of $hostname with no error status .
410 .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 .
414 utility presently does not support the
416 collection of system configuration files
417 .Pq which requires a service name to be known during execution .
419 This will be corrected by a future enhancement.
430 utility first appeared in
433 .An Devin Teske Aq dteske@FreeBSD.org
435 Brandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek,
436 Cyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, Jilles Tjoelker,
437 Allan Jude, and Lars Engels for suggestions, help, and testing.