View previous topic :: View next topic |
Author |
Message |
alex.blackbit Advocate
Joined: 26 Jul 2005 Posts: 2397
|
Posted: Wed Jan 09, 2013 10:03 am Post subject: bash path completion with sudo |
|
|
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 |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Wed Jan 09, 2013 3:33 pm Post subject: |
|
|
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 |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6747
|
Posted: Wed Jan 09, 2013 3:54 pm Post subject: |
|
|
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 |
|
|
|