c - 'less' linux 命令的备用程序/使 'less' 安全

标签 c linux bash less-unix

我想为 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/

相关文章:

linux - 分割逗号集文件

linux - 如果进程已经在运行则终止 bash 脚本

c - 了解 C 中的打印值

在 Visual Studio 2010 中用 C 编译给出 MSVCRTD.lib(crtexew.obj) : error LNK2019

bash - 如何将一系列 bash 命令定义为字符串?

linux - awk 在 bash 脚本中使用引号和空格

linux - Docker 卸载 Sawtooth 市场

c - 无法在 C 中返回多维数组

c - 如何从c中的文件中删除空格

c - 从用户输入获取shell命令并执行C程序