| View previous topic :: View next topic |
| Author |
Message |
alex.blackbit Advocate

Joined: 26 Jul 2005 Posts: 2392
|
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 Advocate

Joined: 01 Jul 2004 Posts: 3001 Location: 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). _________________ Core-i7-2700K@4.1GHz/8GB RAM/180GB SSD/Intel HD3000 graphics
What the heck am I advocating? |
|
| Back to top |
|
 |
mv Advocate


Joined: 20 Apr 2005 Posts: 3154
|
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 |
|
 |
|