sysrc - should it behave this way?

Fun with sysrc(8). Tested on
Code:
tingo@kg-core1$ uname -a
FreeBSD kg-core1.kg4.no 10.3-STABLE FreeBSD 10.3-STABLE #0 r310083: Wed Dec 14 21:00:13 CET 2016
     root@kg-core1.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64
Testing commences (yes, spelling errors are intentional)
Code:
tingo@kg-core1$ mkdir sysrc-testing
tingo@kg-core1$ cd sysrc-testing
tingo@kg-core1$ l
./  ../
tingo@kg-core1$ touch ./test.conf
tingo@kg-core1$ ls -l test.conf
-rw-r--r--  1 tingo  users  0 Jan 25 18:12 test.conf
tingo@kg-core1$ sysrc -f ./test.conf kerm.maxswzone=262144
kerm.maxswzone:  ->
tingo@kg-core1$ cat ./test.conf
kerm.maxswzone="262144"
tingo@kg-core1$ sysrc -f ./test.conf kerm.maxswzone
sysrc: unknown variable 'kerm.maxswzone'
tingo@kg-core1$ sysrc -f ./test.conf kern.maxswzone=38432568
kern.maxswzone:  ->
tingo@kg-core1$ sysrc -f ./test.conf kern.maxswzone
sysrc: unknown variable 'kern.maxswzone'
tingo@kg-core1$ sysrc -f ./test.conf kern.maxswzone=
kern.maxswzone:  ->
tingo@kg-core1$
tingo@kg-core1$ cat ./test.conf
kerm.maxswzone="262144"
kern.maxswzone="38432568"
kern.maxswzone=""
Why doesn't this tool work on arbitrary configuration files? And why does it behave in this way when variables exist (no matter what they are named.
 
Oh, and one more thing. When used this way, it spams var/log/messages:
Code:
tingo@kg-core1$ grep sysrc /var/log/messages
Jan 25 18:04:32 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $cron_dst is not set properly - see rc.conf(5).
Jan 25 18:04:33 kg-core1 tingo: /usr/sbin/sysrc: WARNING: pflog_dev not set
Jan 25 18:04:33 kg-core1 tingo: /usr/sbin/sysrc: ERROR: Usage: /usr/sbin/sysrc [0x00|0x01]
Jan 25 18:04:34 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $sendmail_enable is not set properly - see rc.conf(5).
Jan 25 18:04:34 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $sendmail_submit_enable is not set properly - see rc.conf(5).
Jan 25 18:04:34 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $sendmail_submit_enable is not set properly - see rc.conf(5).
Jan 25 18:04:34 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $sendmail_outbound_enable is not set properly - see rc.conf(5).
Jan 25 18:04:34 kg-core1 tingo: /usr/sbin/sysrc: WARNING: $tmpmfs is not set properly - see rc.conf(5).
 
The tool is specifically designed to work with rc.conf(5) files, not arbitrary configuration files.

Code:
     The sysrc utility retrieves rc.conf(5) variables from the collection of
     system rc files and allows processes with appropriate privilege to change
     values in a safe and effective manner.
 
I dug a little deeper. While you can "abuse" the tool for other configuration files, the main issue is that the variable names need to be valid shell variable names. A dot (.) is an invalid character in a shell variable name. Shell variable names can only contain alphanumeric (a..z, A..Z and 0..9) characters and an underscore (_).
 
Thanks, I found other PR's on sysrc, but hadn't seen that one. The question then - is this new tool sysconf still being developed, or has development stopped?
 
Back
Top