<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Apr 5, 2013, at 6:26 PM, David Tomaschik wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Having a shell in between shouldn't be a problem…</div></blockquote><div><br></div>It is. &nbsp;Here is what currently happens. &nbsp;C program that is setuid calls another C program via system(). &nbsp;The problem is, system spawns a new shell and the euid is not retained, hence when attempting to execute the 2nd C program, I get permission denied.</div><div><br></div><div>The same issue happens popen() because as the man page for popen says, it spawns a new shell with -c.</div><div><br></div><div>I've tested both this is accurate.</div><div><br></div><div>Here is the whole problem description:</div><div><br></div><div>1. cgi perl script calls an existing binary. &nbsp;(apache id executes)</div><div><br></div><div>2. existing binary calls a second binary via system() &nbsp;This program is only executable by a userid that is not apache</div><div><br></div><div>3. the second binary returns permission denied.</div><div><br></div><div>I have attempted setuid on the first binary. &nbsp;No good, still get permission denied.</div><div><br></div><div>I can run the perl script by hand as the user id that owns the second binary and it works fine. (command line)</div><div><br></div><div>The only solution I can see at this point is fork/exec, but the problem &nbsp;is &nbsp;I have to pipe info into the second program as well as pass positional parameters to it.</div><div><br></div><div>I hope this better explains the problem.</div><div><br></div><div>I'll revisit it tomorrow.</div><div><br></div><div><blockquote type="cite"><div dir="ltr"><div><br></div><div style="">Alternatively, set up a pipe, fork(), dup2(pipe_output, STDIN); exec(), (from parent process) push "stuff" into pipe?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 5, 2013 at 1:47 PM, Geoffrey Myers <span dir="ltr">&lt;<a href="mailto:lists@serioustechnology.com" target="_blank">lists@serioustechnology.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 dir="auto"><div>Actually, this won't work as it execs a shell. &nbsp;The binary is suid for a particle user and the program being spawned needs to be executed by the same user.&nbsp;<div class="im">
<br><br><div>--</div><div>From my iP<span>hone</span></div><div>Geoffrey Myers</div></div></div><div><br><div class="im">On Apr 5, 2013, at 3:53 PM, David Tomaschik &lt;<a href="mailto:david@systemoverlord.com" target="_blank">david@systemoverlord.com</a>&gt; wrote:<br>
<br></div></div><div><div class="h5"><blockquote type="cite"><div><div dir="ltr">Must it be fork/exec specifically? &nbsp;Seems like popen would be easier... popen("somebinary arg1 arg2", "w"); then write stuff to the returned file ptr?</div>
<div class="gmail_extra"><br><br>
<div class="gmail_quote">On Fri, Apr 5, 2013 at 12:33 PM, Geoffrey Myers <span dir="ltr">&lt;<a href="mailto:lists@serioustechnology.com" target="_blank">lists@serioustechnology.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

So, shaking some cobwebs loose here. How do I replace the following:<br>
<br>
system("echo stuff | somebinary arg1 arg2");<br>
<br>
With a fork/exec ??<br>
<br>
(Digging out my old C books....)<br>
<br>
--<br>
From my iPhone<br>
<span><font color="#888888">Geoffrey Myers<br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>David Tomaschik<br>OpenPGP: 0x5DEA789B<br><a href="http://systemoverlord.com/" target="_blank">http://systemoverlord.com</a><br><a href="mailto:david@systemoverlord.com" target="_blank">david@systemoverlord.com</a>
</div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Ale mailing list</span><br><span><a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a></span><br>
<span><a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a></span><br><span>See JOBS, ANNOUNCE and SCHOOLS lists at</span><br><span><a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a></span><br>
</div></blockquote></div></div></div><br>_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>David Tomaschik<br>OpenPGP: 0x5DEA789B<br><a href="http://systemoverlord.com/" target="_blank">http://systemoverlord.com</a><br><a href="mailto:david@systemoverlord.com" target="_blank">david@systemoverlord.com</a>
</div>
_______________________________________________<br>Ale mailing list<br><a href="mailto:Ale@ale.org">Ale@ale.org</a><br>http://mail.ale.org/mailman/listinfo/ale<br>See JOBS, ANNOUNCE and SCHOOLS lists at<br>http://mail.ale.org/mailman/listinfo<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>--</div><div>Until later, Geof</div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>