LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-04-2005, 11:30 AM   #1
marsques
Member
 
Registered: Jan 2004
Location: Manchester
Distribution: slackware...
Posts: 344

Rep: Reputation: 31
auto starting program as root?


if a that only can be started by root, needs to auto start once the GUI Desktop has finnished loading, how would i go about it?

thanks in advance...
 
Old 09-04-2005, 12:34 PM   #2
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
There are a few ways you can go about this:

1. Use kdesu / gnomesu in .xinitrc / wm startup script
Code:
kdesu command_to_run &
# or
gnomesu command_to_run &
Youll be asked for the root password, and then the command run.

2. Make a sudo entry for it, with no password required.
Example entry in /etc/sudoers:
Code:
username ALL=NOPASSWD: /path/to/command --to --run
And then just put the following in .xinitrc / wm startup file:
Code:
sudo /path/to/command --to --run &
Thats what I can think of now, ythere might be other methids too. Do note that the second is insecure, so dont use this for a root console at startup or similar. The first methid is rather secure, but requires you manual work for typing the password.. (;
 
Old 09-04-2005, 12:42 PM   #3
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
You could also write a script and put it somewhere in /etc/init.d or /etc/rc.d depending on your distro. There is also a file somewhere in /etc/ called rc.local where you can put scripts to start programs when your system boots up.
 
Old 09-04-2005, 12:45 PM   #4
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
Quote:
Originally posted by reddazz
You could also write a script and put it somewhere in /etc/init.d or /etc/rc.d depending on your distro. There is also a file somewhere in /etc/ called rc.local where you can put scripts to start programs when your system boots up.
But those won't help much if your X isnt up yet, dont you agree? (: Even with a "GUI-only" runlevel (4), X will be started too late for the rc:s to have anything to say to apps in it. .xinitrc is the way to go, and meant just for what youre looking for.
 
Old 09-05-2005, 04:16 AM   #5
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
Quote:
Originally posted by Artanicus
But those won't help much if your X isnt up yet, dont you agree? (: Even with a "GUI-only" runlevel (4), X will be started too late for the rc:s to have anything to say to apps in it. .xinitrc is the way to go, and meant just for what youre looking for.
In this instance you maybe right. Another option I didn't think about, is to put the scripts in ~/.kde/Autostart and make sure they run as root (SUID). I think the same can be done in GNOME by tinkering aroung with the "Sessions" setting, though I am not sure where the file is stored if you wanted to edit it directly.

Last edited by reddazz; 09-05-2005 at 04:17 AM.
 
Old 09-05-2005, 05:32 PM   #6
marsques
Member
 
Registered: Jan 2004
Location: Manchester
Distribution: slackware...
Posts: 344

Original Poster
Rep: Reputation: 31
Quote:
Originally posted by Artanicus
There are a few ways you can go about this:

1. Use kdesu / gnomesu in .xinitrc / wm startup script
Code:
kdesu command_to_run &
# or
gnomesu command_to_run &
Youll be asked for the root password, and then the command run.

2. Make a sudo entry for it, with no password required.
Example entry in /etc/sudoers:
Code:
username ALL=NOPASSWD: /path/to/command --to --run
And then just put the following in .xinitrc / wm startup file:
Code:
sudo /path/to/command --to --run &
Thats what I can think of now, ythere might be other methids too. Do note that the second is insecure, so dont use this for a root console at startup or similar. The first methid is rather secure, but requires you manual work for typing the password.. (;
instead of 'username ALL=NOPASSWD' if only the person with username sk53 was allowed to run this particular program without the password, would it be 'username sk53=NOPASSWD' ?

thanks in advance...
 
Old 09-06-2005, 02:40 AM   #7
Artanicus
Member
 
Registered: Jan 2005
Location: Finland
Distribution: Ubuntu, Debian, Gentoo, Slackware
Posts: 827

Rep: Reputation: 31
Quote:
Originally posted by marsques
instead of 'username ALL=NOPASSWD' if only the person with username sk53 was allowed to run this particular program without the password, would it be 'username sk53=NOPASSWD' ?

thanks in advance...
To be totally honest, I have no idea.. I had a few day fight with sudo until I finally found that combination that lets a user run the command with no password, so I havt touched it since.. (; Ypure ofcourse free to experiment. But, since the line gives the user access to only one command, It doesnt matter much whether the lines gives all users password immunity on the command when only one of them gets to even try.

The kdestartup file is also a good one of you happen to use KDE.

However, if the app isnt a GUI app, or doesnt in somehow modify your X session or something, then you can start it up at any time, but since you wanted a way for starup after X is loaded, I presumed that you meant a GUI app (:
 
  


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
auto starting when cd is inserted oingram Linux - Software 1 11-10-2005 02:54 AM
auto starting when cd is inserted oingram Linux - Software 1 11-05-2005 08:12 AM
Auto starting and/or scripting Infernal211283 Linux - Newbie 1 03-22-2005 01:41 PM
cant resize root thru rescue, auto mounts root dir absolutal Linux - Newbie 0 06-18-2003 04:06 PM
auto starting apps.. newbieME Linux - Newbie 4 03-28-2003 09:20 PM


All times are GMT -5. The time now is 07:01 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration