
\begin{DoxyItemize}
\item infos = Information about hosts plugin is in keys below
\item infos/author = Markus Raab \href{mailto:elektra@libelektra.org}{\texttt{ elektra@libelektra.\+org}}
\item infos/licence = B\+SD
\item infos/provides = storage/hosts
\item infos/needs =
\item infos/recommends = glob error network
\item infos/placements = getstorage setstorage
\item infos/status = maintained unittest nodep libc limited
\item infos/metadata = order comment/\# comment/\#/start comment/\#/space
\item infos/description = This plugin reads and writes /etc/hosts files.
\end{DoxyItemize}\hypertarget{md_src_plugins_hosts_README_src_plugins_hosts_README_md}{}\doxysection{Introduction}\label{md_src_plugins_hosts_README_src_plugins_hosts_README_md}
The {\ttfamily /etc/hosts} file is a simple text file that associates IP addresses with hostnames, one line per IP address. The format is described in {\ttfamily hosts(5)}.\hypertarget{md_src_plugins_hosts_README_autotoc_md265}{}\doxysection{Special values}\label{md_src_plugins_hosts_README_autotoc_md265}
\hypertarget{md_src_plugins_hosts_README_autotoc_md266}{}\doxysubsection{Hostnames}\label{md_src_plugins_hosts_README_autotoc_md266}
Canonical hostnames are stored as key names with their IP address as value.\hypertarget{md_src_plugins_hosts_README_autotoc_md267}{}\doxysubsection{Aliases}\label{md_src_plugins_hosts_README_autotoc_md267}
Aliases are stored as sub keys with a read only duplicate of the associated IP address as value.\hypertarget{md_src_plugins_hosts_README_autotoc_md268}{}\doxysubsection{Comments}\label{md_src_plugins_hosts_README_autotoc_md268}
Comments are stored according to the comment metadata specification (see \href{/home/mpranj/workspace/libelektra/doc/METADATA.ini}{\texttt{ /doc/\+M\+E\+T\+A\+D\+A\+TA.ini}} for more information).\hypertarget{md_src_plugins_hosts_README_autotoc_md269}{}\doxysubsection{Ordering}\label{md_src_plugins_hosts_README_autotoc_md269}
The ordering of the hosts is stored in metakeys of type {\ttfamily order}. The value is an ascending number. Ordering of aliases is {\itshape not} preserved.\hypertarget{md_src_plugins_hosts_README_autotoc_md270}{}\doxysection{Examples}\label{md_src_plugins_hosts_README_autotoc_md270}
Mount the plugin\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount -\/-\/with-\/recommends /etc/hosts system/hosts hosts}
\end{DoxyCode}


Print out all known hosts and their aliases\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb ls system/hosts}
\end{DoxyCode}


Get IP address of ipv4 host \char`\"{}localhost\char`\"{}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb get system/hosts/ipv4/localhost}
\end{DoxyCode}


Check if a comment is belonging to host \char`\"{}localhost\char`\"{}\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{kdb meta-\/ls system/hosts/ipv4/localhost}
\end{DoxyCode}


Try to change the host \char`\"{}localhost\char`\"{}, should fail because it is not an I\+Pv4 address\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb set system/hosts/ipv4/localhost ::1}
\end{DoxyCode}


\`{}\`{}\`{} \hypertarget{md_src_plugins_hosts_README_autotoc_md271}{}\doxysection{Backup-\/and-\/\+Restore\+:/tests/hosts}\label{md_src_plugins_hosts_README_autotoc_md271}
sudo kdb mount --with-\/recommends hosts /tests/hosts hosts\hypertarget{md_src_plugins_hosts_README_autotoc_md272}{}\doxysection{Create hosts file for testing}\label{md_src_plugins_hosts_README_autotoc_md272}
echo \textquotesingle{}127.\+0.\+0.\+1 localhost\textquotesingle{} $>$ {\ttfamily kdb file /tests/hosts} echo \textquotesingle{}\+::1 localhost\textquotesingle{} $>$$>$ {\ttfamily kdb file /tests/hosts}\hypertarget{md_src_plugins_hosts_README_autotoc_md273}{}\doxysection{Check the file}\label{md_src_plugins_hosts_README_autotoc_md273}
cat {\ttfamily kdb file /tests/hosts} \#$>$ 127.\+0.\+0.\+1 localhost \#$>$ \+::1 localhost\hypertarget{md_src_plugins_hosts_README_autotoc_md274}{}\doxysection{Check if the values are read correctly}\label{md_src_plugins_hosts_README_autotoc_md274}
kdb get /tests/hosts/ipv4/localhost \#$>$ 127.\+0.\+0.\+1 kdb get /tests/hosts/ipv6/localhost \#$>$ \+::1\hypertarget{md_src_plugins_hosts_README_autotoc_md275}{}\doxysection{Should both fail with error 04200 and return 5}\label{md_src_plugins_hosts_README_autotoc_md275}
kdb set /tests/hosts/ipv4/localhost \+::1 \hypertarget{md_src_plugins_hosts_README_autotoc_md276}{}\doxysection{R\+E\+T\+:5}\label{md_src_plugins_hosts_README_autotoc_md276}
\hypertarget{md_src_plugins_hosts_README_autotoc_md277}{}\doxysection{E\+R\+R\+O\+R\+:\+C03200}\label{md_src_plugins_hosts_README_autotoc_md277}
kdb set /tests/hosts/ipv6/localhost 127.\+0.\+0.\+1 \hypertarget{md_src_plugins_hosts_README_autotoc_md278}{}\doxysection{R\+E\+T\+:5}\label{md_src_plugins_hosts_README_autotoc_md278}
\hypertarget{md_src_plugins_hosts_README_autotoc_md279}{}\doxysection{E\+R\+R\+O\+R\+:\+C03200}\label{md_src_plugins_hosts_README_autotoc_md279}
\hypertarget{md_src_plugins_hosts_README_autotoc_md280}{}\doxysection{cleanup}\label{md_src_plugins_hosts_README_autotoc_md280}
kdb rm -\/r /tests/hosts sudo kdb umount /tests/hosts \`{}\`{}\`{}\hypertarget{md_src_plugins_hosts_README_autotoc_md281}{}\doxysubsection{Limitations}\label{md_src_plugins_hosts_README_autotoc_md281}

\begin{DoxyItemize}
\item host names are not validated (see \href{https://issues.libelektra.org/2185}{\texttt{ https\+://issues.\+libelektra.\+org/2185}}) 
\end{DoxyItemize}