
\begin{DoxyItemize}
\item infos = Information about path plugin is in keys below
\item infos/author = Markus Raab \href{mailto:elektra@libelektra.org}{\texttt{ elektra@libelektra.\+org}}
\item infos/licence = BSD
\item infos/placements = presetstorage
\item infos/needs =
\item infos/provides = check
\item infos/status = maintained nodep libc nodoc
\item infos/metadata = check/path check/path/mode check/path/user
\item infos/description = Checks if keys enriched with appropriate metadata contain valid paths as values as well as correct permissions
\end{DoxyItemize}\hypertarget{md_src_plugins_path_README_src_plugins_path_README_md}{}\doxysection{Introduction}\label{md_src_plugins_path_README_src_plugins_path_README_md}
This plugin checks whether the value of a key is a valid file system path and optionally if correct permissions are set for a certain user.\hypertarget{md_src_plugins_path_README_autotoc_md387}{}\doxysection{Installation}\label{md_src_plugins_path_README_autotoc_md387}
See \mbox{\hyperlink{doc_INSTALL_md}{installation}}. The package is called {\ttfamily libelektra5-\/extra}.\hypertarget{md_src_plugins_path_README_autotoc_md388}{}\doxysection{Purpose}\label{md_src_plugins_path_README_autotoc_md388}
The motivation to write this plugin is given by the two paths that exist in /etc/fstab\+: the device file and the mountpoint. A missing file is not necessarily an error, because the device file may appear later when a device is plugged in and the mountpoint may be there when another subsequent mount was executed. So only warnings are yielded in that case. One situation, however, presents an error\+: Only an absolute path is allowed to occur for both device and mountpoint. When checking for relative files, it is not enough to look at the first character if it is a {\ttfamily /}, because remote file systems and some special names are valid, too.

If {\ttfamily check/path/mode = $<$permission$>$} is also present it will check for the correct permissions of the file/directory. Optionally, you can also add {\ttfamily check/path/user = $<$user$>$"{}} which then checks the permissions for the given user. When calling {\ttfamily kdb set} on the actual key, you have to run as {\ttfamily root} user or the file permissions cannot be checked (you will receive an error message). It is also possible to leave the {\ttfamily check/path/user} empty (just provide an empty string) which then takes the executing user as target to check. So for example {\ttfamily sudo kdb set ...} will check if {\ttfamily root} can access the target file/directory whereas {\ttfamily kdb set ...} will take the current executing process/user. If {\ttfamily check/path/user} is not given at all, the plugin will check accessibility for the {\ttfamily root} user only (which again requires {\ttfamily sudo})

{\ttfamily check/path/mode = rw} and {\ttfamily check/path/user = tomcat} for example will check if the user {\ttfamily tomcat} has read and write access to the path which was set for the key. Please note that the file has to exist already and it is not checked if the user has the right to create a file in the directory.

Permissions available\+:


\begin{DoxyItemize}
\item {\ttfamily r}\+: $\ast$$\ast$\+R$\ast$$\ast$ead
\item {\ttfamily w}\+: $\ast$$\ast$\+W$\ast$$\ast$rite
\item {\ttfamily x}\+: e$\ast$$\ast$\+X$\ast$$\ast$ecute
\end{DoxyItemize}\hypertarget{md_src_plugins_path_README_autotoc_md389}{}\doxysection{Usage}\label{md_src_plugins_path_README_autotoc_md389}
If the metakey {\ttfamily check/path} is present, it is checked if the value is a valid absolute file system path. If a metavalue is present, an additional check will be done if it is a directory or device file.\hypertarget{md_src_plugins_path_README_autotoc_md390}{}\doxysection{Examples}\label{md_src_plugins_path_README_autotoc_md390}
An example on which the user should have no permission at all for the root directory.


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount test.dump user:/tests path dump}
\DoxyCodeLine{sudo kdb set user:/tests/path "{}\$HOME"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path "{}"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path/user "{}"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path/mode "{}rw"{}}
\DoxyCodeLine{}
\DoxyCodeLine{\# Standard users should not be able to read/write the root folder}
\DoxyCodeLine{[ \$(id -\/u) = 0 ] \&\& printf >\&2 'User is root\(\backslash\)n' || kdb set user:/tests/path "{}/root"{}}
\DoxyCodeLine{\# STDERR: User is root|.*C03200.*}
\DoxyCodeLine{}
\DoxyCodeLine{\# Set something which the current user can access for sure}
\DoxyCodeLine{kdb set user:/tests/path "{}\$HOME"{}}
\DoxyCodeLine{\# STDOUT-\/REGEX: .*Set string to "{}/.*"{}.*}
\DoxyCodeLine{}
\DoxyCodeLine{\#cleanup}
\DoxyCodeLine{sudo kdb rm -\/r user:/tests}
\DoxyCodeLine{sudo kdb umount user:/tests}

\end{DoxyCode}


An example where part of the permissions are missing for a tmp file


\begin{DoxyCode}{0}
\DoxyCodeLine{sudo kdb mount test.dump user:/tests path dump}
\DoxyCodeLine{sudo kdb set user:/tests/path "{}\$HOME"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path "{}"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path/user "{}"{}}
\DoxyCodeLine{sudo kdb meta-\/set user:/tests/path check/path/mode "{}rwx"{}}
\DoxyCodeLine{}
\DoxyCodeLine{\# Standard users should not be able to read/write the root folder}
\DoxyCodeLine{kdb set user:/tests/path/tempfile \$(mktemp)}
\DoxyCodeLine{chmod +rw `kdb get user:/tests/path/tempfile`}
\DoxyCodeLine{kdb set user:/tests/path `kdb get user:/tests/path/tempfile`}
\DoxyCodeLine{\# ERROR:C03200}
\DoxyCodeLine{}
\DoxyCodeLine{\# Set something which the current user can access for sure}
\DoxyCodeLine{chmod +x `kdb get user:/tests/path/tempfile`}
\DoxyCodeLine{kdb set user:/tests/path `kdb get user:/tests/path/tempfile`}
\DoxyCodeLine{\# STDOUT-\/REGEX: Set string to "{}/.*"{}.*}
\DoxyCodeLine{}
\DoxyCodeLine{\#cleanup}
\DoxyCodeLine{sudo rm -\/rf `kdb get user:/tests/path/tempfile`}
\DoxyCodeLine{sudo kdb rm -\/r user:/tests}
\DoxyCodeLine{sudo kdb umount user:/tests}

\end{DoxyCode}
\hypertarget{md_src_plugins_path_README_autotoc_md391}{}\doxysection{Future work}\label{md_src_plugins_path_README_autotoc_md391}
Add a check which ensures that the given path is a file/directory/symbolic link/hard link/etc. 