augeas
augeas copied to clipboard
systemd: Can set arbitrary key to empty, but not to a value
I was looking to leverage the systemd lens to be able to configure some other aspects, like networkd, timesyncd and resolved. Though they have different sections and keys than regular unit files, the syntax of all the files is the same.
During some trial and error I noticed I can do this:
$ augtool --autosave --noautoload --transform 'Systemd.lns incl /etc/systemd/resolved.conf'
augtool> set '/files/etc/systemd/resolved.conf/Resolve/DNS' ''
augtool> save
Saved 1 file(s)
This works and results in DNS=
being written to the file. Given that this worked, I expected to be able to also set DNS
to some value. However, that won't work.
$ augtool --autosave --noautoload --transform 'Systemd.lns incl /etc/systemd/resolved.conf'
augtool> set '/files/etc/systemd/resolved.conf/Resolve/DNS' test
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool> errors
Error in /etc/systemd/resolved.conf at node /files/etc/systemd/resolved.conf/files/etc/systemd/resolved.conf/Resolve (put_fai
led)
Failed to match tree under /files/etc/systemd/resolved.conf/Resolve
{ "#comment" = "DNS=" }
{ "#comment" = "FallbackDNS=1.1.1.1 9.9.9.10 8.8.8.8 2606:4700:4700::1111 2620:fe::10 2001:4860:4860::8888" }
{ "#comment" = "Domains=" }
{ "#comment" = "LLMNR=yes" }
{ "#comment" = "MulticastDNS=yes" }
{ "#comment" = "DNSSEC=allow-downgrade" } [38/1862]
{ "#comment" = "DNSOverTLS=no" }
{ "#comment" = "Cache=yes" }
{ "#comment" = "DNSStubListener=yes" }
{ "#comment" = "ReadEtcHosts=yes" }
{ "FallbackDNS" }
{ "DNS" = "test" }
with pattern
( { /Description/ }
| { /Descriptio((n[.0-9A-Z_a-z-]|[.0-9A-Z_a-mo-z-])[.0-9A-Z_a-z-]*|)|Descripti([.0-9A-Z_a-np-z-][.0-9A-Z_a-z-]*|)|Descr
ipt([.0-9A-Z_a-hj-z-][.0-9A-Z_a-z-]*|)|Descrip([.0-9A-Z_a-su-z-][.0-9A-Z_a-z-]*|)|Descri([.0-9A-Z_a-oq-z-][.0-9A-Z_a-z-]*|)|D
escr([.0-9A-Z_a-hj-z-][.0-9A-Z_a-z-]*|)|Desc([.0-9A-Z_a-qs-z-][.0-9A-Z_a-z-]*|)|Des([.0-9A-Z_abd-z-][.0-9A-Z_a-z-]*|)|De([.0-
9A-Z_a-rt-z-][.0-9A-Z_a-z-]*|)|Environmen((t[.0-9A-Z_a-z-]|[.0-9A-Z_a-su-z-])[.0-9A-Z_a-z-]*|)|Environme([.0-9A-Z_a-mo-z-][.0
-9A-Z_a-z-]*|)|Environm([.0-9A-Z_a-df-z-][.0-9A-Z_a-z-]*|)|Environ([.0-9A-Z_a-ln-z-][.0-9A-Z_a-z-]*|)|Enviro([.0-9A-Z_a-mo-z-
][.0-9A-Z_a-z-]*|)|Envir([.0-9A-Z_a-np-z-][.0-9A-Z_a-z-]*|)|Envi([.0-9A-Z_a-qs-z-][.0-9A-Z_a-z-]*|)|Env([.0-9A-Z_a-hj-z-][.0-
9A-Z_a-z-]*|)|Exec([.0-9_-][.0-9A-Z_a-z-]*|[A-Za-z]|)|Exe([.0-9A-Z_abd-z-][.0-9A-Z_a-z-]*|)|(Ex[.0-9A-Z_a-df-z-]|En[.0-9A-Z_a
-uw-z-]|(E[.0-9A-Z_a-mo-wyz-]|D[.0-9A-Z_a-df-z-]|[A-CF-Za-z][.0-9A-Z_a-z-])[.0-9A-Z_a-z-])[.0-9A-Z_a-z-]*|Ex|En|E[.0-9A-Z_a-m
o-wyz-]|D[.0-9A-Z_a-df-z-]|[A-CF-Za-z][.0-9A-Z_a-z-]/ }
| { /Exec[A-Za-z][.0-9A-Z_a-z-]+/ }
| { /Environment/ }
| { /#comment/ = /[^\t\n\r ].*[^\t\n\r ]|[^\t\n\r ]/ }
| { /\\.include/ = /[^\t\n #]*[^\t\n #\\]/ }
| { })*
Lens: /usr/share/augeas/lenses/dist/inifile.aug:459.27-460.17
This strikes me as odd. If I can clear an arbitrary key, I should be allowed to set one too. If not, it probably shouldn't let me do this in either direction.
While we're at it, could someone suggest what I should change in systemd.aug
to make this work?
Despite the fact that the Systemd lens explicitly includes /etc/systemd/logind.conf
, it doesn't seem to work for that either:
augtool> ls /files/etc/systemd/logind.conf/Login/
#comment[1] = NAutoVTs=6
#comment[2] = ReserveVT=6
#comment[3] = KillUserProcesses=no
#comment[4] = KillOnlyUsers=
#comment[5] = KillExcludeUsers=root
#comment[6] = InhibitDelayMaxSec=5
#comment[7] = HandlePowerKey=poweroff
#comment[8] = HandleSuspendKey=suspend
#comment[9] = HandleHibernateKey=hibernate
#comment[10] = HandleLidSwitch=suspend
#comment[11] = HandleLidSwitchExternalPower=suspend
#comment[12] = HandleLidSwitchDocked=ignore
#comment[13] = PowerKeyIgnoreInhibited=no
#comment[14] = SuspendKeyIgnoreInhibited=no
#comment[15] = HibernateKeyIgnoreInhibited=no
#comment[16] = LidSwitchIgnoreInhibited=yes
#comment[17] = HoldoffTimeoutSec=30s
#comment[18] = IdleAction=ignore
#comment[19] = IdleActionSec=30min
#comment[20] = RuntimeDirectorySize=10%
#comment[21] = RemoveIPC=yes
#comment[22] = InhibitorsMax=8192
#comment[23] = SessionsMax=8192
augtool> set /files/etc/systemd/logind.conf/Login/SessionsMax 8192
augtool> save
error: Failed to execute command
saving failed (run 'errors' for details)
augtool> errors
Error in /etc/systemd/logind.conf at node /files/etc/systemd/logind.conf/files/etc/systemd/logind.conf/Login (put_fa[31/1829]
Failed to match tree under /files/etc/systemd/logind.conf/Login
{ "#comment" = "NAutoVTs=6" }
{ "#comment" = "ReserveVT=6" }
{ "#comment" = "KillUserProcesses=no" }
{ "#comment" = "KillOnlyUsers=" }
{ "#comment" = "KillExcludeUsers=root" }
{ "#comment" = "InhibitDelayMaxSec=5" }
{ "#comment" = "HandlePowerKey=poweroff" }
{ "#comment" = "HandleSuspendKey=suspend" }
{ "#comment" = "HandleHibernateKey=hibernate" }
{ "#comment" = "HandleLidSwitch=suspend" }
{ "#comment" = "HandleLidSwitchExternalPower=suspend" }
{ "#comment" = "HandleLidSwitchDocked=ignore" }
{ "#comment" = "PowerKeyIgnoreInhibited=no" }
{ "#comment" = "SuspendKeyIgnoreInhibited=no" }
{ "#comment" = "HibernateKeyIgnoreInhibited=no" }
{ "#comment" = "LidSwitchIgnoreInhibited=yes" }
{ "#comment" = "HoldoffTimeoutSec=30s" }
{ "#comment" = "IdleAction=ignore" }
{ "#comment" = "IdleActionSec=30min" }
{ "#comment" = "RuntimeDirectorySize=10%" }
{ "#comment" = "RemoveIPC=yes" }
{ "#comment" = "InhibitorsMax=8192" }
{ "#comment" = "SessionsMax=8192" }
{ "SessionsMax" = "8192" }
with pattern
( { /Description/ }
| { /Descriptio((n[.0-9A-Z_a-z-]|[.0-9A-Z_a-mo-z-])[.0-9A-Z_a-z-]*|)|Descripti([.0-9A-Z_a-np-z-][.0-9A-Z_a-z-]*|)|Descr
ipt([.0-9A-Z_a-hj-z-][.0-9A-Z_a-z-]*|)|Descrip([.0-9A-Z_a-su-z-][.0-9A-Z_a-z-]*|)|Descri([.0-9A-Z_a-oq-z-][.0-9A-Z_a-z-]*|)|D
escr([.0-9A-Z_a-hj-z-][.0-9A-Z_a-z-]*|)|Desc([.0-9A-Z_a-qs-z-][.0-9A-Z_a-z-]*|)|Des([.0-9A-Z_abd-z-][.0-9A-Z_a-z-]*|)|De([.0-
9A-Z_a-rt-z-][.0-9A-Z_a-z-]*|)|Environmen((t[.0-9A-Z_a-z-]|[.0-9A-Z_a-su-z-])[.0-9A-Z_a-z-]*|)|Environme([.0-9A-Z_a-mo-z-][.0
-9A-Z_a-z-]*|)|Environm([.0-9A-Z_a-df-z-][.0-9A-Z_a-z-]*|)|Environ([.0-9A-Z_a-ln-z-][.0-9A-Z_a-z-]*|)|Enviro([.0-9A-Z_a-mo-z-
][.0-9A-Z_a-z-]*|)|Envir([.0-9A-Z_a-np-z-][.0-9A-Z_a-z-]*|)|Envi([.0-9A-Z_a-qs-z-][.0-9A-Z_a-z-]*|)|Env([.0-9A-Z_a-hj-z-][.0-
9A-Z_a-z-]*|)|Exec([.0-9_-][.0-9A-Z_a-z-]*|[A-Za-z]|)|Exe([.0-9A-Z_abd-z-][.0-9A-Z_a-z-]*|)|(Ex[.0-9A-Z_a-df-z-]|En[.0-9A-Z_a
-uw-z-]|(E[.0-9A-Z_a-mo-wyz-]|D[.0-9A-Z_a-df-z-]|[A-CF-Za-z][.0-9A-Z_a-z-])[.0-9A-Z_a-z-])[.0-9A-Z_a-z-]*|Ex|En|E[.0-9A-Z_a-m
o-wyz-]|D[.0-9A-Z_a-df-z-]|[A-CF-Za-z][.0-9A-Z_a-z-]/ }
| { /Exec[A-Za-z][.0-9A-Z_a-z-]+/ }
| { /Environment/ }
| { /#comment/ = /[^\t\n\r ].*[^\t\n\r ]|[^\t\n\r ]/ }
| { /\\.include/ = /[^\t\n #]*[^\t\n #\\]/ }
| { })*
Lens: /usr/share/augeas/lenses/dist/inifile.aug:459.27-460.17:
$ augtool --version
augtool 1.12.0 <http://augeas.net/>
Copyright (C) 2007-2016 David Lutterkort
License LGPLv2+: GNU LGPL version 2.1 or later
<http://www.gnu.org/licenses/lgpl-2.1.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David Lutterkort