LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   auto starting program as root? (https://www.linuxquestions.org/questions/slackware-14/auto-starting-program-as-root-360086/)

marsques 09-04-2005 10:30 AM

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...

Artanicus 09-04-2005 11:34 AM

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.. (;

reddazz 09-04-2005 11:42 AM

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.

Artanicus 09-04-2005 11:45 AM

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.

reddazz 09-05-2005 03:16 AM

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.

marsques 09-05-2005 04:32 PM

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...

Artanicus 09-06-2005 01:40 AM

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 (:


All times are GMT -5. The time now is 04:25 PM.