Recommended setting for using Apache mod_mono with a different user

Posted by Korrupzion on Server Fault See other posts from Server Fault or by Korrupzion
Published on 2010-12-30T09:06:24Z Indexed on 2010/12/30 9:56 UTC
Read the original article Hit count: 593

Filed under:
|
|
|
|

Hello,

I'm setting up an ASP.net script in my linux machine using mod_mono.

The script spawn procceses of a bin that belongs to another user, but the proccess is spawned by www-data because apache runs with that user, and i need to spawn the proccess with the user that owns the file.

I tried setuid bit but it doesn't make any effect. I discovered that if I kill mod-mono-server2.exe and I run it with the user that I need, everything works right, but I want to know the proper way to do this, because after a while apache runs mod-mono-server2.exe as www-data again.

Mono-Project webpage says:

How can I Run mod-mono-server as a different user?

Due to apache's design, there is no straightforward way to start processes from inside of a apache child as a specific user. Apache's SuExec wrapper is targeting CGI and is useless for modules.

Mod_mono provides the MonoStartXSP option. You can set it to "False" and start mod-mono-server manually as the specific user. Some tinkering with the Unix socket's permissions might be necessary, unless MonoListenPort is used, which turns on TCP between mod_mono and mod-mono-server.

Another (very risky) way: use a setuid 'root' wrapper for the mono executable, inspired by the sources of Apache's SuExec.

I want to know how to use the setuid wrapper, because I tried adding the setuid to 'mono' bin and changing the owner to the user that I want, but that made mono crash. Or maybe a way to keep running mono-mod-server2.exe separated from apache without being closed (anyone has a script?)

My environment: Debian Lenny 2.6.26-2-amd64 Mono 1.9.1 mod_mono from debian repository Dedicated server (root access and stuff) Using apache vhosts -I use mono for only that script

Thanks!

© Server Fault or respective owner

Related posts about linux

Related posts about apache