Author Topic: ExecOnCommand and cookies?  (Read 304 times)

Offline tony-k

  • New user
  • *
  • Posts: 9
    • View Profile
ExecOnCommand and cookies?
« on: May 23, 2017, 07:43:49 pm »
exec.conf:

Code: [Select]
  ExecOnCommand ALL /usr/bin/curl -H "Content-Type: application/json" -X POST -d '{"userName":"%u","clientIp":"%a","clientDns":"%h","bytes":"%b","path":"%f","file":"%F","command":"%m","responseCode":"%s","seconds":"%T"}' http://udx-api:3000/ftp-commands
exec.log:

Code: [Select]
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]: preparing to execute '/usr/bin/curl' with uid 65534 (euid 65534), gid 65534 (egid 65534)
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[1] = -H
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[2] = Content-Type: application/json
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[3] = -X
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[4] = POST
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[5] = -d
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[6] = '{"userName":"","clientIp":"172.17.0.1","clientDns":"172.17.0.1","bytes":"%b","path":"","file":"","command":"USERAUTH_REQUEST","responseCode":"%s","seconds":"%T"}'
2017-05-23 19:30:46,559 mod_exec/0.9.14[13]:  + '/usr/bin/curl': argv[7] = http://udx-api:3000/ftp-commands
2017-05-23 19:30:48,562 mod_exec/0.9.14[7]: '/usr/bin/curl' terminated normally, with exit status 0
2017-05-23 19:30:48,562 mod_exec/0.9.14[7]: USERAUTH_REQUEST ExecOnCommand '/usr/bin/curl' succeeded

i would have expected %u to have a value and %b,%s and %T to have been replaced (even if with blanks)...?





Offline castaglia

  • Administrator
  • Support Hero
  • *****
  • Posts: 5359
    • View Profile
    • http://www.castaglia.org/
Re: ExecOnCommand and cookies?
« Reply #1 on: May 24, 2017, 05:46:59 am »
The %u variable, for example, is for the _authenticated_ user name -- but some FTP commands happen before the user has been authenticated.  Like, other commands are not related to transfers, but the %b, %T variables are.  Not all variables are relevant to every FTP commands (or SFTP request, for that matter).

Offline tony-k

  • New user
  • *
  • Posts: 9
    • View Profile
Re: ExecOnCommand and cookies?
« Reply #2 on: May 31, 2017, 02:08:42 am »
i'm not seeing %b on STOR,RETR should it be available?

in exec.conf:
Code: [Select]
ExecEnviron _BYTES %b
ExecOnCommand STOR,RETR /etc/proftpd/script/on-command.sh

but _BYTES seems to have a value of the literal %b in the on-command.sh script...?

Offline castaglia

  • Administrator
  • Support Hero
  • *****
  • Posts: 5359
    • View Profile
    • http://www.castaglia.org/
Re: ExecOnCommand and cookies?
« Reply #3 on: June 01, 2017, 01:36:12 am »
The %b variable is not currently supported by mod_exec; see:

  http://www.proftpd.org/docs/contrib/mod_exec.html#ExecEnviron

You can file a feature request to have it supported...