hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
486 stars 199 forks source link

New chrony.conf option leapseclist unsupported by chrony lens #840

Closed flo-renaud closed 3 months ago

flo-renaud commented 3 months ago

With fedora 41, chrony-4.6-0.1.pre1.fc41 is shipped and provides a new option leapseclist with a default value in /etc/chrony.conf that render the lens unusable. The default /etc/chrony.conf contains:

# Set the TAI-UTC offset of the system clock.
leapseclist /usr/share/zoneinfo/leap-seconds.list

and this option breaks augeas. In order to reproduce, use the following python script:

from augeas import Augeas
import os

aug = Augeas(flags=Augeas.NO_LOAD | Augeas.NO_MODL_AUTOLOAD)
module = "chrony"
chrony_conf = os.path.abspath("/etc/chrony.conf")
aug.transform(module, chrony_conf)  # loads chrony lens file
aug.load()  # loads augeas tree

path = '/files{path}'.format(path=chrony_conf)

# remove possible conflicting configuration of servers
aug.remove('{}/server'.format(path))
aug.remove('{}/pool'.format(path))
aug.remove('{}/peer'.format(path))

aug.set('{}/pool[last()+1]'.format(path), "1.pool.ntp.org")
aug.set('{}/pool[last()]/iburst'.format(path), None)

aug.save()

The script fails to save chrony.conf:

# python3 /tmp/test_augeas.py
Traceback (most recent call last):
  File "/tmp/test_augeas.py", line 20, in <module>
    aug.save()
    ~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/augeas/__init__.py", line 607, in save
    self._raise_error(AugeasIOError, "Augeas.save() failed")
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/augeas/__init__.py", line 154, in _raise_error
    raise errorclass(ec, fullmessage, msg, minor, details)
augeas.AugeasIOError: Augeas.save() failed: No error

If /etc/chrony.conf is manually edited in order to remove the option leapseclist, then the script succeeds.

Installed packages:

augeas-libs-1.14.1-2.fc41.x86_64
python3-augeas-1.1.0-14.fc41.noarch
chrony-4.6-0.1.pre1.fc41.x86_64