Forming sanitary shell commands or system calls in Ruby

后端 未结 5 1771
长发绾君心
长发绾君心 2020-12-08 11:20

I\'m building a daemon that will help me manage my server(s). Webmin works fine, as does just opening a shell to the server, but I\'d prefer to be able to control server ope

5条回答
  •  隐瞒了意图╮
    2020-12-08 12:00

    This is an old question, but since it's pretty much the only real answer you'll find when googling I thought I'd add a caveat. The multi argument version of system seems reasonably safe on Linux, but it is NOT on Windows.

    Try system "dir", "&", "echo", "hi!" on a Windows system. Both dir and echo will be run. Echo could of course just as well be something far less innocuous.

提交回复
热议问题