我想为 Linux 编写一个交互式程序,例如“less”命令。我不能在我的设置中使用 less 的原因是你可以在 less 提示符 '!cmd' 中执行 shell 命令,这对于任何生产环境来说都是一个主要的安全风险。
我的首选语言是 C,但是,如果有人能推荐任何其他类似的程序,那也会很棒,因为我手头有时间。
我知道一种选择是浏览较少的源代码,但看起来这在短时间内也不是很直接。
最佳答案
太棒了,我在 less 本身的手册页中得到了答案。您可以使用其中一个变量禁用这些东西。
安全 当环境变量 LESSSECURE 设置为 1 时,less 以“安全”模式运行。这意味着这些特征 已禁用:
! the shell command
| the pipe command
:e the examine command.
v the editing command
s -o log files
-k use of lesskey files
-t use of tags files
metacharacters in filenames, such as *
filename completion (TAB, ^L)
Less can also be compiled to be permanently in "secure" mode.
关于c - 'less' linux 命令的备用程序/使 'less' 安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22815299/