httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r771947 - in /httpd/mod_ftp/trunk/modules/ftp: ftp_limitlogin.c ftp_protocol.h
Date Tue, 05 May 2009 18:03:10 GMT
Author: jim
Date: Tue May  5 18:03:10 2009
New Revision: 771947

URL: http://svn.apache.org/viewvc?rev=771947&view=rev
Log:
Map each limit to a per-server scope, by simply tagging it with
the server's hostname...

Modified:
    httpd/mod_ftp/trunk/modules/ftp/ftp_limitlogin.c
    httpd/mod_ftp/trunk/modules/ftp/ftp_protocol.h

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_limitlogin.c
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_limitlogin.c?rev=771947&r1=771946&r2=771947&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_limitlogin.c (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_limitlogin.c Tue May  5 18:03:10 2009
@@ -161,6 +161,10 @@
     int uval = 0;
     int ival = 0;
     int sval = 0;
+    char *tkey;
+    char *sname = (r->server->server_hostname
+                   ? r->server->server_hostname
+                   : "unknown");
     ftp_server_config *fsc =
     ftp_get_module_config(r->server->module_config);
 
@@ -180,8 +184,9 @@
      * First we check the user settings.
      * This is a safe cast, this is a lookup key.
      */
-    ukey.dptr = (char *) user;
-    ukey.dsize = strlen(user);
+    tkey = apr_psprintf(r->pool, "%s-%s", sname, user);
+    ukey.dptr = (char *) tkey;
+    ukey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, ukey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));
@@ -195,8 +200,9 @@
      * Now we check the IP settings.
      * This is a safe cast, this is a lookup key.
      */
-    ikey.dptr = (char *) c->remote_ip;
-    ikey.dsize = strlen(c->remote_ip);
+    tkey = apr_psprintf(r->pool, "%s-%s", sname, c->remote_ip);
+    ikey.dptr = (char *) tkey;
+    ikey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, ikey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));
@@ -210,8 +216,10 @@
      * OK, so we're not up against the per user or IP limit,
      * we need to check the perserver limit then
      */
-    skey.dptr = FTP_SERVER_LIMIT_KEY;
-    skey.dsize = strlen(FTP_SERVER_LIMIT_KEY);
+
+    tkey = apr_psprintf(r->pool, "%s-%s", sname, FTP_SERVER_LIMIT_KEY);
+    skey.dptr = (char *) tkey;
+    skey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, skey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));
@@ -267,6 +275,10 @@
     int uval = 0;
     int ival = 0;
     int sval = 0;
+    char *tkey;
+    char *sname = (fc->orig_server->server_hostname
+                   ? fc->orig_server->server_hostname
+                   : "unknown");
     ftp_server_config *fsc =
     ftp_get_module_config(fc->orig_server->module_config);
 
@@ -286,24 +298,27 @@
     /*
      * This is a safe cast, it's a lookup key
      */
-    ukey.dptr = (char *) fc->user;
-    ukey.dsize = strlen(fc->user);
+    tkey = apr_psprintf(c->pool, "%s-%s", sname, fc->user);
+    ukey.dptr = (char *) tkey;
+    ukey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, ukey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));
         uval = atoi(temp);
     }
 
-    ikey.dptr = (char *) c->remote_ip;
-    ikey.dsize = strlen(c->remote_ip);
+    tkey = apr_psprintf(c->pool, "%s-%s", sname, c->remote_ip);
+    ikey.dptr = (char *) tkey;
+    ikey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, ikey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));
         ival = atoi(temp);
     }
 
-    skey.dptr = FTP_SERVER_LIMIT_KEY;
-    skey.dsize = strlen(FTP_SERVER_LIMIT_KEY);
+    tkey = apr_psprintf(c->pool, "%s-%s", sname, FTP_SERVER_LIMIT_KEY);
+    skey.dptr = tkey;
+    skey.dsize = strlen(tkey);
     rv = apr_dbm_fetch(dbf, skey, &val);        /* error for non-existant? */
     if (val.dptr != NULL && val.dsize > 0) {
         apr_cpystrn(temp, val.dptr, MYMIN(sizeof(temp), val.dsize + 1));

Modified: httpd/mod_ftp/trunk/modules/ftp/ftp_protocol.h
URL: http://svn.apache.org/viewvc/httpd/mod_ftp/trunk/modules/ftp/ftp_protocol.h?rev=771947&r1=771946&r2=771947&view=diff
==============================================================================
--- httpd/mod_ftp/trunk/modules/ftp/ftp_protocol.h (original)
+++ httpd/mod_ftp/trunk/modules/ftp/ftp_protocol.h Tue May  5 18:03:10 2009
@@ -6,7 +6,7 @@
  * another gmake (or a make ftp_protocol.h)
  *
  * Generated from ../.. on 
- * Tue Jun 17 18:29:23 2008
+ * Tue May  5 14:35:16 2009
  */
 
 



Mime
View raw message