<br><div class="gmail_quote">On Tue, Nov 16, 2010 at 9:37 AM, Tim Arnold <span dir="ltr"><<a href="mailto:tim.arnold@sas.com">tim.arnold@sas.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
"Tim Harig" <<a href="mailto:usernet@ilthio.net">usernet@ilthio.net</a>> wrote in message<br>
news:ibs8h9$jmq$1@speranza.aioe.org...<br>
<div><div></div><div class="h5">> On 2010-11-15, Tim Arnold <<a href="mailto:a_jtim@bellsouth.net">a_jtim@bellsouth.net</a>> wrote:<br>
>> On Nov 15, 10:41 am, Tim Harig <<a href="mailto:user...@ilthio.net">user...@ilthio.net</a>> wrote:<br>
>>> On 2010-11-15, Tim Arnold <<a href="mailto:a_j...@bellsouth.net">a_j...@bellsouth.net</a>> wrote:<br>
>>><br>
>>> > How can I enable the server process to write into the client's<br>
>>> > directories?<br>
>>> > If I change the inetd service to run as 'root', I guess that would<br>
>>> > work, but then the client couldn't remove the files put there after<br>
>>> > the request.<br>
>>><br>
>>> Python provides os.setuid() and os.seteuid() which wrap the system<br>
>>> functions. See you systems man pages for these functions for more<br>
>>> information.<br>
>><br>
>> Thanks -- that was a lot easier than I thought it was going to be.<br>
>> pass the client's uid in the message to the server like so<br>
>><br>
>> argstring, local_dir, uid = message.split(':')<br>
>> os.seteuid(int(uid))<br>
><br>
> I am not sure exactly what you are doing; but, I would advise great<br>
> caution as messing this up could easily open your system to exploitation.<br>
> Be very sure that you know what you are doing.<br>
<br>
</div></div>I can see how that looks dangerous, but I think it's okay. I have inetd<br>
listening on a port and whatever it receives, it passes on to that line<br>
above "argstring, local_dir, uid message.split(':').  The argstring is<br>
parsed using 'argparse' the resulting list of args is passed to a Python<br>
class that can only do work for a specific set of args. I can't think of a<br>
way someone could pass in an evil argstring that could do anything but fail.<br>
<br>
Thanks for your reply, and if you still think it's dangerous please let me<br>
know.<br></blockquote><div><br>What if an attacker passes something other than their own uid across a socket to your inetd-launched process?  EG, what if they pass a 0 (for root) instead of getuid()?<br><br>It might be fine in your case, but in many cases, it's a problem.<br>
<br></div></div>