lower

Core libraries and systems
Post Reply
Message
Author
User avatar
droope
Posts: 801
Joined: Fri 01 Aug 2008, 00:17
Location: Uruguay, Mercedes

lower

#1 Post by droope »

Hi folks!

Some apps are just not safe to be run as root - particularly my browser and my server - so I've decided that i don't want them to. In order to do so comfortably, I've created a script that lowers the privileges ( an anti-sudo, perhaps ) :D

So, here it is:

Code: Select all

#!/bin/bash
if [[ -n $@ ]]; then
        # allows gtk to run
        xhost local:lower@ > /dev/null
        sudo -H -u lower $@
else
        su lower
fi
In order for it to work, you need sudo, which I attach below. Created using this guy's code ( thanks! ). Also, you need to create the "lower" user, which can be done with

Code: Select all

adduser lower
Usage:

Firstly, you need to create a text file in "/usr/bin" called "lower". Insert the first block of code of this post inside that file, and give it execution rights ( tip: `chmod +x /usr/bin/lower`)

After that, you can use it like this

Code: Select all

#lower firefox
or

Code: Select all

#lower
#firefox
( you can use "exit" command to become root again )
What seems hard is actually easy, while what looks like impossible is in fact hard.

“Hard things take time to do. Impossible things take a little longer.â€￾ –Percy Cerutty

[url=http://droope.wordpress.com/]Mi blog[/url] (Spanish)

Post Reply