openSUSE Forums > Install/Boot/Login » Init Script With Different user

Go Back   openSUSE Forums > Install/Boot/Login
Forums FAQ Members List Search Today's Posts Mark Forums Read


Install/Boot/Login Questions about installation, login, boot issues, partitioning, file systems, software that runs at boot (GRUB, LILO, boot scripts)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-Nov-2009, 21:54
smpoole7's Avatar
Parent Penguin
 
Join Date: Oct 2008
Location: Birmingham. AL
Posts: 580
smpoole7 is on a distinguished reputation roadsmpoole7 is on a distinguished reputation road
Default Init Script With Different user

This is one of those things I probably ought to know, but I've never needed it before now. I want to start VirtualBox with an init script in /etc/init.d. That part's easy (I've already got it). But I don't want it to run as root, I want it to run as a less-privileged user. How do I do that? Put an "su" in the script? suid the executable?

Inquiring minds want to know.
Reply With Quote
  #2 (permalink)  
Old 07-Nov-2009, 22:27
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,232
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Init Script With Different user

You use the -u option of startproc inside your init script to specify the user you want to run as. man startproc.

You can see an example using Debian's start-stop-daemon, which is similar in functionality to startproc, here:

Running a production IPCop in a Virtualbox VM
Reply With Quote
  #3 (permalink)  
Old 07-Nov-2009, 22:30
malcolmlewis's Avatar
Global Moderator
 
Join Date: Jun 2008
Location: Podunk
Posts: 4,711
malcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputationmalcolmlewis has great reputation
Default Re: Init Script With Different user

Quote:
Originally Posted by smpoole7
This is one of those things I probably ought to know, but I've never
needed it before now. I want to start VirtualBox with an init script in
/etc/init.d. That part's easy (I've already got it). But I don't want it
to run as root, I want it to run as a less-privileged user. How do I do
that? Put an "su" in the script? suid the executable?

Inquiring minds want to know.
Hi
Yes, that would be the way su - <some_user> but one needs to ask what
your ultimate goal is, perhaps a bit more detail

For example do you just want a vm to start into say a windows vm
running full screen? Do you want to run a server applications that
never use a GUI, use a different display, Xvfb etc.

--
Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.2 (i586) Kernel 2.6.31.5-0.1-desktop
up 3:46, 2 users, load average: 0.38, 0.25, 0.19
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

Reply With Quote
  #4 (permalink)  
Old 08-Nov-2009, 11:21
smpoole7's Avatar
Parent Penguin
 
Join Date: Oct 2008
Location: Birmingham. AL
Posts: 580
smpoole7 is on a distinguished reputation roadsmpoole7 is on a distinguished reputation road
Default Re: Init Script With Different user

Thanks, Ken, and sheesh. I had forgotten about startproc, even though I've used it in the past with scripts.


Malcom,

I have become a VirtualBox lover and mega-user. We're running our mail server in it on one machine, and on the one in question here, I'm going to run both an FTP server and a firewall on separate IP addresses. All three "machines" -- the host and the two guests -- will be minimal, text-only installs. Just as a matter of principle, I don't like running a VM as root. I feel like I get another layer of security that way.

The PC in question has several NICs, so it's ideal. I can set up two to bridge straight into and out of the firewall and a third bridges straight into the FTP server. Best of all, I'm using OpenSUSE 11.1, with which I'm totally comfortable, but when it comes time to upgrade, I'll just down the VM for about an hour and install the new version. It's slicker'n hot oil on a doorknob.

Best of best of all, I can do the upgrades remotely. (I just did a net install of 11.1 in one of the VMs last night; worked like a hose.)

-- Stephen
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2