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.2.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. const char *addr = pr_table_get(session.notes, "mod_xclient.addr", NULL);
  31. if (!addr)
  32. addr = pr_netaddr_get_ipstr(pr_netaddr_get_sess_remote_addr());
  33. pr_log_auth(PR_LOG_NOTICE, "Login: user=<%s>, rip=%s, proto=%s",
  34. session.user, addr, pr_session_get_protocol(0));
  35. return PR_DECLINED(cmd);
  36. }
  37.  
  38. #if defined(PR_SHARED_MODULE)
  39. static void log_login_mod_unload_ev(const void *event_data, void *user_data)
  40. {
  41. if (strcmp("mod_log_login.c", (const char *)event_data) == 0)
  42. pr_event_unregister(&log_login_module, NULL, NULL);
  43. }
  44. #endif
  45.  
  46. static int log_login_init(void)
  47. {
  48. #if defined(PR_SHARED_MODULE)
  49. pr_event_register(&log_login_module, "core.module-unload",
  50. log_login_mod_unload_ev, NULL);
  51. #endif
  52. return 0;
  53. }
  54.  
  55. static cmdtable log_login_cmdtab[] =
  56. {
  57. { LOG_CMD, C_PASS, G_NONE, log_login_do, FALSE, FALSE },
  58. { 0, NULL }
  59. };
  60.  
  61. module log_login_module =
  62. {
  63. /* always NULL */
  64. NULL, NULL,
  65.  
  66. /* module api version 2.0 */
  67. 0x20,
  68.  
  69. /* module name */
  70. "log_login",
  71.  
  72. /* module configuration handler table */
  73. NULL,
  74.  
  75. /* module command handler table */
  76. log_login_cmdtab,
  77.  
  78. /* module authentication handler table */
  79. NULL,
  80.  
  81. /* module initialization function */
  82. log_login_init,
  83.  
  84. /* module session initialization function */
  85. NULL,
  86.  
  87. /* module version */
  88. MOD_LOG_LOGIN_VERSION
  89. };
  90.