arcanis.me/devs/netctl-gui-security-notes.html
2014-09-06 22:27:32 +04:00

113 lines
6.7 KiB
HTML

<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui secutiry notes</title>
<style type="text/css">
img {
display: block;
margin: 0 auto;
}
small {
font-size: 70%;
}
</style>
</head>
<body>
<h1>netctl-gui security notes</h1>
<h3>Project version : 1.3.1</h3>
<ol>
<li><a href="#arch">Architecture</a></li>
<li><a href="#library">Library</a></li>
<li><a href="#helper">Helper</a></li>
<li><a href="#gui">Graphical interface</a></li>
<li><a href="#kde">KDE components</a></li>
<li><a href="#links">External links</a></li>
</ol>
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
<p></p>
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
<img src="architecture.png" alt="architecture">
<h2><a href="#library" class="anchor" id="library"></a>Library</h2>
<p>According to <a href="#arch">the scheme</a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
<ul>
<li>Netctl control module</li>
<li><ul>
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable &lt;profile&gt;</code>. They are commands which provide a general control to netctl.</li>
<li><code>systemctl start|restart|enable &lt;netctl-auto@service&gt;</code>. They are commands which provide ability to control netctl-auto systemd service.</li>
</ul></li>
<li>Netctl profiles module</li>
<li><ul>
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
</ul></li>
<li>WiFi module</li>
<li><ul>
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
</ul></li>
</ul>
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
<p>Profiles reading should be described. Since profiles has shell-like syntax some variables (which provide an array) cannot be reading by usual ways. To do it library uses bash:</p>
<pre>
# define system variables
env -i bash -c "set"
# get profile and system variable list
env -i bash -c "source '&lt;profile&gt;'; set"
# get profile variables
env -i bash -c "source '&lt;profile&gt;'; for i in &#36;{!&lt;key&gt;[@]}; do echo &#36;{&lt;key&gt;[$i]}; done"
</pre>
<h2><a href="#helper" class="anchor" id="helper"></a>Helper</h2>
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>network</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
<p>By default <code>netctgui-helper</code> binary has capabilities to set UID to the children processes (<code>CAP_SETUID</code>). If you do not want to get these capabilities you may use <code>-DUSE_CAPABILITIES</code> cmake flag. Please refer to <code>man 7 capabilities</code> for more details.</p>
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
<h2><a href="#gui" class="anchor" id="gui"></a>Graphical interface</h2>
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
<h2><a href="#kde" class="anchor" id="kde"></a>KDE components</h2>
<p>There are two netctl-based commands which are run from the DataEngine</p>
<ul>
<li><code>&lt;cmd&gt; list</code></li>
<li><code>netctl is-enabled &lt;profile&gt;</code></li>
</ul>
<p>Both of them do not require any additional privileges normally. Also DataEngine has two other command which will be run from; they should define external IP. According to the idea that user can set <b>any</b> command to run, this module is not secure. But running commands will not do more than user can do from console himself.</p>
<p>The widget gets information from DataEngine, thus it does not require any additional permissions to show information. But netctl calls are used to control netctl. In this case used commands are</p>
<ul>
<li><code>netctl enable &lt;profile&gt;</code></li>
<li><code>netctl disable &lt;profile&gt;</code></li>
<li><code>netctl restart &lt;profile&gt;</code></li>
<li><code>netctl start &lt;profile&gt;</code></li>
<li><code>netctl stop &lt;profile&gt;</code></li>
<li><code>netctl stop-all</code></li>
<li><code>netctl switch-to &lt;profile&gt;</code></li>
<li><code>netctl-auto switch-to &lt;profile&gt;</code></li>
</ul>
<p>All netctl-based commands <b>require</b> root privileges and <code>sudo</code> (and any other alternatives) is used normally as prefix to the commands. The netctl-auto command <b>does not require</b> additional permissions.</p>
<p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
<ul>
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
</ul>
<small>
&copy; 2014-2014 <a href="mailto:esalexeev@gmail.com">Evgeniy Alekseev</a><br>
This software is licensed under GPLv3
</small>
</body>
</html>