Topic: [Solved] Launch as Root @ startup

Is there any way to launch a program at startup as root?

Last edited by ZeroTruths (2009-01-17 04:44:39)

All in an effort to learn...
Delves deeper into code...

Re: [Solved] Launch as Root @ startup

What type of program is it that you want to run as root? There shouldn't be a need to run anything as root unless it needs root privileges for a specific purpose (like synaptic or gedit to edit a system config file). Regularly running ordinary user programs as root is bad security practice and while it's possible I would strongly recommend against it.

A Creative Commoner | My images at Google+ | A Waldorf Review

Silence is sometimes the best answer - Dalai Lama.

Re: [Solved] Launch as Root @ startup

omns wrote:

Regularly running ordinary user programs as root is bad security practice and while it's possible I would strongly recommend against it.

I couldn't agree more, and if there were any other way to run this program, then I would.

What I need to run as root is apt-get --simulate update. Basically, what I'm doing is making a script for conky to tell me if there are any updates for the system (Similar to Arch Linux' pacman -Syup), but in order for it to give me a proper reading, I need to run it as root, and I don't want to have to run gksudo on startup.

All in an effort to learn...
Delves deeper into code...

Re: [Solved] Launch as Root @ startup

Hmm that's an interesting one. First, my apologies for being a little forthright in my reply. Some people just don't get the purpose of the root account. I'm glad you do smile

I remember some years ago an update and installation program called Automatix that used the '--force-yes' flag in its script and it caused all sorts of commotion and agro in the Ubuntu/Debian world. This sort of thing is a possibility I suppose but I have no idea how to implement it though.

A Creative Commoner | My images at Google+ | A Waldorf Review

Silence is sometimes the best answer - Dalai Lama.

Re: [Solved] Launch as Root @ startup

ZeroTruths wrote:
omns wrote:

Regularly running ordinary user programs as root is bad security practice and while it's possible I would strongly recommend against it.

I couldn't agree more, and if there were any other way to run this program, then I would.

What I need to run as root is apt-get --simulate update. Basically, what I'm doing is making a script for conky to tell me if there are any updates for the system (Similar to Arch Linux' pacman -Syup), but in order for it to give me a proper reading, I need to run it as root, and I don't want to have to run gksudo on startup.

Ok, you can add a line to sudo allowing the group "users" to run apt-get --simulate and define it as a "NOPASSWD" right, then you'll be able to use sudo in the command line and your users will be unable to abuse it smile

Add this line to /etc/sudoers by using the command visudo

%users  ALL = (root) NOPASSWD: /usr/bin/apt-get --simulate *

That way, the users can sudo without a password, but all they can run is apt-get --simulate and its sub commands which are harmless. If you want to restrict it down even further:

%users  ALL = (root) NOPASSWD: /usr/bin/apt-get --simulate upgrade

Then they can only do a simulated upgrade.

Last edited by Nik_Doof (2009-01-09 08:51:08)

Re: [Solved] Launch as Root @ startup

I tried to put these two lines in sudoers but it doesn't work hmm

%users  ALL = (root) NOPASSWD: /usr/bin/apt-get --simulate upgrade
%users  ALL = (root) NOPASSWD: /usr/bin/apt-get update

Re: [Solved] Launch as Root @ startup

It seems I found the solution. I edited the sudoers like this:

There is a line: "# Cmnd alias specification", under I wrote:
Cmnd_Alias UPDATE=/usr/bin/apt-get update, /usr/bin/apt-get -s upgrade

And at the end of file I added the lines:
# For conky reason, authorization to update and simulate upgrade
# without password
%admin ALL =(ALL) NOPASSWD: UPDATE