[SOLVED]running smartfox service as non root user

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

[SOLVED]running smartfox service as non root user

Postby levancho » 15 Jan 2012, 20:50

hi,

I tried to search the forum for this issue but it seems there is no talink about it.

I have a glassfish server currently runing as a regular user, I am ussing chkconfig and glassfis is working just file.

I have reused my file for smartfox as well, this way:

Code: Select all

#! /bin/sh
# chkconfig: 2345 99 01
# description: Smartfox  Server

SF_USER=givi
GF_HOME=/opt/servers/SFS2X/SFS2X
ASADMIN=$SF_HOME/sfs2x-service
SU="su --login  $SF_USER --command  "

case "$1" in

status)
    $SU "$ASADMIN status"
    ;;
start)
    echo "starting ..."
    $SU "$ASADMIN start "
    ;;
stop)
    $SU "$ASADMIN stop"
    ;;
restart)
    $SU "$ASADMIN restart"
    ;;
\*)
    echo "usage: $0 (start|stop|restart|status)"
esac
'
'
all works fine but when I check ps aux it still says that smartfox is running as root, so it must be something inside sfs2x-service that changes back to root?

is there a way to get smartfox running under non root user, this is kind of a security issue for us.

I had a type in SU command .

it works like a charm now
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 16 Jan 2012, 09:00

Thanks for posting.
I think this was asked by some other users not too long ago. I will add a sticky for other Linux users who prefer to avoid running the service as root.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
jrimmer
Posts: 23
Joined: 03 Oct 2010, 16:44

Postby jrimmer » 16 Jan 2012, 14:24

I run SFS as a non-privileged (game/game) user. While I start the server directly instead of using the provided shell script I don't recall having issues with process ownership. It was more an issue of getting a pid so that Monit can watch it.

This is my init.d script on Ubuntu, note that it contains other adjustments such as memory.

Code: Select all

#!/bin/bash

case $1 in
  start)
    start-stop-daemon --start --background --oknodo --user game --group game --pidfile /var/run/sfs.pid --make-pidfile --startas /home/game/sfs/jre/bin/java --chuid game --chdir /home/game/sfs/SFS2X -- -Xms1024M -Xmx1024M -cp ./:lib/*:lib/Jetty/*:extensions/__lib__/* -Dfile.encoding=UTF-8 com.smartfoxserver.v2.Main $1 $2 >> /home/game/sfs/SFS2X/logs/smartfox.log
    ;;
 
  stop) 
    start-stop-daemon --stop --pidfile /var/run/sfs.pid
    ;;
  *) 
 
  echo "usage: sfs2x {start|stop}" ;;
esac

exit 0
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 16 Jan 2012, 14:35

The problem raised by levancho is related to auto-starting the SFS service at boot-time. Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
jrimmer
Posts: 23
Joined: 03 Oct 2010, 16:44

Postby jrimmer » 16 Jan 2012, 15:00

Lapo wrote:The problem raised by levancho is related to auto-starting the SFS service at boot-time. Cheers

Once the start script's set correctly I would think that's a simple matter of upstart, chkconfig, sysv-rc-conf monkeying.

Regardless, glad to hear the issue's successfully resolved.
User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

Postby levancho » 17 Jan 2012, 13:39

now the only thing worries me a little is the how bluebox will work since smartfox is run as non root uer so we cat bind port 80 to jetty, but I thnk I have a solution, please advice if that will work,

I will front jetty port 9090 (ii changed it ) by apaches mo_proxy so all request for bluebox will be routed to smartfoxes jetty on port 9090
that should work right?
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Jan 2012, 15:01

Yes, it should work
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 72 guests