<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 26, 2016 at 4:49 PM, Niels de Vos <span dir="ltr">&lt;<a href="mailto:ndevos@redhat.com" target="_blank">ndevos@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Sep 23, 2016 at 08:44:14PM +0530, Pranith Kumar Karampuri wrote:<br>
&gt; On Fri, Sep 23, 2016 at 6:12 PM, Jeff Darcy &lt;<a href="mailto:jdarcy@redhat.com">jdarcy@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; &gt; Jiffin found an interesting problem in posix xlator where we have never<br>
&gt; &gt; been<br>
&gt; &gt; &gt; using setfsuid/gid ( <a href="http://review.gluster.org/#/c/15545/" rel="noreferrer" target="_blank">http://review.gluster.org/#/c/<wbr>15545/</a> ), what I am<br>
&gt; &gt; &gt; seeing regressions after this is, if the files are created using non-root<br>
&gt; &gt; &gt; user then the file creation fails because that user doesn&#39;t have<br>
&gt; &gt; permissions<br>
&gt; &gt; &gt; to create the gfid-link. So it seems like the correct way forward for<br>
&gt; &gt; this<br>
&gt; &gt; &gt; patch is to write wrappers around sys_&lt;syscall&gt; to do setfsuid/gid do the<br>
&gt; &gt; &gt; actual operation requested and then set it back to old uid/gid and then<br>
&gt; &gt; do<br>
&gt; &gt; &gt; the internal operations. I am planning to write posix_sys_&lt;syscall&gt;() to<br>
&gt; &gt; do<br>
&gt; &gt; &gt; the same, may be a macro?<br>
&gt; &gt;<br>
&gt; &gt; Kind of an aside, but I&#39;d prefer to see a lot fewer macros in our code.<br>
&gt; &gt; They&#39;re not type-safe, and multi-line macros often mess up line numbers for<br>
&gt; &gt; debugging or error messages.  IMO it&#39;s better to use functions whenever<br>
&gt; &gt; possible, and usually to let the compiler worry about how/when to inline.<br>
&gt; &gt;<br>
&gt; &gt; &gt; I need inputs from you guys to let me know if I am on the right path and<br>
&gt; &gt; if<br>
&gt; &gt; &gt; you see any issues with this approach.<br>
&gt; &gt;<br>
&gt; &gt; I think there&#39;s a bit of an interface problem here.  The sys_xxx wrappers<br>
&gt; &gt; don&#39;t have arguments that point to the current frame, so how would they get<br>
&gt; &gt; the correct uid/gid?  We could add arguments to each function, but then<br>
&gt; &gt; we&#39;d have to modify every call.  This includes internal calls which don&#39;t<br>
&gt; &gt; have a frame to pass, so I guess they&#39;d have to pass NULL.  Alternatively,<br>
&gt; &gt; we could create a parallel set of functions with frame pointers.  Contrary<br>
&gt; &gt; to what I just said above, this might be a case where macros make sense:<br>
&gt; &gt;<br>
&gt; &gt;    int<br>
&gt; &gt;    sys_writev_fp (call_frame_t *frame, int fd, void *buf, size_t len)<br>
&gt; &gt;    {<br>
&gt; &gt;       if (frame) { setfsuid(...) ... }<br>
&gt; &gt;       int ret = writev (fd, buf, len);<br>
&gt; &gt;       if (frame) { setfsuid(...) ... }<br>
&gt; &gt;       return ret;<br>
&gt; &gt;    }<br>
&gt; &gt;    #define sys_writev(fd,buf,len) sys_writev_fp (NULL, fd, buf, len)<br>
&gt; &gt;<br>
&gt; &gt; That way existing callers don&#39;t have to change, but posix can use the<br>
&gt; &gt; extended versions to get the right setfsuid behavior.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; After trying to do these modifications to test things out, I am now under<br>
&gt; the impression to remove setfsuid/gid altogether and depend on posix-acl<br>
&gt; for permission checks. It seems too cumbersome as the operations more often<br>
&gt; than not happen on files inside .glusterfs and non-root users/groups don&#39;t<br>
&gt; have permissions at all to access files in that directory.<br>
<br>
</div></div>But the files under .glusterfs are hardlinks. Except for creation and<br>
removal, should the users not have access to read/write and update<br>
attributes and xattrs?<br>
<br>
I would prefer to rely on the VFS permission checking on the bricks, and<br>
not bother with the posix-acl xlator when the filesystem on the brick<br>
supports POSIX ACLs.<br></blockquote><div><br></div><div>Could you list down the pros/cons with each approach?<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Niels<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Pranith<br></div></div>
</div></div>