Главная страница


ru.unix.bsd

 
 - RU.UNIX.BSD ------------------------------------------------------------------
 From : Pavel Vorotilin                      2:5020/400     09 Feb 2003  16:19:35
 To : All
 Subject : SASL MySQL Patch
 -------------------------------------------------------------------------------- 
 
 Дарова, Олл!
 Обещал сабжевый патч, в мыло ринулось такое нереальное количесво народа что
 решил выложить в эху..
 Для версии 1.5.24
 
 \begin{WindowsClipboard}
 diff -ru cyrus-sasl-1.5.24.old/configure cyrus-sasl-1.5.24/configure
 - --- cyrus-sasl-1.5.24.old/configure Fri Jan 14 06:01:08 2000
 +++ cyrus-sasl-1.5.24/configure Fri Apr 28 22:02:29 2000
 @@ -3227,4 +3227,18 @@
  fi
 
 +if test "${with_mysql+set}" = set; then
 +  withval="$with_mysql"
 +  with_mysql=$withval
 +else
 +  with_mysql=yes
 +fi
 +if test "$with_mysql" != no; then
 +  if test -d $with_mysql; then
 +    CPPFLAGS="$CPPFLAGS -I${with_mysql}/include/mysql"
 +    LDFLAGS="$LDFLAGS -L${with_mysql}/lib/mysql"
 +    LIBS="$LIBS -lmysqlclient"
 +    DEFS="$DEFS -DHAVE_MYSQL"
 +  fi
 +fi
 
  # Check whether --with-pam or --without-pam was given.
 diff -ru cyrus-sasl-1.5.24.old/configure cyrus-sasl-1.5.24/configure
 - --- cyrus-sasl-1.5.24.old/configure Fri Jan 14 06:01:08 2000
 +++ cyrus-sasl-1.5.24/configure Fri Apr 28 22:02:29 2000
 @@ -5430,1 +5430,1 @@
 -DEFS=-DHAVE_CONFIG_H
 +DEFS="$DEFS -DHAVE_CONFIG_H"
 diff -ru cyrus-sasl-1.5.24.old/lib/checkpw.c cyrus-sasl-1.5.24/lib/checkpw.c
 - --- cyrus-sasl-1.5.24.old/lib/checkpw.c Sun Dec 12 23:31:14 1999
 +++ cyrus-sasl-1.5.24/lib/checkpw.c Fri Apr 28 22:02:49 2000
 @@ -900,7 +900,111 @@
 
  #endif
 
 +#ifdef HAVE_MYSQL
 +/*MySQL SASL Patch by Pavel Vorotilin. 08 Sep 2002. For Space hosting
 system*/
 +#include "mysql.h"
 +#define QUERY_STRING    "select %s from %s where %s = '%s' and %s = '%s'
 %s"
 +
 +static int mysql_verify_password(sasl_conn_t *conn,
 +                               const char *userid,
 +                               const char *password,
 +    const char *service __attribute__((unused)),
 +    const char *user_realm __attribute__((unused)),
 +    const char **reply)
 +{
 +  unsigned int numrows;
 +  MYSQL mysql,*sock;
 +  MYSQL_RES *result;
 +  char qbuf[300];
 +  char *db_user="",
 +       *db_passwd="",
 +       *db_host="",
 +       *db_uidcol="",
 +       *db_pwcol="",
 +       *db_database="",
 +       *db_table="",
 +       *sqlappend="";
 +  sasl_getopt_t *getopt;
 +  void *context;
 +
 +  if (!userid || !password) {
 +      return SASL_BADPARAM;
 +  }
 +  if (reply) { *reply = NULL; }
 +
 +  /* check to see if the user configured a mysqluser/passwd/host/etc */
 +  if (_sasl_getcallback(conn, SASL_CB_GETOPT, &getopt, &context)
 +      == SASL_OK) {
 +      getopt(context, NULL, "mysqluser", (const char **) &db_user, NULL);
 +      if (!db_user) db_user = "";
 +      getopt(context, NULL, "mysqlpasswd", (const char **) &db_passwd,
 NULL);
 +      if (!db_passwd) db_passwd = "";
 +      getopt(context, NULL, "mysqlhost", (const char **) &db_host, NULL);
 +      if (!db_host) db_host = "";
 +      getopt(context, NULL, "mysqldatabase", (const char **) &db_database,
 NULL);
 +      if (!db_database) db_database = "";
 +      getopt(context, NULL, "mysqltable", (const char **) &db_table, NULL);
 +      if (!db_table) db_table = "";
 +      getopt(context, NULL, "mysqluidcol", (const char **) &db_uidcol,
 NULL);
 +      if (!db_uidcol) db_uidcol = "";
 +      getopt(context, NULL, "mysqlpwcol", (const char **) &db_pwcol, NULL);
 +      if (!db_pwcol) db_pwcol = "";
 +      /* Query Append */
 +      getopt(context, NULL, "mysqlappend", (const char **) &sqlappend,
 NULL);
 +      if (!sqlappend) sqlappend = "";
 +  }
 +
 +  //if (!(sock = mysql_connect(&mysql,NULL,0,0)))
 +  if (!(sock = mysql_connect(&mysql,db_host,db_user,db_passwd)))
 +  {
 +    return SASL_FAIL;
 +  }
 +
 +  if (mysql_select_db(sock,db_database) < 0)
 +  {
 +    mysql_close(sock);
 +    return SASL_FAIL;
 +  }
 +  /* select DB_UIDCOL from DB_TABLE where DB_UIDCOL = 'userid' AND DB_PWCOL
 = password('password') [ further stuff ]*/
 +
 +
 sprintf(qbuf,QUERY_STRING,db_uidcol,db_table,db_uidcol,userid,db_pwcol,passw
 ord,sqlappend);
 +    if (mysql_query(sock,qbuf) < 0 || !(result=mysql_store_result(sock)))
 +    {
 +      mysql_close(sock);
 +      return SASL_FAIL;
 +    }
 +
 +   if (result) //There were some rows found
 +   {
 +           numrows = mysql_affected_rows(&mysql);
 +           if (numrows > 1) // dupes !!
 +           {
 +                   mysql_free_result(result);
 +                   mysql_close(sock);
 +                   return SASL_BADAUTH;
 +           }
 +
 +           if (numrows == 0) {
 +                   mysql_free_result(result);
 +                   mysql_close(sock);
 +                   return SASL_BADAUTH;
 +           }
 +
 +           if (numrows == 1) {
 +                   mysql_free_result(result);
 +                   mysql_close(sock);
 +                   return SASL_OK; }
 +   }
 +  mysql_free_result(result);
 +  mysql_close(sock);
 +  return SASL_BADAUTH;
 +}
 +#endif
 +
  struct sasl_verify_password_s _sasl_verify_password[] = {
      { "sasldb", &sasldb_verify_password },
 +#ifdef HAVE_MYSQL
 +    { "mysql", &mysql_verify_password },
 +#endif
  #ifdef HAVE_KRB
 \end{WindowsClipboard}
 
 Павел
 --- ifmail v.2.15dev5
  * Origin: Demos online service (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 SASL MySQL Patch   Pavel Vorotilin   09 Feb 2003 16:19:35 
 Re: SASL MySQL Patch   Ivan Beriozko   09 Feb 2003 21:32:30 
 SASL MySQL Patch   Anton Panyushkin   10 Feb 2003 22:43:55 
 SASL MySQL Patch   Alexander Lunyov   11 Feb 2003 09:49:01 
 SASL MySQL Patch   Anton Panyushkin   11 Feb 2003 19:55:19 
 SASL MySQL Patch   Alexander Lunyov   12 Feb 2003 16:00:38 
 SASL MySQL Patch   Vladimir Kurtukov   13 Feb 2003 18:48:00 
 Re: SASL MySQL Patch   Konstantin Nikonenko   13 Feb 2003 14:30:10 
 SASL MySQL Patch   Alexander Lunyov   13 Feb 2003 17:51:47 
 SASL MySQL Patch   Vladimir Kurtukov   13 Feb 2003 23:46:48 
 SASL MySQL Patch   Alexander Lunyov   13 Feb 2003 23:46:53 
 SASL MySQL Patch   Vladimir Kurtukov   14 Feb 2003 15:14:11 
 SASL MySQL Patch   Alexander Lunyov   14 Feb 2003 15:56:42 
 Re: SASL MySQL Patch   Konstantin Nikonenko   14 Feb 2003 10:07:29 
 SASL MySQL Patch   Vladimir Kurtukov   14 Feb 2003 15:39:59 
 SASL MySQL Patch   Anton Panyushkin   13 Feb 2003 21:42:28 
 Re: SASL MySQL Patch   Ivan Beriozko   10 Feb 2003 00:28:22 
 Re: SASL MySQL Patch   Pavel Vorotilin   11 Feb 2003 00:29:26 
 Re: SASL MySQL Patch   Pavel Vorotilin   11 Feb 2003 00:35:44 
 SASL MySQL Patch   Vladimir Kurtukov   10 Feb 2003 13:58:18 
 SASL MySQL Patch   Alexander Lunyov   10 Feb 2003 10:48:05 
Архивное /ru.unix.bsd/6577ec284a9e.html, оценка 1 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional