6

I have restricted user, whose default shell is rbash. Now, I would like to allow the TAB completion feature for this user for his/her home directory, instead of getting this error:

-rbash: /dev/null: restricted: cannot redirect output
-rbash: /dev/null: restricted: cannot redirect output
bash: _upvars: `-a2': invalid number specifier
-rbash: /dev/null: restricted: cannot redirect output
bash: _upvars: `-a0': invalid number specifier

How can I do this for restricted user?

TomiL
  • 671
  • 2
  • 11
  • 25
  • You can't. The restricted mode would not permit you to `cd`; tab completion being enabled would imply that being bypassed. – devnull Jul 19 '13 at 09:34
  • I understand that rbash does not allow `ls` and `cd` to system directories (and probably others as well), but enabling tab completion for selecting files inside restricted user's directory could be legal feature, isn't it? My restricted user has many long-name files in his directory and typing them over and over again is really paint in the ass.. – TomiL Jul 19 '13 at 09:52
  • 1
    `rbash` does not allow you to change to *any* directory, even one in your home directory. However, this does not interfere with tab completion on my system. There may be custom completions installed that cause the observed errors. – chepner Jul 19 '13 at 11:53

3 Answers3

3

Change permission of /dev/null to 666

chmod 777 /dev/null
iman mir
  • 241
  • 1
  • 13
1

Sorry for the late reply, but this is one of the first results in Google for this issue, so you ought to know: Tab completion works ordinarily, even in rbash. I recently encountered this same issue and it turned out to be caused by using su restricteduser instead of su -l restricteduser. The latter command sets the environment and shell variables to be like they would be if you had logged in as restricteduser with an actual login shell. You never mentioned su in the OP, but I suspect this was the issue.

Shan
  • 11
  • 1
1

If you have bash autocomplete installed, a programmable completion script containing redirects may be getting sourced. For example, in CentOS /usr/share/bash-completion/bash_completion may be sourced by /etc/profile.d/bash_completion.sh.

Try adding this to your restricted user's .bashrc to disable programmable completion:

shopt -u progcomp

Basic tab completion will continue to work, and you can optionally attempt to write a replacement programmable completion script that does not invoke redirects.

treble
  • 11
  • 1