You are not logged in.

#1 2010-06-22 23:35:28

kportertx
Member
Registered: 2010-06-22
Posts: 12

Auto sudo

currently if you type $pacman -S package it will spit back error: you cannot perform this operation unless you are root.

Does anyone know a way that I can catch permission errors and instead of giving the error just prompt for root password or something similar?

Offline

#2 2010-06-22 23:44:39

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,392
Website

Re: Auto sudo

Moved topic....

Look into setting up sudo and making an alias on the wiki

Offline

#3 2010-06-23 07:01:50

kportertx
Member
Registered: 2010-06-22
Posts: 12

Re: Auto sudo

Yea... one could do that but that would involve a lot of aliases for what I was asking.  Perhaps I could clarify a bit more by another example.  Say I run $touch /sbin/somefile again I get a permission error...  How would one change this behavior to instead prompt your for the a password or even username/password.  Any ideas?

Offline

#4 2010-06-23 07:09:55

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: Auto sudo

alias s='sudo'
alias p='sudo pacman'

p -S package
s touch "some dirty file"
s less /var/log/auth.log

Sudo is then just two-characters away from being automatic.  wink

Last edited by Wintervenom (2010-06-23 07:15:47)

Offline

#5 2010-06-23 07:22:31

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: Auto sudo

I use this function in my .bashrc:

pacman() {
    if [[ "$1" =~ ^-S[cuy]|^-S$|^-R|^-U ]]
    then
        sudo pacman-color $@
    else
        pacman-color $@
    fi
}

Note that this works for me though I'm sure the regex needs tweaking a bit to handle all arguments correctly.

Offline

#6 2010-06-23 12:29:23

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Auto sudo

Yes... Login and work day-to-day as root.

Permissions and sudo are there for a reason, and coming up with some system to automatically override them makes them completely redundant.

Offline

#7 2010-06-23 13:38:22

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,394

Re: Auto sudo

He's just asking for an automated way of asking password.
How would it make 'permissions and sudo' 'completely redundant' is far from my understanding.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#8 2010-06-23 17:49:20

Berticus
Member
Registered: 2008-06-11
Posts: 731

Re: Auto sudo

I personally wouldn't recommend catching it and automatically asking for a password, but if you really don't want to retype everything, you could always do:

$ sudo !!

There's a lot you can do with bang commands, so check them out.

Offline

#9 2010-06-23 20:09:59

loafer
Member
From: the pub
Registered: 2009-04-14
Posts: 1,772

Re: Auto sudo

You could also look at using super as an alternative to sudo for certain tasks.


All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.

Offline

#10 2010-06-23 22:03:18

lastchancetosee
Member
From: Berlin
Registered: 2009-02-19
Posts: 131

Re: Auto sudo

You can use Yaourt instead of pacman. You can use it with the same syntax as pacman, but it will ask for a password if needed. It also has tons of other nice features, including but not limited to being able to install from AUR.

You can get it from AUR or from the archlinuxfr repo. Just add

[archlinuxfr]
Server = http://repo.archlinux.fr/x86_64

or

[archlinuxfr]
Server = http://repo.archlinux.fr/i868

depending on your architecture, to /etc/pacman.conf, then you can install it from that repo.

Last edited by lastchancetosee (2010-06-23 22:06:20)


My ship don't crash! She crashes, you crashed her!

Offline

#11 2010-06-24 00:45:06

schen
Member
Registered: 2009-06-06
Posts: 468

Re: Auto sudo

I don't suggest using yaourt, because it's a lot slower than normal pacman and (I think) isn't being actively developed.

Offline

#12 2010-06-24 00:50:30

TigTex
Member
From: Portugal
Registered: 2008-06-19
Posts: 301

Re: Auto sudo

I don't confirm that. Right now there are new yaourt packages and the performance improved A LOT. Give it a try.


.::. TigTex @ Portugal .::.

Offline

#13 2010-06-24 23:10:49

kportertx
Member
Registered: 2010-06-22
Posts: 12

Re: Auto sudo

Be nice to able to catch the permission error and then sudo !! automatically.  Eh o well it is not a big deal.  Just hate retyping smile.  Did not expect so many people to get their panties in a wad though.  Wonder if they even read the question... or if they were just trying to troll.

Offline

#14 2010-06-24 23:30:48

milomouse
Member
Registered: 2009-03-24
Posts: 940
Website

Re: Auto sudo

correct me if i'm wrong but the shell gives you your error messages depending on what the program/action returns/exits with. if you wanted to catch these error reports you'd have to be monitoring for them constantly from within a shell function (perhaps ran before every command is executed from that shell) and have it respond according to the error (in your case, maybe just watch for permission errors).. i guess read the manpage for your shell to give you ideas on the errors returned to give you a better idea on how you want to handle it, because it sounds like a lot of work just to reduce the amount of time typing your password. i dunno hmm i'm probably all wrong

Offline

#15 2010-06-25 00:04:08

andresp
Member
Registered: 2010-05-29
Posts: 62

Re: Auto sudo

@op

I recommend timestamp_timeout = 0

Offline

Board footer

Powered by FluxBB