ports/107828: [Maintainer Update] ftp/proftpd - Added distributor patch

Beech Rintoul beech at alaskaparadise.com
Thu Jan 11 19:20:16 UTC 2007


>Number:         107828
>Category:       ports
>Synopsis:       [Maintainer Update] ftp/proftpd - Added distributor patch
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 11 19:20:15 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Beech Rintoul
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
Alaska Paradise  
>Environment:


System: FreeBSD 7.0-CURRENT #98: Tue Jan  9 15:30:00 AKST 2007
    root at stargate.alaskaparadise.com:/usr/obj/usr/src/sys/STARGATE



>Description:


Combined patch-contrib-mod_sql.c
Additional patch needed, to preserve the 'fast' functionality.
Ref:
http://bugs.proftpd.org/attachment.cgi?id=2569&action=view
Bumped PORTREVISION.


>How-To-Repeat:





>Fix:


diff -ruN --exclude=CVS /usr/ports/ftp/proftpd.orig/Makefile /usr/ports/ftp/proftpd/Makefile
--- /usr/ports/ftp/proftpd.orig/Makefile	Sun Jan  7 08:37:15 2007
+++ /usr/ports/ftp/proftpd/Makefile	Thu Jan 11 10:03:14 2007
@@ -7,7 +7,7 @@
 
 PORTNAME=	proftpd
 DISTVERSION=	1.3.1rc1
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	ftp
 MASTER_SITES=	ftp://ftp.proftpd.org/distrib/source/ \
 		ftp://ftp.fastorama.com/mirrors/ftp.proftpd.org/distrib/source/ \
diff -ruN --exclude=CVS /usr/ports/ftp/proftpd.orig/files/patch-contrib-mod_sql.c /usr/ports/ftp/proftpd/files/patch-contrib-mod_sql.c
--- /usr/ports/ftp/proftpd.orig/files/patch-contrib-mod_sql.c	Thu Jan  4 16:38:34 2007
+++ /usr/ports/ftp/proftpd/files/patch-contrib-mod_sql.c	Thu Jan 11 09:59:46 2007
@@ -1,5 +1,5 @@
 --- contrib/mod_sql.c.orig	Mon Dec 11 13:40:18 2006
-+++ contrib/mod_sql.c	Thu Jan  4 14:31:13 2007
++++ contrib/mod_sql.c	Thu Jan 11 09:48:25 2007
 @@ -23,7 +23,7 @@
   * the resulting executable, without including the source code for OpenSSL in
   * the source distribution.
@@ -22,20 +22,47 @@
  static char *resolve_long_tag(cmd_rec *, char *);
  static int resolve_numeric_tag(cmd_rec *, char *);
  static char *resolve_short_tag(cmd_rec *, char);
-@@ -752,10 +755,10 @@
+@@ -170,7 +173,6 @@
+   char *grpgidfield;            /* group gid field */
+   char *grpmembersfield;        /* group members field */
+   char *groupwhere;             /* groups where clause */
+-  char *groupcustom;		/* custom groups query */
+ 
+   /*
+    * other information
+@@ -752,10 +754,10 @@
    return mr ? (char *) mr->data : NULL;
  }
  
 -static char *_sql_where(cmd_rec *cmd, int cnt, ...) {
+-  int i, flag;
 +static char *sql_prepare_where(int flags, cmd_rec *cmd, int cnt, ...) {
-   int i, flag;
++  int i, flag, nclauses = 0;
    int curr_avail;
 -  char *buf = "", *res, *tchar, *curr, *tmp;
-+  char *buf = "", *res, *tchar;
++  char *buf = "", *res;
    va_list dummy;
  
    res = pcalloc(cmd->tmp_pool, SQL_MAX_STMT_LEN);
-@@ -774,31 +777,53 @@
+@@ -763,42 +765,68 @@
+   flag = 0;
+   va_start(dummy, cnt);
+   for (i = 0; i < cnt; i++) {
+-    tchar = va_arg(dummy, char *);
+-    if (tchar != NULL &&
+-        *tchar != '\0') {
+-      if (flag++)
+-        buf = pstrcat(cmd->tmp_pool, buf, " and ", NULL);
++    char *clause = va_arg(dummy, char *);
++    if (clause != NULL &&
++        *clause != '\0') {
++      nclauses++;
+ 
+-      buf = pstrcat(cmd->tmp_pool, buf, "(", tchar, ")", NULL);
++      if (flag++)
++        buf = pstrcat(cmd->tmp_pool, buf, " AND ", NULL);
++      buf = pstrcat(cmd->tmp_pool, buf, "(", clause, ")", NULL);
+     }
    }
    va_end(dummy);
  
@@ -45,11 +72,16 @@
 -  for (tmp = buf; *tmp; ) {
 -    char *str;
 -    modret_t *mr;
-+  if (!(flags & SQL_PREPARE_WHERE_FL_NO_TAGS)) {
-+    char *curr, *tmp;
++  if (nclauses == 0)
++    return NULL;
  
 -    if (*tmp == '%') {
 -      char *tag = NULL;
++  if (!(flags & SQL_PREPARE_WHERE_FL_NO_TAGS)) {
++    char *curr, *tmp;
+ 
+-      if (*(++tmp) == '{') {
+-        char *query;
 +    /* Process variables in WHERE clauses, except any "%{num}" references. */
 +    curr = res;
 +    curr_avail = SQL_MAX_STMT_LEN;
