You are not logged in.

#1 2007-11-13 08:18:43

dumas
Member
From: Sydney
Registered: 2007-09-01
Posts: 103

A simple "sudo" script

Hi, I wrote a simple "sudo" script for people who prefer to use su rather than sudo.

#!/bin/bash
while [ -n "$1" ]
do
        command="${command} $1"
        shift
done
su -c "$command"

Usage:
put it in /usr/sbin, then for example, do
sudo pacman -Sy
Password:
enter root password

Advantages:
for those who don't like sudo, this sudo script is convenient for one line commands
simple bash completion

Hope you find it useful

Offline

#2 2007-11-13 12:00:46

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: A simple "sudo" script

Couldn't you just do:

#!/bin/bash

su -c "$@"

Offline

#3 2007-11-13 12:14:15

dumas
Member
From: Sydney
Registered: 2007-09-01
Posts: 103

Re: A simple "sudo" script

Ah, yes. Forgot the $@.
But with this simple script I don't see any reason to use the original sudo anymore. The time stamp is convenient but is also a potential security problem.

Offline

#4 2007-11-13 12:17:29

mucknert
Member
From: Berlin // Germany
Registered: 2006-06-27
Posts: 510

Re: A simple "sudo" script

Uh. sudo allows a much finer selection of rights. You can say what user or group is allowed to execute with its own password (or no password at all) instead of the root pw. That's a lot more than your script does and those are good reasons, too. Read up on sudo one day. You will be suprised.

Last edited by mucknert (2007-11-13 12:25:31)


Todays mistakes are tomorrows catastrophes.

Offline

#5 2007-11-13 12:23:16

Xilon
Member
Registered: 2007-01-01
Posts: 243

Re: A simple "sudo" script

Cerebral wrote:

Couldn't you just do:

#!/bin/bash

su -c "$@"

Couldn't you just do:

alias sudo='su -c'

And what mucknert said...

Offline

#6 2007-11-13 13:25:08

dumas
Member
From: Sydney
Registered: 2007-09-01
Posts: 103

Re: A simple "sudo" script

Xilon wrote:

Couldn't you just do:
alias sudo='su -c'

That would require you to manually put ' ' around your command, and miss bash completion.

mucknert wrote:

Uh. sudo allows a much finer selection of rights. You can say what user or group is allowed to execute with its own password (or no password at all) instead of the root pw. That's a lot more than your script does and those are good reasons, too. Read up on sudo one day. You will be suprised.

Thanks for your suggestion, I just had a quick read through sudo and sudoers. This is some stuff I found:

The time stamp issue was never a big one, and you can configure the time or disable it. I find sudo -k useful too.

I thought sudo might add security risk if the user password was compromised, but you can configure sudo to ask for the root password. However, this would defeat the purpose for those who disable root.

I also have a questions: if you want to do access control, why would you prefer sudo over simple file permissions? Or is sudo primarily used as a finer access control scheme?

Again, thanks for your advice, I really appreciate it. Please point out anything wrong with my questions. The manual was pretty long, so I'm bound to miss something.

Offline

#7 2007-11-13 13:29:01

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: A simple "sudo" script

I'd rather specify the binaries a user can have root access to than to go change permissions on all those binaries, over and over with each upgrade.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

Board footer

Powered by FluxBB