Get FTP Username for <IfModule mod_exec.c>

Hello Forlks,

I have been searching around the internet for the specific and customized requirement to get the security logs for analysis. I have been stuck at one place.

I have used following command in virtulmin.conf file under /etc/proftpd/conf.d

<IfModule mod_exec.c>
ExecEngine on
ExecOptions logStderr logStdout
ExecLog /var/log/proftpd/mod_exec.log
ExecTimeout 180
ExecEnviron FTP_USER_PASS %A
ExecEnviron FTP_USER_IP %a
ExecEnviron FTP_USER_NAME_LOCAL %u
ExecEnviron FTP_USER_NAME_ORIG %U
ExecEnviron FTP_USER_GROUP %g
ExecEnviron FTP_USER_DNS_NAME %h
ExecEnviron FTP_WORKING_DIR %C
ExecEnviron FTP_CONN_CLASS %c
ExecEnviron FTP_FILE %F
ExecEnviron FTP_FILE_PATH %f
ExecEnviron FTP_COMMAND %m
ExecEnviron FTP_SERVER_NAME %v
ExecEnviron FTP_RNFR_NAME %w
ExecOnConnect /etc/proftpd/scripts/mycustom.sh %A %a %u %U %g %h %C %c %F %f
</IfModule>

mycustom.sh file looks like this

#!/bin/bash
echo “Script argument 1 FTP_USER_PASS=$1”
echo “Script argument 2 FTP_USER_IP=$2”
echo “Script argument 3 FTP_USER_NAME_LOCAL=$3”
echo “Script argument 4 FTP_USER_NAME_ORIG=$4”
echo “Script argument 5 FTP_USER_GROUP=$5”
echo “Script argument 6 FTP_USER_DNS_NAME=$6”
echo “Script argument 7 FTP_WORKING_DIR=$7”
echo “Script argument 8 FTP_CONN_CLASS=$8”
echo “Script argument 9 FTP_FILE=$9”
echo “Script argument 10 FTP_FILE_PATH=$10”
echo “Script argument 11 FTP_COMMAND=$11”
echo “Script argument 12 FTP_SERVER_NAME=$12”
echo “Script argument 13 FTP_RNFR_NAME=$13”

The following output in mod_exec.log showing output only for the " FTP_USER_IP" variable but other like FTP_USER_NAME_LOCAL, FTP_USER_NAME_ORIG is not showing.

I wanted to know which user is connected to FTP through which IP, i’m going to use this log file to send push notification via perl. That is the later part but first would like to output the username used to connect FTP.

I have also tried replacing common virtualmin variables like ${USER} but it does not help!

Can anyone suggest me something?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.