How to: make default debian install run not as root

Tutorials, tips and tricks.

Moderator: moderators

How to: make default debian install run not as root

Postby achoo5000 » Wed Mar 30, 2011 11:15 pm

(note: I used the .deb package to install mine, but I'm sure the same can be done for the other linux packages with the right changes.)

I just recently encountered Subsonic and I totally love it.

After doing the standard installation with the debian package on my Ubuntu server I noticed that the 'java' process that was running the server was launched by the root user. This kind of gave me the heeby-jeebies and I wanted alter the installation to run as another user.

First step is to install everything as normal using the .deb package.

Now make another user (called subsonic in this case):

Code: Select all
sudo useradd subsonic


We now have to give this user ownership of all the subsonic data:

Code: Select all
cd /var/subsonic/
sudo chown -R subsonic:subsonic .


I had a problem where mine would crash when trying to write to /tmp because there was already data there, you could just change the permissions as above, but I just deleted it.

Code: Select all
cd /tmp
sudo rm -rf subsonic/


The last step is to edit the script which is run on startup. It lives at:

Code: Select all
/usr/share/subsonic/subsonic.sh


Open it as root (or using sudo) with your favorite editor. Near the bottom of the script change:

Code: Select all
${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \


to

Code: Select all
sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \


That's it, restart the service

Code: Select all
sudo service subsonic restart


To me I think it should be done this way by default for security reasons. I may have missed some details, but it's working for me at the moment. (Note that if you use the uploading feature you will need to make sure the subsonic user has write permissions wherever you want to upload.)

EDIT:
I guess this has been posted earlier, almost identically.
achoo5000
 
Posts: 29
Joined: Wed Mar 30, 2011 10:47 pm
Location: USA

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 12 guests