@@ -58,18 +90,16 @@
 +      char *str;
 +      modret_t *mr;
  
--      if (*(++tmp) == '{') {
--        char *query;
-+      if (*tmp == '%') {
-+        char *tag = NULL;
- 
 -        if (*tmp != '\0')
 -          query = ++tmp;
-+        if (*(++tmp) == '{') {
-+          char *query;
++      if (*tmp == '%') {
++        char *tag = NULL;
  
 -        while (*tmp && *tmp != '}')
 -          tmp++;
++        if (*(++tmp) == '{') {
++          char *query;
++
 +          if (*tmp != '\0')
 +            query = ++tmp;
 +
@@ -81,34 +111,34 @@
 +            str = resolve_long_tag(cmd, tag);
 +            if (!str)
 +              str = pstrdup(cmd->tmp_pool, "");
-+
-+            mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 2, "default",
-+              str), "sql_escapestring");
-+            if (check_response(mr) < 0)
-+              return NULL;
  
 -        tag = pstrndup(cmd->tmp_pool, query, (tmp - query));
 -        if (tag) {
 -          str = resolve_long_tag(cmd, tag);
 -          if (!str)
 -            str = pstrdup(cmd->tmp_pool, "");
++            mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 2, "default",
++              str), "sql_escapestring");
++            if (check_response(mr) < 0)
++              return NULL;
++
 +            sstrcat(curr, mr->data, curr_avail);
 +            curr += strlen(mr->data);
 +            curr_avail -= strlen(mr->data);
 +
 +            if (*tmp != '\0')
 +              tmp++;
-+
+ 
 +          } else {
 +            return NULL;
 +          }
- 
++
 +        } else {
 +          str = resolve_short_tag(cmd, *tmp);
            mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 2, "default",
              str), "sql_escapestring");
            if (check_response(mr) < 0)
-@@ -810,32 +835,18 @@
+@@ -810,32 +838,18 @@
  
            if (*tmp != '\0')
              tmp++;
@@ -147,7 +177,7 @@
  
    return res;
  }
-@@ -1212,7 +1223,7 @@
+@@ -1212,7 +1226,7 @@
    }
  
    if (!cmap.usercustom) { 
@@ -156,7 +186,7 @@
  
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 5, "default",
        cmap.usrtable, cmap.usrfields, where, "1"), "sql_select");
-@@ -1438,7 +1449,7 @@
+@@ -1438,7 +1452,7 @@
        return NULL;
      }
  
@@ -165,25 +195,29 @@
  
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 5, "default",
        cmap.grptable, cmap.grpfield, where, "1"), "sql_select");
-@@ -1456,7 +1467,7 @@
+@@ -1456,8 +1470,9 @@
  
    grpwhere = pstrcat(cmd->tmp_pool, cmap.grpfield, " = '", groupname, "'",
      NULL);
 -  where = _sql_where(cmd, 2, grpwhere, cmap.groupwhere);
+-  
++
 +  where = sql_prepare_where(0, cmd, 2, grpwhere, cmap.groupwhere, NULL);
-   
++
    mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 4, "default",
      cmap.grptable, cmap.grpfields, where), "sql_select");
-@@ -1530,7 +1541,7 @@
+   if (check_response(mr) < 0)
+@@ -1530,7 +1545,8 @@
  
    usrwhere = pstrcat(cmd->tmp_pool, cmap.usrfield, " = '", _sql_realuser(cmd),
      "'", NULL);
 -  where = _sql_where(cmd, 2, usrwhere, cmap.userwhere);
++
 +  where = sql_prepare_where(0, cmd, 2, usrwhere, cmap.userwhere, NULL);
  
    mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 4, "default", cmap.usrtable,
      query, where), "sql_update");
-@@ -1606,7 +1617,8 @@
+@@ -1606,7 +1622,8 @@
        cmap.grpmembersfield, " = '", username, "'", NULL);
    }
  
@@ -193,7 +227,7 @@
    
    mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 4, "default",
      cmap.grptable, cmap.grpfields, where), "sql_select");
