<div dir="ltr"><div dir="ltr">On Sat, 19 Mar 2016 at 06:27 Matt Riedemann <<a href="mailto:mriedem@linux.vnet.ibm.com">mriedem@linux.vnet.ibm.com</a>> wrote:<br></div><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">I stared pretty hard at the nova rootwrap filter change today [1] and<br>tried to keep that in my head along with the devstack change and the<br>changes to os-brick (which depend on the devstack/cinder/nova changes).<br>And with reading the privsep-helper command code in privsep itself.<br><br>I realize this is a bridge to fix the tightly couple lockstep upgrade<br>issue between cinder and nova, but it would be super helpful, at least<br>for me, to chart out how that nova rootwrap filter change fits into the<br>bigger picture, like what calls what and how, where are things used, etc.<br><br>I see devstack passing on the os-brick change so I'm inclined to almost<br>blindly approve to just keep moving, but I'd feel bad about that. Would<br>it be possible to flow chart this out somewhere?<br></blockquote><div> </div>Sorry for all the confusion Matt.  I obviously explained it poorly in my gerrit reply to you and I presume also in the parts of the oslo spec that you've read, so I'll try another explanation here:<div><br></div><div>privsep fundamentally involves two processes - the regular (nova, whatever) unprivileged code, and a companion Unix process running with some sort of elevated privileges (different uid/gid, extra Linux capabilities, whatever).  These two processes talk to each other over a Unix socket in the obvious way.</div><div><br></div><div>*Conceptually* the companion privileged process is a fork from the unprivileged process - in that the python environment (oslo.config, etc) tries to be as similar as possible and writing code that runs in the privileged process looks just like python defined in the original process but with a particular decorator.</div><div><br></div><div>privsep has two modes of setting up this split-process-with-ipc-channel arrangement:</div><div>- One is to use a true fork(), which follows the traditional Unix daemon model of starting with full privileges (from init or whatever) and then dropping privileges later - this avoids sudo, is more secure (imo), and is a whole lot simpler in the privsep code, but requires a change to the way OpenStack services are deployed, and a function call at the top of main() before dropping privileges.</div><div>- The second is to invoke sudo or sudo+rootwrap from the unprivileged process to run the "privsep-helper" command that you see in this change.  This requires no changes to the way OpenStack services are deployed, so is the method I'm recommending atm.  (We may never actually use the fork() method tbh given how slowly things change in OpenStack.)  It is completely inconsequential whether this uses sudo or sudo+rootwrap - it just affects whether you need to add a line to sudoers or rootwrap filters.  I chose rootwrap filter here because I thought we had greater precedent for that type of change.</div><div><br></div><div>So hopefully that makes the overall picture clear:  We need this nova rootwrap filter addition so privsep-helper can use sudo+rootwrap to become root, so it can switch to the right set of elevated privileges, so we can run the relevant privsep-decorated privileged functions in that privileged environment.</div><div><br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I also have a concern in there about how the privsep-helper rootwrap<br>
command in nova is only using the os-brick context. What happens if<br>
os-vif and nova need to share common rootwrap commands? At the midcycle<br>
Jay and Daniel said there weren't any coming up soon, but if that<br>
happens, how do we handle it?</blockquote><div><br></div><div>privsep is able to have different "privileged contexts", which can each run as different uids and with different Linux capabilities.  In practice each context has its own privileged process, and if we're using the sudo(+rootwrap) and privsep-helper method, then each context will want its own line in sudoers or rootwrap filters.</div><div>It is expected that most OpenStack services would only have one or maybe two different contexts, but nova may end up with a few more because it has its fingers in so many different pies.  So yes, we'll want another entry similar to this one for os-vif - presumably os-vif will want CAP_NET_ADMIN, whereas os-brick wants various storage device-related capabilities.</div><div><br></div><div><br></div><div>Again, I'm disappointed the relevant section of the privsep spec failed to explain the above sufficiently - if this conversation helps clarify it for you, *please* suggest some better wording for the spec.  It seems (understandably!) no-one wants to approve even the smallest self-contained privsep-related change without understanding the entire overall process, so I feel like I've had the above conversation about 10 times now.  It would greatly improve everyone's productivity if we can get the spec (or some new doc) to a place where it can become the place where people learn about privsep, and they don't have to wait for me to reply with poorly summarised versions.</div><div><br></div><div> - Gus</div></div></div></div>