Few comments:<br><br>* variables named like &quot;pPrivSet&quot; do not match local style.&nbsp; <br><br>* large #ifdef&#39;ed out code are generally frowned upon.&nbsp; Could it be in a separate file (solaris-priv-drop.c?) which is conditionally compiled and linked in?&nbsp; Then the #ifdef segment could be one line.<br>
<br><br><div class="gmail_quote">On Mon, Jun 16, 2008 at 5:13 PM, Glenn Brunette &lt;<a href="mailto:Glenn.Brunette@sun.com">Glenn.Brunette@sun.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
[Sorry for the re-send. &nbsp;Not sure what is going on. &nbsp;Full message<br>
was in Thunderbird when I sent it...]<div class="Ih2E3d"><br>
<br>
All,<br>
<br>
Per a suggestion from Brad, I wanted to follow up on my original<br>
posting with unified diffs for each of the two files modified. &nbsp;In<br>
addition, I compiled and tested memcached with these changes on a<br>
up-to-date (fully patched) Ubuntu Linux (Hardy Heron) system and<br>
everything worked as expected. &nbsp;Tests pass on both Solaris and Linux.<br>
<br>
During &quot;configure&quot;, you will see the following on Linux:<br>
<br>
checking for setppriv... no<br>
checking priv.h usability... no<br>
checking priv.h presence... no<br>
checking for priv.h... no<br>
<br></div>
During &quot;configure&quot;, you will see the following on Solaris:<br>
<br>
checking for setppriv... yes<br>
checking priv.h usability... yes<br>
checking priv.h presence... yes<br>
checking for priv.h... yes<br>
<br>
Included below are the unifed diffs...<br>
<br>
g<br>
<br>
--- BEGIN DIFFS ---<br>
<br>
--- memcached-1.2.5/<a href="http://configure.ac" target="_blank">configure.ac</a> &nbsp; &nbsp; &nbsp; &nbsp;Mon Mar &nbsp;3 14:59:47 2008<br>
+++ memcached-1.2.5-priv/<a href="http://configure.ac" target="_blank">configure.ac</a> &nbsp; Mon Jun &nbsp;9 10:45:53 2008<br>
@@ -201,6 +201,8 @@<br>
&nbsp;AC_CHECK_FUNCS(mlockall)<br>
&nbsp;AC_CHECK_FUNCS(getpagesizes)<br>
&nbsp;AC_CHECK_FUNCS(memcntl)<br>
+AC_CHECK_FUNCS(setppriv)<br>
+AC_CHECK_HEADER(priv.h, AC_DEFINE(HAVE_PRIV_H,,[do we have priv.h?]))<br>
<br>
&nbsp;AC_CONFIG_FILES(Makefile doc/Makefile)<br>
&nbsp;AC_OUTPUT<br>
<br>
<br>
<br>
--- ./memcached-1.2.5/memcached.c &nbsp; &nbsp; &nbsp; Mon Mar &nbsp;3 14:13:45 2008<br>
+++ ./memcached-1.2.5-priv/memcached.c &nbsp;Mon Jun &nbsp;9 13:31:04 2008<br>
@@ -59,6 +59,10 @@<br>
&nbsp;#endif<br>
&nbsp;#endif<br>
<br>
+#ifdef HAVE_PRIV_H<br>
+#include &lt;priv.h&gt;<br>
+#endif /* HAVE_PRIV_H */<br>
+<br>
&nbsp;/*<br>
 &nbsp;* forward declarations<br>
 &nbsp;*/<br>
@@ -3044,7 +3048,55 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; }<br>
 &nbsp; &nbsp; }<br>
<br>
+#if defined(HAVE_PRIV_H) &amp;&amp; defined(HAVE_SETPPRIV)<br>
<br>
+ &nbsp; &nbsp;/* this section of code will drop all (Solaris) privileges including those<br>
+ &nbsp; &nbsp; * normally granted to all userland process (basic privileges). The effect<br>
+ &nbsp; &nbsp; * of this is that after running this code, the process will not able to<br>
+ &nbsp; &nbsp; * fork(), exec(), etc. &nbsp;See privileges(5) for more information.<br>
+ &nbsp; &nbsp; */<br>
+<br>
+ &nbsp; &nbsp;priv_set_t *pPrivSet = NULL;<br>
+ &nbsp; &nbsp;priv_set_t *oPrivSet = NULL;<br>
+<br>
+ &nbsp; &nbsp;if ((pPrivSet = priv_str_to_set(&quot;basic&quot;, &quot;,&quot;, NULL)) == NULL) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;priv_str_to_set&quot;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br>
+ &nbsp; &nbsp;}<br>
+<br>
+ &nbsp; &nbsp;(void) priv_delset(pPrivSet, PRIV_FILE_LINK_ANY);<br>
+ &nbsp; &nbsp;(void) priv_delset(pPrivSet, PRIV_PROC_EXEC);<br>
+ &nbsp; &nbsp;(void) priv_delset(pPrivSet, PRIV_PROC_FORK);<br>
+ &nbsp; &nbsp;(void) priv_delset(pPrivSet, PRIV_PROC_INFO);<br>
+ &nbsp; &nbsp;(void) priv_delset(pPrivSet, PRIV_PROC_SESSION);<br>
+<br>
+ &nbsp; &nbsp;if (setppriv(PRIV_SET, PRIV_PERMITTED, pPrivSet) != 0) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;setppriv(PRIV_SET, PRIV_PERMITTED)&quot;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br>
+ &nbsp; &nbsp;}<br>
+<br>
+ &nbsp; &nbsp;if ((oPrivSet = priv_allocset()) == NULL) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;priv_allocset&quot;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br>
+ &nbsp; &nbsp;}<br>
+<br>
+ &nbsp; &nbsp;priv_emptyset(oPrivSet);<br>
+<br>
+ &nbsp; &nbsp;if (setppriv(PRIV_SET, PRIV_INHERITABLE, oPrivSet) != 0) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;setppriv(PRIV_SET, PRIV_INHERITABLE)&quot;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br>
+ &nbsp; &nbsp;}<br>
+<br>
+ &nbsp; &nbsp;if (setppriv(PRIV_SET, PRIV_LIMIT, oPrivSet) != 0) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;setppriv(PRIV_SET, PRIV_LIMIT)&quot;);<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br>
+ &nbsp; &nbsp;}<br>
+<br>
+ &nbsp; &nbsp;priv_freeset(pPrivSet);<br>
+ &nbsp; &nbsp;priv_freeset(oPrivSet);<br>
+<br>
+#endif /* defined(HAVE_PRIV_H) &amp;&amp; defined(HAVE_SETPPRIV) */<br>
+<br>
 &nbsp; &nbsp; /* initialize main thread libevent instance */<br>
 &nbsp; &nbsp; main_base = event_init();<br>
<br>
<br>
--- END DIFFS ---<br>
</blockquote></div><br>