Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
bash path completion with sudo
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
alex.blackbit
Advocate
Advocate


Joined: 26 Jul 2005
Posts: 2397

PostPosted: Wed Jan 09, 2013 10:03 am    Post subject: bash path completion with sudo Reply with quote

Hi,

I only open a root shell in case of an emergency.
Normally I do admin stuff with sudo.
Unfortunately tab completion for paths does not work with sudo when accessing directories that the normal user does not have 'r' permission for.
Code:
$ sudo tailf /var/log/apache2/<TAB>

It is obvious that this cannot work, because the completion is run by the shell which is running under my normal user account.
Is there some hack to make this work?

Any ideas appreciated.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Wed Jan 09, 2013 3:33 pm    Post subject: Reply with quote

Of course it's a security hole if it did work.

But if you want to punch a hole, an idea is to make your user be a part of that directory's group and give read permissions that group (and none for others).
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Wed Jan 09, 2013 3:54 pm    Post subject: Reply with quote

A possibility could be to let the sudo completion call sudo for completion. Whether this is useful depends on your sudo configuration (e.g. can your user get full root access at all or only for special commands?). If you need it only for particular commands (which probably is the case), I would handcraft a special solution for that case(s). Overriding the default sudo completion (and calling the original as a fallback if the command line does not match your special case(s)) is trivial in zsh, probably not so simple in bash. (Oh, did I forget to say as usual that I recommend zsh for interactive usage?)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum