What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Run script on FTP user connect

I'm not using ftp so, what does it log to syslog?
Without using the timestamps you could tail pipe it anf simply look for the entry.
 
I'm not using ftp so, what does it log to syslog?
Without using the timestamps you could tail pipe it anf simply look for the entry.
Out of the box? Nothing. If I add this to vsftpd.conf
Code:
log_ftp_protocol=YES
I get lots of nice logging in /var/log/vsftpd.log
Code:
Tue Aug 29 22:12:44 2017 [pid 10482] [jack] FTP response: Client "10.14.16.10", "230 Login successful."
Enabling client timeouts then gets me lines such as
Code:
Tue Aug 29 22:12:55 2017 [pid 10482] [jack] FTP response: Client "10.14.16.10", "421 Timeout."

So now I'm working on a script to run every 10-15s to check for these lines. I'm going to make it a log cleaner so on detection of a line it deletes everything prior, as I'm not sure if log rotation applies to vsftpd.log.

I'm trying to find a nice way to make an indefinite loop but with a shutdown/abort condition. I'll probably make it refer to a temp file i create on loop start, and if it is deleted, the loop will exit.

EDIT: timeouts fire even when there's an active transfer, though it doesn't interrupt the transfer. Tracking the disconnects is proving the tricky part.
 
A different approach is using:
Code:
setproctitle_enable
If enabled, vsftpd will try and show session status information in the system process listing. In other words, the reported name of the process will change to reflect what a vsftpd session is doing (idle, downloading etc). You probably want to leave this off for security purposes.
Default: NO
which shows
Code:
admin@RT-AC87U:/tmp/home/root# ps | grep "vsftpd"
15357 admin     3804 S    vsftpd: LISTENER
15921 admin     3868 S    vsftpd: 10.14.16.10: connected
15923 1         3900 D    vsftpd: 10.14.16.10/jack: FILENAME
16031 admin     3868 S    vsftpd: 10.14.16.10: connected
16033 1         3900 D    vsftpd: 10.14.16.10/jack: RETR FILENAME
16271 admin     1448 R    grep vsftpd

since there's no WAN access to the router login/FTP (accessible over VPN only), I'm not currently worried about the security implications.

My desired function is for a script to divide up a total amount of bandwidth between connected users. I think using this ps approach I can total up the number of users with a RETR, and calculate bandwidth, and put in client config file. ftpd service would then be restarted. FileZilla seems smart enough to wait and continue the transfer while the server is unavailable.
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top