[patch] Change user after binding port X (as root)

1 view
Skip to first unread message

Nils

unread,
Oct 31, 2009, 3:27:32 PM10/31/09
to Happs Mailinglist
Hi,

I wrote this little patch which adds an entry to the Conf data. You can
now tell happstack what user it should use after binding port 80 as root
for example.


Patch is attached,

Nils / McManiaC

username.patch

stepcut

unread,
Nov 1, 2009, 9:40:46 AM11/1/09
to HAppS
I typically call startSystemState before simpleHTTP, so that state
system is initialize before any requests are being handled. However,
if the state system starts running as root, and the switches to
another user, won't there be file ownership issues with the state
files?

- jeremy

Nils

unread,
Nov 1, 2009, 7:29:00 PM11/1/09
to ha...@googlegroups.com

Hmm, good point. But I think as long as you dont save the state to
harddrive before binding port 80 this souldn't be an issue since the
whole application will change the userID and not just the HTTP-thread.

Not quite sure tho, since I didn't dive that deep into happstacks source
code. :) At least I'm running this patch on my local machine and didn't
experience any issues so far (which is no "proof" of course).

stepcut

unread,
Nov 2, 2009, 8:26:41 AM11/2/09
to HAppS
I think that in general, there are a lot of things you might want to
do after dropping privileges but before processing incoming requests.
That is true of some of my applications.

It seems like maybe we want to split the port binding stuff out and
then pass the handle into simpleHTTP later? Something like this
perhaps?

main =
do h <- bind (port conf)
doOtherStuffAsRoot
changeUser (user conf)
doOtherStuffAsUser
tid <- forkIO $ simpleHTTPAlt h conf impl -- finally start taking
incoming requests
...


- jeremy

Nils

unread,
Nov 2, 2009, 8:59:31 AM11/2/09
to ha...@googlegroups.com
On Mon, Nov 02, 2009 at 05:26:41AM -0800, stepcut wrote:
> It seems like maybe we want to split the port binding stuff out and
> then pass the handle into simpleHTTP later? Something like this
> perhaps?

Jup, sounds great. I've been thinking about that too.

stepcut

unread,
Nov 9, 2009, 1:32:56 PM11/9/09
to HAppS

Nils

unread,
Nov 10, 2009, 7:58:37 PM11/10/09
to ha...@googlegroups.com
Hi,

I wrote the little patch we talked about before. Hope you like it. :)


Nils / McManiaC

On Mon, Nov 02, 2009 at 05:26:41AM -0800, stepcut wrote:
>

simpleHTTPWithSocket.patch
Reply all
Reply to author
Forward
0 new messages