Blame SOURCES/vsftpd-2.1.0-userlist_log.patch

bd78b8
diff -up vsftpd-2.1.0/logging.c.userlist_log vsftpd-2.1.0/logging.c
bd78b8
--- vsftpd-2.1.0/logging.c.userlist_log	2008-12-17 20:56:45.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/logging.c	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -95,6 +95,13 @@ vsf_log_line(struct vsf_session* p_sess,
bd78b8
   vsf_log_common(p_sess, 1, what, p_str);
bd78b8
 }
bd78b8
 
bd78b8
+void
bd78b8
+vsf_log_failed_line(struct vsf_session* p_sess, enum EVSFLogEntryType what,
bd78b8
+             struct mystr* p_str)
bd78b8
+{
bd78b8
+  vsf_log_common(p_sess, 0, what, p_str);
bd78b8
+}
bd78b8
+
bd78b8
 int
bd78b8
 vsf_log_entry_pending(struct vsf_session* p_sess)
bd78b8
 {
bd78b8
diff -up vsftpd-2.1.0/logging.h.userlist_log vsftpd-2.1.0/logging.h
bd78b8
--- vsftpd-2.1.0/logging.h.userlist_log	2008-07-30 03:29:21.000000000 +0200
bd78b8
+++ vsftpd-2.1.0/logging.h	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -80,5 +80,16 @@ void vsf_log_do_log(struct vsf_session* 
bd78b8
 void vsf_log_line(struct vsf_session* p_sess, enum EVSFLogEntryType what,
bd78b8
                   struct mystr* p_str);
bd78b8
 
bd78b8
+/* vsf_log_failed_line()
bd78b8
+ * PURPOSE
bd78b8
+ * Same as vsf_log_line(), except that it logs the line as failed operation.
bd78b8
+ * PARAMETERS
bd78b8
+ * p_sess       - the current session object
bd78b8
+ * what         - the type of operation to log
bd78b8
+ * p_str        - the string to log
bd78b8
+ */
bd78b8
+void vsf_log_failed_line(struct vsf_session* p_sess, enum EVSFLogEntryType what,
bd78b8
+                  struct mystr* p_str);
bd78b8
+
bd78b8
 #endif /* VSF_LOGGING_H */
bd78b8
 
bd78b8
diff -up vsftpd-2.1.0/parseconf.c.userlist_log vsftpd-2.1.0/parseconf.c
bd78b8
--- vsftpd-2.1.0/parseconf.c.userlist_log	2008-12-18 07:21:41.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/parseconf.c	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -96,6 +96,7 @@ parseconf_bool_array[] =
bd78b8
   { "mdtm_write", &tunable_mdtm_write },
bd78b8
   { "lock_upload_files", &tunable_lock_upload_files },
bd78b8
   { "pasv_addr_resolve", &tunable_pasv_addr_resolve },
bd78b8
+  { "userlist_log", &tunable_userlist_log },
bd78b8
   { "debug_ssl", &tunable_debug_ssl },
bd78b8
   { "require_cert", &tunable_require_cert },
bd78b8
   { "validate_cert", &tunable_validate_cert },
bd78b8
diff -up vsftpd-2.1.0/prelogin.c.userlist_log vsftpd-2.1.0/prelogin.c
bd78b8
--- vsftpd-2.1.0/prelogin.c.userlist_log	2009-02-18 23:23:53.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/prelogin.c	2009-02-24 09:17:41.000000000 +0100
bd78b8
@@ -220,6 +220,20 @@ handle_user_command(struct vsf_session* 
bd78b8
       check_login_delay();
bd78b8
       vsf_cmdio_write(p_sess, FTP_LOGINERR, "Permission denied.");
bd78b8
       check_login_fails(p_sess);
bd78b8
+      if (tunable_userlist_log)
bd78b8
+      {
bd78b8
+        struct mystr str_log_line = INIT_MYSTR;
bd78b8
+        if (tunable_userlist_deny)
bd78b8
+        {
bd78b8
+          str_alloc_text(&str_log_line, "User is in the deny user list.");
bd78b8
+        }
bd78b8
+        else
bd78b8
+        {
bd78b8
+          str_alloc_text(&str_log_line, "User is not in the allow user list.");
bd78b8
+        }
bd78b8
+        vsf_log_failed_line(p_sess, kVSFLogEntryLogin, &str_log_line);
bd78b8
+        str_free(&str_log_line);
bd78b8
+      }
bd78b8
       str_empty(&p_sess->user_str);
bd78b8
       return;
bd78b8
     }
bd78b8
diff -up vsftpd-2.1.0/tunables.c.userlist_log vsftpd-2.1.0/tunables.c
bd78b8
--- vsftpd-2.1.0/tunables.c.userlist_log	2009-02-24 09:12:42.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/tunables.c	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -72,6 +72,7 @@ int tunable_force_anon_data_ssl;
bd78b8
 int tunable_mdtm_write;
bd78b8
 int tunable_lock_upload_files;
bd78b8
 int tunable_pasv_addr_resolve;
bd78b8
+int tunable_userlist_log;
bd78b8
 int tunable_debug_ssl;
bd78b8
 int tunable_require_cert;
bd78b8
 int tunable_validate_cert;
bd78b8
@@ -206,6 +207,7 @@ tunables_load_defaults()
bd78b8
   tunable_mdtm_write = 1;
bd78b8
   tunable_lock_upload_files = 1;
bd78b8
   tunable_pasv_addr_resolve = 0;
bd78b8
+  tunable_userlist_log = 0;
bd78b8
   tunable_debug_ssl = 0;
bd78b8
   tunable_require_cert = 0;
bd78b8
   tunable_validate_cert = 0;
bd78b8
diff -up vsftpd-2.1.0/tunables.h.userlist_log vsftpd-2.1.0/tunables.h
bd78b8
--- vsftpd-2.1.0/tunables.h.userlist_log	2008-12-17 06:47:11.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/tunables.h	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -73,6 +73,7 @@ extern int tunable_force_anon_data_ssl; 
bd78b8
 extern int tunable_mdtm_write;                /* Allow MDTM to set timestamps */
bd78b8
 extern int tunable_lock_upload_files;         /* Lock uploading files */
bd78b8
 extern int tunable_pasv_addr_resolve;         /* DNS resolve pasv_addr */
bd78b8
+extern int tunable_userlist_log;              /* Log every failed login attempt */
bd78b8
 extern int tunable_debug_ssl;                 /* Verbose SSL logging */
bd78b8
 extern int tunable_require_cert;              /* SSL client cert required */
bd78b8
 extern int tunable_validate_cert;             /* SSL certs must be valid */
bd78b8
diff -up vsftpd-2.1.0/vsftpd.conf.5.userlist_log vsftpd-2.1.0/vsftpd.conf.5
bd78b8
--- vsftpd-2.1.0/vsftpd.conf.5.userlist_log	2009-02-24 09:12:42.000000000 +0100
bd78b8
+++ vsftpd-2.1.0/vsftpd.conf.5	2009-02-24 09:12:42.000000000 +0100
bd78b8
@@ -585,6 +585,14 @@ Self-signed certs do not constitute OK v
bd78b8
 
bd78b8
 Default: NO
bd78b8
 .TP
bd78b8
+.B userlist_log
bd78b8
+This option is examined if
bd78b8
+.BR userlist_enable
bd78b8
+is activated. If enabled, every login denial based on the user list will be
bd78b8
+logged.
bd78b8
+
bd78b8
+Default: NO
bd78b8
+.TP
bd78b8
 .B virtual_use_local_privs
bd78b8
 If enabled, virtual users will use the same privileges as local users. By
bd78b8
 default, virtual users will use the same privileges as anonymous users, which