'alias' + sudo
Mel Flynn
mel.flynn+fbsd.questions at mailing.thruhere.net
Fri Sep 4 01:58:30 UTC 2009
On Friday 04 September 2009 02:10:36 Jerry wrote:
> On Fri, 4 Sep 2009 01:34:05 +0200
>
> Mel Flynn <mel.flynn+fbsd.questions at mailing.thruhere.net> wrote:
> > alias spico='/usr/local/bin/sudo pico -m' and be done with it.
>
> That is what I am currently doing; however,there are other commands
> that I want to use that are not available when used via sudo without
> modifying the alias. I did not realize that sudo had such a limitation.
It doesn't. alias has the limitation. As far as alias is concerned, a command
is the first thing on the command line, and for good reason, as you don't want
it to look further along the command line and attempt to expand everything.
So the shell only changes the command that is really run, when the first word
matches an alias. Sudo or any app for that matter, never knew it was run
through an alias.
However.....reading through the bash manpage:
If the
last character of the alias value is a blank, then the next command
word following the alias is also checked for alias expansion.
So.....:
$ alias sudo='/usr/local/bin/sudo '
$ alias pico='vim --version'
$ sudo pico
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 21 2009 13:22:46)
Included patches: 1-6, 8-35, 37-48, 50-70, 73, 75-87, 90-92, 94-100, 102-137,
139-149, 151-171, 173-190, 192-193, 195-203, 206-209
However....be aware of the consequences. If someone compromises your account,
then setting:
alias ls='/tmp/mkroot'
and you running:
sudo ls
He just got root.
--
Mel
More information about the freebsd-questions
mailing list