Slide 1

Slide 1 text

Introduction to libeconf Bringing Peace to the Configuration War Linux Distribution Engineer Richard Brown [email protected] sysrich on Freenode.net @sysrich

Slide 2

Slide 2 text

Who’s responsible for configuration?

Slide 3

Slide 3 text

Who’s responsible for configuration?

Slide 4

Slide 4 text

Distributions ● Distributions are responsible for providing a good out of the box experience ● This includes distributing “sensible” defaults ● New upstream developments often require new settings

Slide 5

Slide 5 text

Users ● Users need to be able to configure their system as they see fit ● This may include “unsensible” choices ● They might not know of new features/changes needing new settings

Slide 6

Slide 6 text

Problems ● Distribution config installed in /etc/$foo.conf ● User edits /etc/$foo.conf ● New $foo package wishes to change defaults/introduce new parameters ● …….

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Imperfect Solutions ● Package PostScripts editing existing /etc config – Users: “The Distro broke my config!” ● Backing up user config and installing new in /etc (eg .rpmsave) – Users: “The Distro broke my config!” ● Avoiding user config in /etc and storing new alongside (eg .rpmnew) – Distros/Upstreams: “Sorry your setup is not supported”

Slide 9

Slide 9 text

Atomic Distros (eg. openSUSE MicroOS) ● Growing availability of Atomic/Transactional Distributions ● Many allow users changing /etc for runtime configuration changes ● Need some way of atomically delivering new configuration with their atomically installed packages

Slide 10

Slide 10 text

systemD ● Nice structured ‘Unit’ files ● Dedicated location for distro config – /usr/lib/systemd/system ● Dedicated location for user config – /etc/systemd/system

Slide 11

Slide 11 text

systemD drop-ins ● Selected parameters can be overridden by ‘drop-in’ files – /usr/lib/systemd/system/$foo.service.d – /etc/systemd/system/$foo.service.d ● Perfect for distros with multiple ‘consumers’ of a service & and for users wanting to make minimal changes

Slide 12

Slide 12 text

libeconf ● Flexible & configurable C library for implementing systemd-like configuration layering ● Supports both “/usr vs /etc” configs and “/usr/*/$foo*.d/ vs /etc/*/$foo*.d/” drop- ins

Slide 13

Slide 13 text

Current Limitations ● Not magic; software must add libeconf support ● Only suitable for “.ini style” config values with key/value/group structure [Group] Key=Value Key2=Value2

Slide 14

Slide 14 text

API Call Examples ● econf_readFile – read config file and stores it’s contents into a key_file ● econf_readDirs – read config files in directory ● econf_getGroups – get [Groups] from key_file ● econf_getKeys – get Keys from Group ● econf_get{$FOO}Value – get Value (of type {$FOO}) from Key

Slide 15

Slide 15 text

API Call Examples ● econf_set{$FOO}Value – set Value of type {$FOO} in a Key ● econf_mergeFiles – merge contents of two key_file ● econf_writeFile – write config file from key_file (not yet stable)

Slide 16

Slide 16 text

libeconf & openSUSE - /usr/etc ● /etc is considered ‘user data’ and treated with the same reverence & avoidance as /home, /srv and similar. ● libeconf managed config files moving to /usr/etc ● These locations are configurable by bother distros and software developers

Slide 17

Slide 17 text

Examples ● pam – Distro config in /usr/etc/pam.d – User config in /etc/pam.d – Both parsed with libeconf at runtime – /etc values always win

Slide 18

Slide 18 text

Examples ● shadow – Distro config in /usr/etc/pam.d & /usr/login.defs – User config in /etc/pam.d & /etc/login.defs – Both parsed with libeconf at runtime – /etc values always win

Slide 19

Slide 19 text

Examples ● util-linux (su, login, remote, runuser) – Distro config in /usr/etc/pam.d – User config in /etc/pam.d – Both parsed with libeconf at runtime – /etc values always win

Slide 20

Slide 20 text

Examples ● Rebootmgr – Distro config in /usr/etc/rebootmgr.conf – User config in /etc/rebootmgr.conf – Both merged libeconf at runtime, written to /etc/rebootmgr.conf

Slide 21

Slide 21 text

Plans ● Augeas – Highly reliable parser with support for more complex merging, diverse filetypes & layouts – Not Certain: Larger dependencies, more code complexity ● econftool – Generic ‘helper’ tool for understanding and editing layered configuration

Slide 22

Slide 22 text

Other Ideas ● Different file parser ● Language Bindings – Python? – Go? – Rust?

Slide 23

Slide 23 text

How to Contribute ● https://github.com/openSUSE/libeconf ● Contributions Welcome ● Changes Welcome ● New Features Welcome

Slide 24

Slide 24 text

No content