-@@ -1746,7 +1758,7 @@
+@@ -1746,7 +1763,7 @@
  static char *resolve_short_tag(cmd_rec *cmd, char tag) {
    char arg[256] = {'\0'}, *argp;
  
@@ -202,7 +236,7 @@
    case 'A': {
        char *pass;
  
-@@ -2915,7 +2927,7 @@
+@@ -2915,7 +2932,7 @@
    /* single select or not? */
    if (SQL_FASTUSERS) {
      /* retrieve our list of passwds */
@@ -211,25 +245,29 @@
  
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 4, "default",
        cmap.usrtable, cmap.usrfields, where), "sql_select");
-@@ -2978,7 +2990,7 @@
+@@ -2978,8 +2995,8 @@
      } 
    } else {
      /* retrieve our list of passwds */
 -    where = _sql_where(cmd, 1, cmap.userwhere);
+-    
 +    where = sql_prepare_where(0, cmd, 1, cmap.userwhere, NULL);
-     
++
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 4, "default",
        cmap.usrtable, cmap.usrfield, where), "sql_select");
-@@ -3086,7 +3098,7 @@
+     if (check_response(mr) < 0)
+@@ -3086,8 +3103,8 @@
  
    if (SQL_FASTGROUPS) {
      /* retrieve our list of groups */
 -    where = _sql_where(cmd, 1, cmap.groupwhere);
+-    
 +    where = sql_prepare_where(0, cmd, 1, cmap.groupwhere, NULL);
-     
++
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 6, "default",
        cmap.grptable, cmap.grpfields, where, NULL), "sql_select");
-@@ -3119,9 +3131,15 @@
+     if (check_response(mr) < 0)
+@@ -3119,9 +3136,9 @@
      }
  
    } else {
@@ -237,32 +275,47 @@
 -    where = _sql_where(cmd, 1, cmap.groupwhere);
 -    
 +    /* Retrieve our list of groups. */
-+    if (cmap.groupwhere &&
-+        strlen(cmap.groupwhere) > 0) {
-+      where = sql_prepare_where(0, cmd, 1, cmap.groupwhere, NULL);
-+
-+    } else {
-+      where = NULL;
-+    }
++    where = sql_prepare_where(0, cmd, 1, cmap.groupwhere, NULL);
 + 
      mr = _sql_dispatch(_sql_make_cmd(cmd->tmp_pool, 6, "default",
        cmap.grptable, cmap.grpfield, where, NULL, "DISTINCT"), "sql_select");
      if (check_response(mr) < 0)
-@@ -3593,7 +3611,7 @@
+@@ -3593,8 +3610,9 @@
  
    usrwhere = pstrcat(cmd->tmp_pool, cmap.usrfield, " = '", _sql_realuser(cmd),
      "'", NULL);
 -  where = _sql_where(cmd, 2, usrwhere, cmap.userwhere);
+-  
++
 +  where = sql_prepare_where(0, cmd, 2, usrwhere, cmap.userwhere, NULL);
-   
++ 
    query = pstrcat(cmd->tmp_pool, cmap.sql_fstor, ", ",
  		  cmap.sql_fretr, ", ", cmap.sql_bstor, ", ",
-@@ -3627,7 +3645,7 @@
+ 		  cmap.sql_bretr, NULL);
+@@ -3627,8 +3645,9 @@
  
    usrwhere = pstrcat(cmd->tmp_pool, cmap.usrfield, " = '", _sql_realuser(cmd),
      "'", NULL);
 -  where = _sql_where(cmd, 2, usrwhere, cmap.userwhere);
+-  
++
 +  where = sql_prepare_where(0, cmd, 2, usrwhere, cmap.userwhere, NULL);
-   
++
    query = pstrcat(cmd->tmp_pool, cmap.sql_frate, ", ",
  		  cmap.sql_fcred, ", ", cmap.sql_brate, ", ",
+ 		  cmap.sql_bcred, NULL);
+@@ -4715,10 +4734,12 @@
+   cmap.grpfields = pstrdup(sql_pool, fieldset);
+ 
+   temp_ptr = get_param_ptr(main_server->conf, "SQLUserWhereClause", FALSE);
+-  cmap.userwhere = temp_ptr ? pstrcat(sql_pool, "(", temp_ptr, ")", NULL) : "";
++  cmap.userwhere = temp_ptr ? pstrcat(sql_pool, "(", temp_ptr, ")", NULL) :
++    NULL;
+ 
+   temp_ptr = get_param_ptr(main_server->conf, "SQLGroupWhereClause", FALSE);
+-  cmap.groupwhere = temp_ptr ? pstrcat(sql_pool, "(", temp_ptr, ")", NULL) : "";
++  cmap.groupwhere = temp_ptr ? pstrcat(sql_pool, "(", temp_ptr, ")", NULL) :
++    NULL;
+ 
+   temp_ptr = get_param_ptr(main_server->conf, "SQLAuthTypes", FALSE);
+   cmap.authlist = temp_ptr;



>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list