[OpenAFS] How can I create new pag for a process whose euid doesn't equal to ruid under keyring setttings?

shuaijie wang wangshuaijie@gmail.com
Mon, 2 Sep 2013 13:30:35 +0800


--047d7b47215e2a699404e55fdfc5
Content-Type: text/plain; charset=ISO-8859-1

Thanks very much! I will switch to API approach.


2013/9/2 Russ Allbery <rra@stanford.edu>

> shuaijie wang <wangshuaijie@gmail.com> writes:
>
> > I have a daemon process whose ruid is a normal user and euid is root, it
> > does most of its work under normal user, but occasionally it needs to
> > change its euid to root to do something, so we can't just change both of
> > its ruid and euid to normal user.  And when I want to create a PAG for
> > this process, I make this process to fork a child to exec aklog -setpag
> > to do this, but our linux kernel is 2.6.34, which has keyring feature
> > enabled, and we found that under this circumstance, the keyring created
> > by this process belongs to the ruid, not euid, so the keyring created is
> > root, and the aklog forked by this daemon can't write into this keyring,
> > thus causing pag creation error.  And I've tries many ways to change the
> > permission of the keyring, but they didn't work.
>
> aklog -setpag is a horrible hack that (IMO) completely breaks the expected
> inheritance semantics of PAGs.  It's also rather fragile and has broken
> from time to time, since it requires a child process to change internal
> state of its parent, which is not an operation that's normally supposed to
> be possible.  I would never use it.
>
> Instead, create the PAG directly in the parent process using the
> k_setpag() function provided by libkafs or libkopenafs.
>
> --
> Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>
>

--047d7b47215e2a699404e55fdfc5
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks very much! I will switch to API approach.<br></div>=
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2013/9/2 Russ=
 Allbery <span dir=3D"ltr">&lt;<a href=3D"mailto:rra@stanford.edu" target=
=3D"_blank">rra@stanford.edu</a>&gt;</span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"im">shuaijie wang &lt;<a href=
=3D"mailto:wangshuaijie@gmail.com">wangshuaijie@gmail.com</a>&gt; writes:<b=
r>
<br>
&gt; I have a daemon process whose ruid is a normal user and euid is root, =
it<br>
&gt; does most of its work under normal user, but occasionally it needs to<=
br>
&gt; change its euid to root to do something, so we can&#39;t just change b=
oth of<br>
&gt; its ruid and euid to normal user. =A0And when I want to create a PAG f=
or<br>
&gt; this process, I make this process to fork a child to exec aklog -setpa=
g<br>
&gt; to do this, but our linux kernel is 2.6.34, which has keyring feature<=
br>
&gt; enabled, and we found that under this circumstance, the keyring create=
d<br>
&gt; by this process belongs to the ruid, not euid, so the keyring created =
is<br>
&gt; root, and the aklog forked by this daemon can&#39;t write into this ke=
yring,<br>
&gt; thus causing pag creation error. =A0And I&#39;ve tries many ways to ch=
ange the<br>
&gt; permission of the keyring, but they didn&#39;t work.<br>
<br>
</div>aklog -setpag is a horrible hack that (IMO) completely breaks the exp=
ected<br>
inheritance semantics of PAGs. =A0It&#39;s also rather fragile and has brok=
en<br>
from time to time, since it requires a child process to change internal<br>
state of its parent, which is not an operation that&#39;s normally supposed=
 to<br>
be possible. =A0I would never use it.<br>
<br>
Instead, create the PAG directly in the parent process using the<br>
k_setpag() function provided by libkafs or libkopenafs.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Russ Allbery (<a href=3D"mailto:rra@stanford.edu">rra@stanford.edu</a>) =A0=
 =A0 =A0 =A0 =A0 =A0 &lt;<a href=3D"http://www.eyrie.org/~eagle/" target=3D=
"_blank">http://www.eyrie.org/~eagle/</a>&gt;<br>
</font></span></blockquote></div><br></div>

--047d7b47215e2a699404e55fdfc5--