Hi all,
In case any of you want to use a postgresql backend, here is a patch
that fixes some typos that get in the way of compilation and adds
support for valias.
I have not tried 5.5.0 but I suspect that it will apply to vpgsql.c if
in the backends/postgresql dir and using 'patch -p1'.
diff -urN vpopmail-5.4.30/vpgsql.c vpopmail-5.4.30-pgsqlfixed/vpgsql.c
--- vpopmail-5.4.30/vpgsql.c 2010-06-19 20:12:30.991542810 +0800
+++ vpopmail-5.4.30-pgsqlfixed/vpgsql.c 2010-06-19 20:15:34.056278658
+0800
@@ -392,10 +392,10 @@
#endif
#ifdef ENABLE_SQL_LOGGING
- qnprintf( sqlBufUpdate, SQL_BUF_SIZE,
+ qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
"delete from vlog where domain = '%s'", domain );
pgres=PQexec(pgc, SqlBufUpdate);
- if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {
+ if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {
return(-1);
}
#endif
@@ -445,11 +445,11 @@
#endif
#ifdef ENABLE_SQL_LOGGING
- qnprintf( sqlBufUpdate, SQL_BUF_SIZE,
+ qnprintf( SqlBufUpdate, SQL_BUF_SIZE,
"delete from vlog where domain = '%s' and user='%s'",
domain, user );
pgres=PQexec(pgc, SqlBufUpdate);
- if( !pgres || PGresultStatus(pgres)!=PGRES_COMMAND_OK) {
+ if( !pgres || PQresultStatus(pgres)!=PGRES_COMMAND_OK) {
err = -1;
}
#endif
@@ -1614,3 +1614,69 @@
return(strcmp(crypt(clear_pass,vpw->pw_passwd),vpw->pw_passwd));
}
+char *valias_select_names( char *alias, char *domain )
+{
+ PGresult *pgvalias;
+ int err, verrori;
+ unsigned ntuples, ctuple;
+ struct linklist *temp_entry = NULL;
+
+ /* remove old entries as necessary */
+ while (valias_current != NULL)
+ valias_current = linklist_del (valias_current);
+
+ if ( (err=vauth_open(0)) != 0 ) {
+ verrori = err;
+ return(NULL);
+ }
+
+ qnprintf( SqlBufRead, SQL_BUF_SIZE,
+ "select distinct alias from valias where domain = '%s'
order by alias",
+ domain );
+ if ( ! (pgvalias=PQexec(pgc, SqlBufRead))
+ || PQresultStatus(pgvalias) != PGRES_TUPLES_OK ) {
+ if(pgvalias) PQclear(pgvalias);
+ vcreate_valias_table();
+ if ( ! (pgvalias=PQexec(pgc, SqlBufRead))
+ || PQresultStatus(pgvalias) != PGRES_TUPLES_OK ) {
+ fprintf(stderr,"vpgsql: sql error[j]: %s\n",
+ PQerrorMessage(pgc));
+ if (pgvalias) PQclear(pgvalias);
+ return(NULL);
+ }
+ }
+
+ ntuples = PQntuples (pgvalias);
+ for (ctuple = 0; ctuple < ntuples; ctuple++) {
+ temp_entry = linklist_add (temp_entry, PQgetvalue (pgvalias,
ctuple, 1),
+PQgetvalue (pgvalias, ctuple, 0));
+ if (valias_current == NULL) valias_current = temp_entry;
+ }
+ PQclear (pgvalias);
+ pgvalias = NULL;
+
+ if (valias_current == NULL) return NULL; /* no results */
+ else {
+ strcpy (alias, valias_current->d2);
+ return(valias_current->data);
+ }
+}
+
+char *valias_select_names_next(char *alias)
+{
+ if (valias_current == NULL) return NULL;
+
+ valias_current = linklist_del (valias_current);
+
+ if (valias_current == NULL) return NULL;
+ else {
+ strcpy (alias, valias_current->d2);
+ return valias_current->data;
+ }
+}
+
+void valias_select_names_end() {
+
+// not needed by pgsql
+
+}
!DSPAM:4c1cc3c832711198718232!