gpt4 book ai didi

linux - 如何使用 mod_exec proftpd linux

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:16 32 4
gpt4 key购买 nike

我使用这段代码从 mod_exec proftpd 执行外部脚本。

执行引擎开启 ExecLog/opt/proftpd_mod_exec.log ExecOptions logStderr logStdout

<IfUser yogi>
ExecBeforeCommand STOR,RETR /home/yogi/Desktop/kab.sh EVENT=BeforeCommand FILE='%f'
ExecOnCommand STOR,RETR /home/yogi/Desktop/kab.sh EVENT=OnCommand FILE='%f'
</IfUser>

但我在 proftpd_mod_exec.log 文件中收到类似这样的错误代码。 STOR ExecBeforeCommand '/home/yogi/Desktop/kab.sh' 失败:执行格式错误

我该如何解决?

最佳答案

来自 http://www.proftpd.org/docs/contrib/mod_exec.html

This module will not work properly for logins, or for logins that are affected by DefaultRoot. These directives use the chroot(2) system call, which wreaks havoc when it comes to scripts. The path to script/shell interpreters often assume a certain location that is no longer valid within a chroot. In addition, most modern operating systems use dynamically loaded libraries (.so libraries) for many binaries, including script/shell interpreters. The location of these libraries, when they come to be loaded, are also assumed; those assumptions break within a chroot. Perl, in particular, is so wrought with filesystem location assumptions that it's almost impossible to get a Perl script to work within a chroot, short of installing Perl itself into the chroot environment.

从错误消息来看,似乎就是这样。您已启用 chroot,但脚本无法执行,因为文件在 chroot 中的预期位置不可用。

作者因此建议不要使用该模块。要让它工作,您需要弄清楚 chroot 目标中需要的依赖项,并将它们设置在适当的位置。或者为用户禁用 chroot,然后重试。第三种可能性:构建一个几乎没有依赖关系的静态链接二进制文件。

或者按照模块作者的建议,尝试使用 FIFO 和 proftpd 日志记录功能在 chroot 环境之外触发脚本。

关于linux - 如何使用 mod_exec proftpd linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57969247/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com