118b13239SDevin Teske.\" Copyright (c) 2011-2013 Devin Teske 22a357efaSDevin Teske.\" All rights reserved. 32a357efaSDevin Teske.\" 42a357efaSDevin Teske.\" Redistribution and use in source and binary forms, with or without 52a357efaSDevin Teske.\" modification, are permitted provided that the following conditions 62a357efaSDevin Teske.\" are met: 72a357efaSDevin Teske.\" 1. Redistributions of source code must retain the above copyright 82a357efaSDevin Teske.\" notice, this list of conditions and the following disclaimer. 92a357efaSDevin Teske.\" 2. Redistributions in binary form must reproduce the above copyright 102a357efaSDevin Teske.\" notice, this list of conditions and the following disclaimer in the 112a357efaSDevin Teske.\" documentation and/or other materials provided with the distribution. 122a357efaSDevin Teske.\" 132a357efaSDevin Teske.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 142a357efaSDevin Teske.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 152a357efaSDevin Teske.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 162a357efaSDevin Teske.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 172a357efaSDevin Teske.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 182a357efaSDevin Teske.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 192a357efaSDevin Teske.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 202a357efaSDevin Teske.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 212a357efaSDevin Teske.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 222a357efaSDevin Teske.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 232a357efaSDevin Teske.\" SUCH DAMAGE. 242a357efaSDevin Teske.\" 252a357efaSDevin Teske.\" $FreeBSD$ 262a357efaSDevin Teske.\" 27bc3ccb90SDevin Teske.Dd Nov 20, 2013 282a357efaSDevin Teske.Dt SYSRC 8 292a357efaSDevin Teske.Os 302a357efaSDevin Teske.Sh NAME 312a357efaSDevin Teske.Nm sysrc 322a357efaSDevin Teske.Nd safely edit system rc files 332a357efaSDevin Teske.Sh SYNOPSIS 342a357efaSDevin Teske.Nm 354cc57221SDevin Teske.Op Fl cdDeFhinNqvx 362a357efaSDevin Teske.Op Fl f Ar file 372a357efaSDevin Teske.Op Fl j Ar jail | Fl R Ar dir 382a357efaSDevin Teske.Ar name Ns Op = Ns Ar value 392a357efaSDevin Teske.Ar ... 402a357efaSDevin Teske.Nm 414cc57221SDevin Teske.Op Fl cdDeFhinNqvx 422a357efaSDevin Teske.Op Fl f Ar file 432a357efaSDevin Teske.Op Fl j Ar jail | Fl R Ar dir 442a357efaSDevin Teske.Fl a | A 452a357efaSDevin Teske.Sh DESCRIPTION 462a357efaSDevin TeskeThe 472a357efaSDevin Teske.Nm 482a357efaSDevin Teskeutility retrieves 492a357efaSDevin Teske.Xr rc.conf 5 502a357efaSDevin Teskevariables from the collection of system rc files and allows processes with 512a357efaSDevin Teskeappropriate privilege to change values in a safe and effective manner. 522a357efaSDevin Teske.Pp 532a357efaSDevin TeskeThe following options are available: 542a357efaSDevin Teske.Bl -tag -width indent+ 552a357efaSDevin Teske.It Fl a 562a357efaSDevin TeskeDump a list of all non-default configuration variables. 572a357efaSDevin Teske.It Fl A 582a357efaSDevin TeskeDump a list of all configuration variables 592a357efaSDevin Teske.Pq incl. defaults . 604cc57221SDevin Teske.It Fl c 614cc57221SDevin TeskeCheck if the value will change when assigning a new value. 624cc57221SDevin TeskeIf verbose 634cc57221SDevin Teske.Pq see Dq Fl v 644cc57221SDevin Teskeprints a message stating whether a change would occur. 654cc57221SDevin TeskeExits with success if no change is necessary, else returns error status. 662a357efaSDevin Teske.It Fl d 672a357efaSDevin TeskePrint a description of the given variable. 682a357efaSDevin Teske.It Fl D 692a357efaSDevin TeskeShow default value(s) only (this is the same as setting RC_CONFS to NULL or 702a357efaSDevin Teskepassing `-f' with a NULL file-argument). 712a357efaSDevin Teske.It Fl e 722a357efaSDevin TeskePrint query results as 73379cb6baSDevin Teske.Xr sh 1 74379cb6baSDevin Teskecompatible syntax 75379cb6baSDevin Teske.Pq for example, Ql var=value . 76379cb6baSDevin TeskeIgnored if either 77379cb6baSDevin Teske.Ql Fl n 78379cb6baSDevin Teskeor 79379cb6baSDevin Teske.Ql Fl F 802a357efaSDevin Teskeis specified. 812a357efaSDevin Teske.It Fl f Ar file 822a357efaSDevin TeskeOperate on the specified file(s) instead of the files obtained by reading the 832a357efaSDevin Teske.Sq rc_conf_files 842a357efaSDevin Teskeentry in the 852a357efaSDevin Teske.Ev RC_DEFAULTS 862a357efaSDevin Teskefile. 872a357efaSDevin TeskeThis option can be specified multiple times for additional files. 882a357efaSDevin Teske.It Fl F 892a357efaSDevin TeskeShow only the last 902a357efaSDevin Teske.Xr rc.conf 5 912a357efaSDevin Teskefile each directive is in. 922a357efaSDevin Teske.It Fl h 932a357efaSDevin TeskePrint a short usage message to stderr and exit. 942a357efaSDevin Teske.It Fl -help 952a357efaSDevin TeskePrint a full usage statement to stderr and exit. 962a357efaSDevin Teske.It Fl i 972a357efaSDevin TeskeIgnore unknown variables. 982a357efaSDevin Teske.It Fl j Ar jail 992a357efaSDevin TeskeThe 1002a357efaSDevin Teske.Ar jid 1012a357efaSDevin Teskeor name of the 1022a357efaSDevin Teske.Ar jail 1032a357efaSDevin Tesketo operate within 1042a357efaSDevin Teske.Pq overrides So Fl R Ar dir Sc ; requires Xr jexec 8 . 1052a357efaSDevin Teske.It Fl n 1062a357efaSDevin TeskeShow only variable values, not their names. 1072a357efaSDevin Teske.It Fl N 1082a357efaSDevin TeskeShow only variable names, not their values. 1092a357efaSDevin Teske.It Fl q 1103dacd67eSJoel DahlQuiet. 111b2c577b5SDevin TeskeIgnore previous occurrences of 1122a357efaSDevin Teske.Fl v 113b2c577b5SDevin Teskeflag. 1142a357efaSDevin Teske.It Fl R Ar dir 1152a357efaSDevin TeskeOperate within the root directory 1162a357efaSDevin Teske.Pq Sq Ar dir 1172a357efaSDevin Teskerather than 1182a357efaSDevin Teske.Pq Sq / . 1192a357efaSDevin Teske.It Fl v 1203dacd67eSJoel DahlVerbose. 1213dacd67eSJoel DahlPrint the pathname of the specific 1222a357efaSDevin Teske.Xr rc.conf 5 1232a357efaSDevin Teskefile where the directive was found. 1243e74984cSDevin Teske.It Fl -version 1253e74984cSDevin TeskePrint version information to stdout and exit. 1262a357efaSDevin Teske.It Fl x 1272a357efaSDevin TeskeRemove variable(s) from specified file(s). 1282a357efaSDevin Teske.El 1292a357efaSDevin Teske.Pp 1302a357efaSDevin TeskeThis utility works similar to 1312a357efaSDevin Teske.Xr sysctl 8 . 1322a357efaSDevin TeskeIt shares the `-e' and `-n' options 1332a357efaSDevin Teske.Pq detailed above 1342a357efaSDevin Teskeand also has the same 1352a357efaSDevin Teske.Ql name[=value] 1362a357efaSDevin Teskesyntax for querying/setting configuration options. 1372a357efaSDevin Teske.Pp 1382a357efaSDevin TeskeHowever, while 1392a357efaSDevin Teske.Xr sysctl 8 1402a357efaSDevin Teskeserves to query/modify MIBs in the entrant kernel, 141be15d0e4SJoel Dahl.Nm 1422a357efaSDevin Teskeinstead works on values in the system 1432a357efaSDevin Teske.Xr rc.conf 5 1442a357efaSDevin Teskeconfiguration files. 1452a357efaSDevin Teske.Pp 1462a357efaSDevin TeskeThe list of system configuration files is configured in the file 1472a357efaSDevin Teske.Ql /etc/defaults/rc.conf 1482a357efaSDevin Teskewithin the variable 1492a357efaSDevin Teske.Ql rc_conf_files , 1503dacd67eSJoel Dahlwhich by-default contains a space-separated list of pathnames. 1513dacd67eSJoel DahlOn all FreeBSD 1523dacd67eSJoel Dahlsystems, this defaults to the value "/etc/rc.conf /etc/rc.conf.local". 1533dacd67eSJoel DahlEach 1543dacd67eSJoel Dahlpathname is sourced in-order upon startup. 1553dacd67eSJoel DahlIt is in the same fashion that 1562a357efaSDevin Teske.Nm 1572a357efaSDevin Teskesources the configuration files before returning the value of the given 1582a357efaSDevin Teskevariable. 1592a357efaSDevin Teske.Pp 1602a357efaSDevin TeskeWhen supplied a variable name, 1612a357efaSDevin Teske.Nm 1623dacd67eSJoel Dahlwill return the value of the variable. 1633dacd67eSJoel DahlIf the variable does not appear in any 1642a357efaSDevin Teskeof the configured 1652a357efaSDevin Teske.Ql rc_conf_files , 1662a357efaSDevin Teskean error is printed and error status is returned. 1672a357efaSDevin Teske.Pp 1682a357efaSDevin TeskeWhen changing values of a given variable, it does not matter if the variable 1692a357efaSDevin Teskeappears in any of the 1702a357efaSDevin Teske.Ql rc_conf_files 1713dacd67eSJoel Dahlor not. 1723dacd67eSJoel DahlIf the variable does not appear in any of the files, it is appended to 1732a357efaSDevin Teskethe end of the first pathname in the 1742a357efaSDevin Teske.Ql rc_conf_files 1753dacd67eSJoel Dahlvariable. 1763dacd67eSJoel DahlOtherwise, 1772a357efaSDevin Teske.Nm 1782a357efaSDevin Teskewill replace only the last-occurrence in the last-file found to contain the 1793dacd67eSJoel Dahlvariable. 1803dacd67eSJoel DahlThis gets the value to take effect next boot without heavily 1812a357efaSDevin Teskemodifying these integral files (yet taking care not to allow the file to 1822a357efaSDevin Teskegrow unwieldy should 1832a357efaSDevin Teske.Nm 1842a357efaSDevin Teskebe called repeatedly). 1852a357efaSDevin Teske.Sh ENVIRONMENT 1862a357efaSDevin TeskeThe following environment variables are referenced by 1872a357efaSDevin Teske.Nm : 188bc3ccb90SDevin Teske.Bl -tag -width ".Ev RC_DEFAULTS" 1892a357efaSDevin Teske.It Ev RC_CONFS 1902a357efaSDevin TeskeOverride default 1912a357efaSDevin Teske.Ql rc_conf_files 1922a357efaSDevin Teske.Pq even if set to NULL . 1932a357efaSDevin Teske.It Ev RC_DEFAULTS 1942a357efaSDevin TeskeLocation of 1952a357efaSDevin Teske.Ql /etc/defaults/rc.conf 1962a357efaSDevin Teskefile. 1972a357efaSDevin Teske.El 1982a357efaSDevin Teske.Sh DEPENDENCIES 1992a357efaSDevin TeskeThe following standard commands are required by 2002a357efaSDevin Teske.Nm : 2012a357efaSDevin Teske.Pp 2022a357efaSDevin Teske.Xr awk 1 , 2032a357efaSDevin Teske.Xr cat 1 , 2042a357efaSDevin Teske.Xr chmod 1 , 2052a357efaSDevin Teske.Xr env 1 , 2062a357efaSDevin Teske.Xr grep 1 , 2072a357efaSDevin Teske.Xr jls 1 , 2082a357efaSDevin Teske.Xr mktemp 1 , 2092a357efaSDevin Teske.Xr mv 1 , 2102a357efaSDevin Teske.Xr rm 1 , 2112a357efaSDevin Teske.Xr sh 1 , 2122a357efaSDevin Teske.Xr stat 1 , 213872d9e39SNiclas Zeising.Xr tail 1 , 214872d9e39SNiclas Zeising.Xr chown 8 215872d9e39SNiclas Zeisingand 216872d9e39SNiclas Zeising.Xr jexec 8 . 2172a357efaSDevin Teske.Sh FILES 2182a357efaSDevin Teske.Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact 2192a357efaSDevin Teske.It Pa /etc/defaults/rc.conf 2202a357efaSDevin Teske.It Pa /etc/rc.conf 2212a357efaSDevin Teske.It Pa /etc/rc.conf.local 2222a357efaSDevin Teske.El 2232a357efaSDevin Teske.Sh EXAMPLES 2242a357efaSDevin TeskeBelow are some simple examples of how 2252a357efaSDevin Teske.Nm 2262a357efaSDevin Teskecan be used to query certain values from the 2272a357efaSDevin Teske.Xr rc.conf 5 2282a357efaSDevin Teskecollection of system configuration files: 2292a357efaSDevin Teske.Pp 2302a357efaSDevin Teske.Nm 2312a357efaSDevin Teskesshd_enable 2322a357efaSDevin Teske.Dl returns the value of $sshd_enable, usually YES or NO . 2332a357efaSDevin Teske.Pp 2342a357efaSDevin Teske.Nm 2352a357efaSDevin Teskedefaultrouter 2362a357efaSDevin Teske.Dl returns IP address of default router Pq if configured . 2372a357efaSDevin Teske.Pp 2382a357efaSDevin TeskeWorking on other files, such as 2392a357efaSDevin Teske.Xr crontab 5 : 2402a357efaSDevin Teske.Pp 2412a357efaSDevin Teske.Nm 2422a357efaSDevin Teske-f /etc/crontab MAILTO 2432a357efaSDevin Teske.Dl returns the value of the MAILTO setting Pq if configured . 2442a357efaSDevin Teske.Pp 2452a357efaSDevin TeskeIn addition to the above syntax, 2462a357efaSDevin Teske.Nm 2472a357efaSDevin Teskealso supports inline 2482a357efaSDevin Teske.Xr sh 1 2492a357efaSDevin TeskePARAMETER expansion for changing the way values are reported, shown below: 2502a357efaSDevin Teske.Pp 2512a357efaSDevin Teske.Nm 2522a357efaSDevin Teske\&'hostname%%.*' 2532a357efaSDevin Teske.Dl returns $hostname up to (but not including) first `.' . 2542a357efaSDevin Teske.Pp 2552a357efaSDevin Teske.Nm 2562a357efaSDevin Teske\&'network_interfaces%%[$IFS]*' 2572a357efaSDevin Teske.Dl returns first word of $network_interfaces . 2582a357efaSDevin Teske.Pp 2592a357efaSDevin Teske.Nm 2602a357efaSDevin Teske\&'ntpdate_flags##*[$IFS]' 2612a357efaSDevin Teske.Dl returns last word of $ntpdate_flags (time server address) . 2622a357efaSDevin Teske.Pp 2632a357efaSDevin Teske.Nm 2642a357efaSDevin Teskeusbd_flags-"default" 2652a357efaSDevin Teske.Dl returns $usbd_flags or "default" if unset or NULL . 2662a357efaSDevin Teske.Pp 2672a357efaSDevin Teske.Nm 2682a357efaSDevin Teskecloned_interfaces+"alternate" 2692a357efaSDevin Teske.Dl returns "alternate" if $cloned_interfaces is set . 2702a357efaSDevin Teske.Pp 2712a357efaSDevin Teske.Nm 2722a357efaSDevin Teske\&'#kern_securelevel' 2732a357efaSDevin Teske.Dl returns length in characters of $kern_securelevel . 2742a357efaSDevin Teske.Pp 2752a357efaSDevin Teske.Nm 2762a357efaSDevin Teske\&'hostname?' 2772a357efaSDevin Teske.Dl returns NULL and error status 2 if $hostname is unset Pq or if set, returns the value of $hostname with no error status . 2782a357efaSDevin Teske.Pp 2792a357efaSDevin Teske.Nm 2802a357efaSDevin Teske\&'hostname:?' 2812a357efaSDevin Teske.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 . 2822a357efaSDevin Teske.Sh LIMITATIONS 2832a357efaSDevin TeskeThe 2842a357efaSDevin Teske.Nm 2852a357efaSDevin Teskeutility presently does not support the 2862a357efaSDevin Teske.Ql rc.conf.d 2872a357efaSDevin Teskecollection of system configuration files 2882a357efaSDevin Teske.Pq which requires a service name to be known during execution . 2892a357efaSDevin Teske.Pp 2902a357efaSDevin TeskeThis will be corrected by a future enhancement. 2912a357efaSDevin Teske.Sh SEE ALSO 292872d9e39SNiclas Zeising.Xr jls 1 , 293872d9e39SNiclas Zeising.Xr rc.conf 5 , 2942a357efaSDevin Teske.Xr jail 8 , 2952a357efaSDevin Teske.Xr jexec 8 , 2962a357efaSDevin Teske.Xr rc 8 , 2972a357efaSDevin Teske.Xr sysctl 8 2982a357efaSDevin Teske.Sh HISTORY 2992a357efaSDevin TeskeA 3002a357efaSDevin Teske.Nm 3012a357efaSDevin Teskeutility first appeared in 302385f5635SDevin Teske.Fx 9.2 . 3032a357efaSDevin Teske.Sh AUTHORS 304*01c2b8acSBaptiste Daroussin.An Devin Teske Aq Mt dteske@FreeBSD.org 3052a357efaSDevin Teske.Sh THANKS TO 3062a357efaSDevin TeskeBrandon Gooch, Garrett Cooper, Julian Elischer, Pawel Jakub Dawidek, 3072a357efaSDevin TeskeCyrille Lefevre, Ross West, Stefan Esser, Marco Steinbach, and Jilles Tjoelker 3082a357efaSDevin Teskefor suggestions and help. 309