Download | Plain Text | No Line Numbers


  1. /*
  2.  * ProFTPD: mod_log_login
  3.  *
  4.  * Copyright (c) 2014 Manuel Mausz
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. #define MOD_LOG_LOGIN_VERSION "mod_log_login/0.1.0"
  22.  
  23. #include "conf.h"
  24. #include "privs.h"
  25.  
  26. module log_login_module;
  27.  
  28. MODRET log_login_do(cmd_rec *cmd)
  29. {
  30. pr_log_auth(PR_LOG_NOTICE, "Login: user=<%s>, rip=%s, proto=%s",
  31. session.user, pr_netaddr_get_ipstr(pr_netaddr_get_sess_remote_addr()),
  32. pr_session_get_protocol(0));
  33.  
  34. return PR_DECLINED(cmd);
  35. }
  36.  
  37. #if defined(PR_SHARED_MODULE)
  38. static void log_login_mod_unload_ev(const void *event_data, void *user_data)
  39. {
  40. if (strcmp("mod_log_login.c", (const char *)event_data) == 0)
  41. pr_event_unregister(&log_login_module, NULL, NULL);
  42. }
  43. #endif
  44.  
  45. static int log_login_init(void)
  46. {
  47. #if defined(PR_SHARED_MODULE)
  48. pr_event_register(&log_login_module, "core.module-unload",
  49. log_login_mod_unload_ev, NULL);
  50. #endif
  51. return 0;
  52. }
  53.  
  54. static cmdtable log_login_cmdtab[] =
  55. {
  56. { LOG_CMD, C_PASS, G_NONE, log_login_do, FALSE, FALSE },
  57. { 0, NULL }
  58. };
  59.  
  60. module log_login_module =
  61. {
  62. /* always NULL */
  63. NULL, NULL,
  64.  
  65. /* module api version 2.0 */
  66. 0x20,
  67.  
  68. /* module name */
  69. "log_login",
  70.  
  71. /* module configuration handler table */
  72. NULL,
  73.  
  74. /* module command handler table */
  75. log_login_cmdtab,
  76.  
  77. /* module authentication handler table */
  78. NULL,
  79.  
  80. /* module initialization function */
  81. log_login_init,
  82.  
  83. /* module session initialization function */
  84. NULL,
  85.  
  86. /* module version */
  87. MOD_LOG_LOGIN_VERSION
  88. };
  89.