Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Running java as UID != 0 from init
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
count
Apprentice
Apprentice


Joined: 28 May 2002
Posts: 242
Location: Dalton, MA

PostPosted: Sat Dec 14, 2002 2:41 pm    Post subject: Running java as UID != 0 from init Reply with quote

An Open Source project of mine (LlamaChat, http://www.42llamas.com/LlamaChat/ ) has a server portion and has been in an init script running as root. I woud like this to run as a different user for security reasaons.

/etc/init.d/llamachat
Code:
#!/sbin/runscript

depend() {
        need net
}

start() {
        ebegin "Starting LlamaChat Server"
        /home/httpd/htdocs/LlamaChat/server/startServer.sh &
        echo $! > /var/run/llamachat.pid
        eend $? "Failed to start LlamaChat Server"
}

stop() {
        ebegin "Stopping LlamaChat Server"
        start-stop-daemon --stop --quiet --pidfile /var/run/llamachat.pid
        eend $? "Failed to stop LlamaChat Server"
}

startServer.sh
Code:
#!/bin/bash
cd /home/httpd/htdocs/LlamaChat/server/
exec java -server -jar LlamaChatServer.jar


Ay help would be greatly appreciated :)
_________________
- Joseph Monti
_________________
This message is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more info visit http://joemonti.org/
Back to top
View user's profile Send private message
ghost_o
Tux's lil' helper
Tux's lil' helper


Joined: 10 Jul 2002
Posts: 119

PostPosted: Sat Dec 14, 2002 3:05 pm    Post subject: Reply with quote

You can
Code:

su <user> -c "command"


in the init script to get that effect

-G
Back to top
View user's profile Send private message
count
Apprentice
Apprentice


Joined: 28 May 2002
Posts: 242
Location: Dalton, MA

PostPosted: Sat Dec 14, 2002 9:46 pm    Post subject: Reply with quote

Is there any other way?

That wont work with my apache user because there is no shell, which is the account i would prefer to use. I tried w/ a user account, but ran into problems of not having java in the path.
_________________
- Joseph Monti
_________________
This message is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more info visit http://joemonti.org/
Back to top
View user's profile Send private message
count
Apprentice
Apprentice


Joined: 28 May 2002
Posts: 242
Location: Dalton, MA

PostPosted: Sat Dec 14, 2002 10:45 pm    Post subject: Reply with quote

Thanks ghost_o

I got it working with a regular user. Now I dont have to stay up all night worrying about my possibly insecure server running as root being compremised :)
_________________
- Joseph Monti
_________________
This message is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more info visit http://joemonti.org/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum