<div dir="ltr"><div hspace="streak-pt-mark" style="max-height:1px"><img style="width:0px; max-height:0px;" src="https://mailfoogae.appspot.com/t?sender=aZXJpY0B3aW5kaXNjaC51cw%3D%3D&type=zerocontent&guid=1f5b166c-c37d-4b6d-9154-2391bb2f16ee"><font color="#ffffff" size="1">ᐧ</font></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><span style="line-height:1.5"><br></span></div><div><span style="line-height:1.5">    </span>from neutron.agent.privileged.commands import ip_lib as priv_ip</div><div><span style="line-height:1.5">    def foo():</span></div><div><span style="line-height:1.5">        # Need to create a new veth interface pair - that usually requires root/NET_ADMIN</span></div><div><span style="line-height:1.5">        priv_ip.CreateLink('veth', 'veth0', peer='veth1')</span></div><div><br></div><div>Because we now have elevated privileges directly (on the privileged daemon side) without having to shell out through sudo, we can do all sorts of nicer things like just using netlink directly to configure networking.  This avoids the overhead of executing subcommands, the ugliness (and danger) of generating command lines and regex parsing output, and make us less reliant on specific versions of command line tools (since the kernel API should be very stable).</div></div></blockquote><div><br></div><div>One of the advantages of spawning a new process is being able to use flags to clone(2) and to set capabilities. This basically means to create containers, by some definition. Anything you have in a "privileged daemon" or privileged process ideally should reduce its privilege set for any operation it performs. That might mean it clones itself and executes Python, or it may execvp an executable, but either way, the new process would have less-than-full-privilege.</div><div><br></div><div>For instance, writing a file might require root access, but does not need the ability to load kernel modules. Changing network interfaces does not need access to the filesystem, no more than changes to the filesystem needs access to the network. The capabilities and namespaces mechanisms resolve these security conundrums and simplify principle of least privilege.</div><div><br></div><div>Regards,</div><div>Eric Windisch</div></div></div></div>