LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-19-2011, 05:39 PM   #1
jsmith6
Member
 
Registered: Feb 2006
Distribution: Slackware 13.1 / 13.37
Posts: 91

Rep: Reputation: 16
how can I securely start non-root services?


I run Slackware 13.1 on a small Pentium 4 box that runs a torrent client, game server, and a few more Internet-related scripts.

I see no point running these stuff with root priviledges, so I have this line in rc.local:

Code:
su user -c "/home/user/services/start-all.sh"
How secure is that command, su user -c? And what would be the right way to go with it?
 
Old 06-19-2011, 08:20 PM   #2
psionl0
Member
 
Registered: Jan 2011
Distribution: slackware_64 14.1
Posts: 722
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
It depends on what "start-all.sh" starts as to whether root privileges are needed. You can "chmod" start-all.sh itself so that you don't need root privileges to use it.

If any programs in start-all.sh need root privileges to run then I would have thought that "sudo" would be the better way to go. You can set up the sudoers file (run "visudo") so that only those commands in start-all.sh can be run by user.
 
Old 06-20-2011, 10:03 AM   #3
jsmith6
Member
 
Registered: Feb 2006
Distribution: Slackware 13.1 / 13.37
Posts: 91

Original Poster
Rep: Reputation: 16
Quote:
It depends on what "start-all.sh" starts as to whether root privileges are needed.
None of the programs inside start-all.sh need root priviledges.

Quote:
You can "chmod" start-all.sh itself so that you don't need root privileges to use it.
It's already executable, see how I am starting the script from rc.local. If it wasn't, I would need to sh /path/to/start-all.sh. But even if it wasn't, how would a chmod change the fact that a program needs root priviledges to run? You have me confused here.

Perhaps the mention of start-all.sh complicated things. Imagine that I only have one service that I want to run as non-root, so I use this line in rc.local:

Code:
su user -c "transmission-daemon"
Is this the prudent and right way to start a non-root process on boot?
 
Old 06-20-2011, 01:55 PM   #4
qweasd
Member
 
Registered: May 2010
Posts: 621

Rep: Reputation: Disabled
Post

I don't see anything wrong with what you are doing. That's the way I would do it:
Code:
su -l -c "/home/user/services/start-all.sh" user
which is the same, except that -l emulates a direct login. In Slackware 13.37,
I would also check /etc/group to make sure that user doesn't get extra permissions.
As an interactive user, I am in floppy, audio, video, cdrom, plugdev, power, and
netdev. A transmission-daemon would not need any of them, I believe. I am not even sure
I need them.
 
Old 06-20-2011, 04:58 PM   #5
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by psionl0 View Post
It depends on what "start-all.sh" starts as to whether root privileges are needed. You can "chmod" start-all.sh itself so that you don't need root privileges to use it.
If you're talking about setting it suid then that wouldn't work on a shell script.

Quote:
Originally Posted by psionl0 View Post
If any programs in start-all.sh need root privileges to run then I would have thought that "sudo" would be the better way to go. You can set up the sudoers file (run "visudo") so that only those commands in start-all.sh can be run by user.
That's just the point... the OP is wanting to run programs as a non-root user without any root (or any extra) privs.

Quote:
Originally Posted by jsmith6 View Post
Is this the prudent and right way to start a non-root process on boot?
Yes although in addition to what queasd said...

I'm not sure "-l" will work in all cases but if you make sure that your user has only the permissions needed you can use.

Code:
su - user -c "/home/user/services/start-all.sh"
 
Old 06-20-2011, 05:22 PM   #6
piratesmack
Member
 
Registered: Feb 2009
Distribution: Slackware, Arch
Posts: 519

Rep: Reputation: 142Reputation: 142
Quote:
Originally Posted by mRgOBLIN View Post
I'm not sure "-l" will work in all cases but if you make sure that your user has only the permissions needed you can use.

Code:
su - user -c "/home/user/services/start-all.sh"
I didn't test if that command works or not, but the su man page says that if '-' is used it must be the last option.
Code:
su user -c "/home/user/services/start-all.sh" -
Quote:
$ man su
...
When - is used, it must be specified as the last su option. The other forms (-l and --login) do not have this restriction.
edit:
Hmm... it seems to work even when it's not the last option

Last edited by piratesmack; 06-20-2011 at 05:30 PM.
 
Old 06-22-2011, 06:23 AM   #7
jsmith6
Member
 
Registered: Feb 2006
Distribution: Slackware 13.1 / 13.37
Posts: 91

Original Poster
Rep: Reputation: 16
Is it more secure using the -l option?
 
Old 06-22-2011, 07:02 AM   #8
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by jsmith6 View Post
Is it more secure using the -l option?
It's the same thing.

Just that -l may or may not work on some machines.... depends on su version and compile time options.
 
Old 06-22-2011, 10:11 AM   #9
jsmith6
Member
 
Registered: Feb 2006
Distribution: Slackware 13.1 / 13.37
Posts: 91

Original Poster
Rep: Reputation: 16
Excellent!

Thanks guys!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] "/etc/init.d/apache2" start VS "apache2ctl start" with passenger module (ruby/rails) arond Linux - Server 1 12-13-2010 10:56 AM
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
LXer: Using "shred" to Securely Delete Files LXer Syndicated Linux News 0 02-27-2008 06:50 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Named doesn't start : "root:4: no current owner name" tigernux Linux - Server 2 12-20-2006 08:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration