LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-02-2008, 02:45 PM   #1
TexasDex
Member
 
Registered: Feb 2003
Location: The Attic. Nowhere near Texas.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133

Rep: Reputation: 15
Question Allow unprivileged users to change runlevel


I have a Gentoo server that I occasionally have users who also need to use it as a desktop. Although it's not terribly short on RAM I don't like to have the X desktop running unless it's really needed, so the initdefault is 3. However I have unprivileged users who need to be able to start X (as well as ALSA services) by changing to runlevel 5.

A simple SUID script would theoretically work, but of course when I make one and try to execute it, the shell doesn't execute it directly, instead executing the interpreter (which has normal permissions) with the suid script as an argument, meaning the suid bit has no effect.

I just need a simple way for users to change to runlevel 5 without giving them root access. I've even tried compiling a tiny SUID C program that runs system("/sbin/init 5"); but it doesn't work and I'm not sure why.

I know I could do this easily with Sudo but I don't want to install that if I don't have to, because the machine already has more junk on it than I'd prefer. Is it possible to do this without it, or should I just suck it up and emerge sudo?
 
Old 03-02-2008, 03:31 PM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Have you tried just booting to runlevel 5 ?

X will be started, and if I understand correctly not usually be used on your system.

If memory is tight, the kernel will send it to swap if noone is using it: No significant performance hit, apart form the kernel saying "I need some more RAM, what isn't being used..... X, so I'll swap it out".
When your user(s) need it, it'll be swapped back in. A few milliseconds. Who cares?

Try allowing the kernel to do what it was designed to do: manage the available reources for you

Do benchmarking if you like.
 
Old 03-02-2008, 03:34 PM   #3
marco18
Member
 
Registered: Jul 2007
Location: Argentina
Distribution: Ubuntu 13.04 , Debian Lenny 5.0.7
Posts: 223

Rep: Reputation: 21
Maybe it isn't necessary to switch runlevel. You could try stopping the X server. Anyway, I don't remember if that also needs priviliges to be run.
 
Old 03-02-2008, 03:38 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,151

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Let then log in at level 3 and do a startx. The only difference is that level 3 is a single user mode, and, if you only have one user at a time running, that's not a limitation.

Oh, you could set up a .bashrc for them so that startx would run automatically as soon as they logged in.
 
Old 03-02-2008, 04:45 PM   #5
moljac024
Member
 
Registered: May 2007
Location: Serbia, Europe
Distribution: Arch Linux
Posts: 54

Rep: Reputation: 15
Or just have two GRUB entries, one with init level 3 and one with init level 5

For example:


Code:
title  Your Linux (runlevel 5)
root   (hd0,0)
kernel /vmlinuz26 root=/dev/sda6 ro 5
initrd /kernel26.img

title  Your Linux (runlevel 3)
root   (hd0,0)
kernel /vmlinuz26 root=/dev/sda6 ro 3
initrd /kernel26.img
 
Old 03-02-2008, 04:49 PM   #6
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 57
Quote:
Originally Posted by PTrenholme View Post
Let then log in at level 3 and do a startx. The only difference is that level 3 is a single user mode, and, if you only have one user at a time running, that's not a limitation.

Oh, you could set up a .bashrc for them so that startx would run automatically as soon as they logged in.
run level 3 is multi-usermode
run level 1 is single user
 
Old 03-02-2008, 06:15 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
sudo is tiny.
It's also the best way to allow non-root user's to do anything you specify. I'd go with that.
 
Old 03-02-2008, 08:23 PM   #8
TexasDex
Member
 
Registered: Feb 2003
Location: The Attic. Nowhere near Texas.
Distribution: Gentoo, Kubuntu, formerly LFS, SuSE, and RedHat
Posts: 133

Original Poster
Rep: Reputation: 15
tredegar has a good point, that it probably doesn't hurt all that much as long as I have enough swap. PTrenholme has a pretty good idea too, I probably should have thought of that, but I think I want a full desktop manager (xdm, in keeping with the minimalism, and I only have IceWM twm, and mwm installed). But chrism01 is right too, that sudo is small so I just stuck that on. I had thought about using grub, a'la moljac024's solution, but decided that I didn't want them rebooting my server whenever they wanted a desktop. So sudo it is. Thank you all!
 
Old 03-03-2008, 08:16 AM   #9
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,151

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by TexasDex View Post
tredegar has a good point, that it probably doesn't hurt all that much as long as I have enough swap. PTrenholme has a pretty good idea too, I probably should have thought of that, but I think I want a full desktop manager (xdm, in keeping with the minimalism, and I only have IceWM twm, and mwm installed). But chrism01 is right too, that sudo is small so I just stuck that on. I had thought about using grub, a'la moljac024's solution, but decided that I didn't want them rebooting my server whenever they wanted a desktop. So sudo it is. Thank you all!
I believe that startx starts the X-server, invokes the display manager (xdm, gdm, kdm, etc.), and then the DM starts the window manager. So having the user log in at level 3 (O.K. AceoSpades19, I misspoke. ) doesn't mean that you won't have a DM running after a startx.

The only "problem" with my proposed solution is that you can only exit the X-windows session to the session from which startx was run, so the user would need to do an exit, reboot or shutdown by hand when they terminated the X session.

I'm fairly familiar with the technique since I often need to use it when I boot Fedora from a USB drive on a non-Linux system, and the device drivers aren't set up properly for the "strange" hardware. So startx sometimes fails -- although, more often than not, it finds a driver in its list that does work -- and I need to "tweak" xorg.conf in the Midnight Commander editor to get it to work. Whilst "tweaking," I save the changed xorg.conf file and then try startx 'till I get it working.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Change RunLevel carlosinfl Debian 6 05-09-2006 07:00 PM
Change runlevel jstephens84 Debian 4 01-02-2006 05:25 PM
Printers for unprivileged users dvishloff Linux - General 2 09-01-2005 12:59 PM
change to unprivileged user without sudo? german Linux - Security 2 01-28-2005 01:32 PM
how do i change my runlevel pguru Linux - Newbie 5 08-13-2004 01:51 PM


All times are GMT -5. The time now is 11:12 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration