简体   繁体   English

允许在 rbash 中完成制表符

[英]Allow tab completion in rbash

I have restricted user, whose default shell is rbash .我有限制用户,其默认 shell 是rbash Now, I would like to allow the TAB completion feature for this user for his/her home directory, instead of getting this error:现在,我想为他/她的主目录允许此用户的TAB 完成功能,而不是收到此错误:

-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 ?如何为受限用户执行此操作?

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. 抱歉,回复晚了,但这是Google在此问题上的首批结果之一,因此您应该知道:制表符补全通常可以正常工作,即使在rbash中也是如此。 I recently encountered this same issue and it turned out to be caused by using su restricteduser instead of su -l restricteduser . 最近,我遇到了同样的问题,它是由使用su restricteduser而不是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. 后面的命令将环境变量和shell变量设置为与使用实际登录shell以受限用户身份登录时的环境和shell变量相同。 You never mentioned su in the OP, but I suspect this was the issue. 您在OP中从未提到过su ,但是我怀疑这是问题所在。

将/ dev / null的权限更改为666

chmod 777 /dev/null

If you have bash autocomplete installed, a programmable completion script containing redirects may be getting sourced.如果您安装了 bash 自动完成功能,则可能会获取包含重定向的可编程完成脚本。 For example, in CentOS /usr/share/bash-completion/bash_completion may be sourced by /etc/profile.d/bash_completion.sh.例如,在 CentOS 中,/usr/share/bash-completion/bash_completion 可能来自 /etc/profile.d/bash_completion.sh。

Try adding this to your restricted user's.bashrc to disable programmable completion:尝试将此添加到受限用户的 .bashrc 以禁用可编程完成:

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.基本选项卡完成将继续工作,您可以选择尝试编写不调用重定向的替代可编程完成脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM