
\begin{DoxyItemize}
\item infos = Information about augeas plugin is in keys below
\item infos/author = Felix Berlakovich \href{mailto:elektra@berlakovich.net}{\tt elektra@berlakovich.\+net}
\item infos/licence = B\+SD
\item infos/provides = storage
\item infos/needs =
\item infos/recommends = glob keytometa
\item infos/placements = getstorage setstorage
\item infos/status = maintained unittest libc configurable
\item infos/metadata = order
\item infos/description = reading and writing configurations via libaugeas
\end{DoxyItemize}

This is a plugin for reading and writing configuration files with help from Augeas. The plugin should be able to read all configuration files for which an Augeas lens exists. However, not all stock lenses of Augeas have been tested yet. A detailed description of the lens language and a tutorial on how to write new lenses can be found at \href{http://augeas.net/}{\tt http\+://augeas.\+net/}

\subsection*{Dependencies}


\begin{DoxyItemize}
\item {\ttfamily libaugeas-\/dev}\+: You need version 0.\+16 or higher
\end{DoxyItemize}

\subsection*{Installation}

If you have installed Augeas manually, it may be necessary to update the ld configuration. This is especially true if an older version of Augeas is installed also. Such a situation may lead to an error similar to this\+:


\begin{DoxyCode}
/usr/lib/libaugeas.so.0: version `AUGEAS\_0.16.0` not found (required by kdb)
\end{DoxyCode}


This is because {\ttfamily ld} tries to link {\ttfamily /usr/lib/libaugeas.so.\+0} which is an older version of Augeas. Simply add the path to the newer library to your ld search paths (consult your system documentation on how to do this).

\subsection*{Mounting and Configuration}

In order to mount the hosts file with the augeas plugin, issue the following command\+:


\begin{DoxyCode}
kdb mount /etc/hosts system/hosts augeas lens=Hosts.lns
\end{DoxyCode}


The value of the plugin configuration option \char`\"{}lens\char`\"{} should be the module name of the lens (Hosts in the example) with a \textquotesingle{}.lns\textquotesingle{} suffix. Depending on your distribution and kind of installation, lenses can be found at {\ttfamily /usr/share/augeas/lenses/dist}, {\ttfamily /usr/local/share/augeas/lenses/dist}, or something similar. The lens module name is equal to the filename without extension in pascal notation. For example, the lens {\ttfamily /usr/share/augeas/lenses/dist/hosts.aug} contains the module Hosts.

Note that, without configuring the plugin to use a lens, the plugin will print an error message on the first usage\+:


\begin{DoxyCode}
kdb ls system/hosts
#> Sorry, module storage issued the error 85:
#> an Augeas error occurred: Lens not found
\end{DoxyCode}


This happens because the plugin does not know which lens it should use to read and write the configuration. For that reason, the lens configuration option was supplied together with the mount command.

\subsection*{Restrictions}

\subsubsection*{Inner Node Values}

Currently no Augeas lens supports values for inner nodes. Unfortunately no validation plugin exists yet that would prevent such modifications early\+:


\begin{DoxyCode}
kdb set system/hosts/1 somevalue
#> The command set terminated unsuccessfully with the info: Error (#85) occurred!
#> Description: an Augeas error occurred
#> Module: storage
#> At: /path/augeas.c:166
#> an Augeas error occurred: Malformed child node '1'
\end{DoxyCode}


The operation simply fails with an undescriptive error.

\subsubsection*{Leaky Abstraction of Order}

Most Augeas lenses require subtrees to be in a specific order. For example the hosts lens requires the ipaddr node of an entry to precede the canonical node. Unfortunately the Augeas storage plugin has no knowledge about this required order. Therefore the correct order must be ensured via order metakeys. Otherwise saving the Key\+Set may fail. As an example consider the following kdb shell script\+:


\begin{DoxyCode}
kdbGet system/hosts
keySetName system/hosts/6
ksAppendKey
keySetName system/hosts/6/ipaddr
keySetString 14.14.14.14
ksAppendKey
keySetName system/hosts/6/canonical
keySetString newhost
ksAppendKey
kdbSet system/hosts
\end{DoxyCode}


This fails with an error similar to this


\begin{DoxyCode}
Sorry, module storage issued the error 85:
an Augeas error occurred: Failed to match
some augeas match expression
with tree
\{ \(\backslash\)"canonical\(\backslash\)" = \(\backslash\)"newhost\(\backslash\)" \} \{ \(\backslash\)"ipaddr\(\backslash\)" = \(\backslash\)"14.14.14.14\(\backslash\)" \}
\end{DoxyCode}


Whereas the following script succeeds due to the correct order


\begin{DoxyCode}
kdbGet system/hosts
keySetName system/hosts/6
ksAppendKey
keySetName system/hosts/6/ipaddr
keySetString 14.14.14.14
keySetMeta order 100
ksAppendKey
keySetName system/hosts/6/canonical
keySetString newhost
keySetMeta order 110
ksAppendKey
kdbSet system/hosts
\end{DoxyCode}


\subsection*{Planned Improvements}


\begin{DoxyItemize}
\item a validation plugin preventing inner node values 
\end{DoxyItemize}