add postgresql flavour; submitted by Maurice Nonnekes

This commit is contained in:
jakob 2002-09-13 23:06:06 +00:00
parent 1fa550c3ca
commit 6b4e44c1c1
6 changed files with 131 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.29 2002/06/11 07:48:38 jakob Exp $
# $OpenBSD: Makefile,v 1.30 2002/09/13 23:06:06 jakob Exp $
COMMENT= "Open source LDAP software (client)"
COMMENT-server= "Open source LDAP software (server)"
@ -8,7 +8,6 @@ DISTNAME= openldap-${VERSION}
FULLPKGNAME= openldap-client-${VERSION}
PKGNAME-server= openldap-server-${VERSION}
CATEGORIES= databases net
NEED_VERSION= 1.500
HOMEPAGE= http://www.openldap.org/
@ -57,7 +56,7 @@ MODGNU_CONFIG_GUESS_DIRS= ${WRKSRC} ${WRKSRC}/build
PATCH_LIST= gcc-* patch-*
.endif
FLAVORS= sasl
FLAVORS= sasl pgsql
FLAVOR?=
MULTI_PACKAGES= -server
@ -66,14 +65,24 @@ SUBPACKAGE?=
.if ${FLAVOR:L} == "sasl"
CONFIGURE_ARGS+= --with-cyrus-sasl \
--enable-spasswd
CONFIGURE_ENV+= CPPFLAGS="-I${LOCALBASE}/include/sasl" \
LDFLAGS="-L${LOCALBASE}/lib" LIBS="-lkrb"
LIB_DEPENDS+= sasl::security/cyrus-sasl
CPPFLAGS+= -I${LOCALBASE}/include/sasl
LIBS+= -lkrb
.else
CONFIGURE_ARGS+= --without-cyrus-sasl \
--disable-spasswd
.endif
.if ${FLAVOR:L} == "pgsql"
CONFIGURE_ARGS+= --enable-sql
BUILD_DEPENDS+= :postgresql-*-odbc:databases/postgresql,odbc
CPPFLAGS+= -I${LOCALBASE}/include
.endif
CONFIGURE_ENV+= CPPFLAGS="${CPPFLAGS}" \
LDFLAGS="-L${LOCALBASE}/lib" \
LIBS="${LIBS}"
.if ${SUBPACKAGE} == "-server"
RUN_DEPENDS= openldap:openldap-client-${VERSION}:databases/openldap
.endif

View File

@ -0,0 +1,11 @@
--- servers/slapd/back-sql/back-sql.h.orig Fri Sep 13 13:58:53 2002
+++ servers/slapd/back-sql/back-sql.h Fri Sep 13 13:59:18 2002
@@ -25,7 +25,7 @@
//SQL condition for subtree searches differs in syntax:
//"LIKE CONCAT('%',?)" or "LIKE '%'+?" or smth else
char *subtree_cond;
- char *oc_query,*at_query;
+ char *oc_query,*at_query,*oc_cast,*id_notbyref;
char *insentry_query,*delentry_query;
char *id_query;
char *upper_func;

View File

@ -0,0 +1,38 @@
--- servers/slapd/back-sql/config.c.orig Fri Sep 13 13:59:42 2002
+++ servers/slapd/back-sql/config.c Fri Sep 13 14:07:55 2002
@@ -178,6 +178,35 @@
}
return(0);
}
+
+ if (!strcasecmp(argv[0],"oc_cast"))
+ {
+ if (argc<2)
+ {
+ Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing function name in directive\n",
+ fname,lineno,0);
+ }
+ else
+ {
+ si->oc_cast=ch_strdup(argv[1]);
+ Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): =%s\n",si->oc_cast,0,0);
+ }
+ return(0);
+ }
+ if (!strcasecmp(argv[0],"id_notbyref"))
+ {
+ if (argc<2)
+ {
+ Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): missing function name in directive\n",
+ fname,lineno,0);
+ }
+ else
+ {
+ si->id_notbyref=ch_strdup(argv[1]);
+ Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config(): =%s\n",si->id_notbyref,0,0);
+ }
+ return(0);
+ }
Debug(LDAP_DEBUG_TRACE,"<==backsql_db_config (%s line %d): unknown directive '%s' (ignored)\n",
fname,lineno,argv[0]);

View File

@ -0,0 +1,11 @@
--- servers/slapd/back-sql/entry-id.c.orig Fri Sep 13 14:12:02 2002
+++ servers/slapd/back-sql/entry-id.c Fri Sep 13 14:13:50 2002
@@ -119,7 +119,7 @@
{
if (row.is_null[i]>0)
{
- backsql_entry_addattr(bsi->e,row.col_names[i],row.cols[i],/*row.col_prec[i]*/
+ backsql_entry_addattr(bsi->e,at->name,row.cols[i],/*row.col_prec[i]*/
strlen(row.cols[i]));
// Debug(LDAP_DEBUG_TRACE,"prec=%d\n",(int)row.col_prec[i],0,0);
}

View File

@ -0,0 +1,31 @@
--- servers/slapd/back-sql/modify.c.orig Fri Sep 13 14:14:04 2002
+++ servers/slapd/back-sql/modify.c Fri Sep 13 14:16:04 2002
@@ -362,6 +362,7 @@
char *pdn;
int pno,po;//first parameter no, parameter order
int prc; //procedure return code
+ BACKSQL_ROW_NTS row;
Debug(LDAP_DEBUG_TRACE,"==>backsql_add(): adding entry '%s'\n",e->e_dn,0,0);
if (dn_validate(e->e_dn)==NULL)
@@ -412,6 +413,20 @@
send_ldap_result(conn,op,LDAP_OTHER,"","SQL-backend error",NULL,NULL);
return 1;
}
+
+ if (bi->id_notbyref)
+ {
+ backsql_BindRowAsStrings(sth,&row);
+ while ((rc=SQLFetch(sth)) == SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO)
+ {
+ for (i=0;i<row.ncols;i++)
+ {
+ new_keyval=atoi(row.cols[i]);
+ }
+ }
+ backsql_FreeRow(&row);
+ }
+
SQLFreeStmt(sth,SQL_RESET_PARAMS);
Debug(LDAP_DEBUG_TRACE,"backsql_add(): create_proc returned keyval=%d\n",new_keyval,0,0);

View File

@ -0,0 +1,26 @@
--- servers/slapd/back-sql/search.c.orig Fri Sep 13 14:08:05 2002
+++ servers/slapd/back-sql/search.c Fri Sep 13 14:11:43 2002
@@ -283,11 +283,18 @@
bsi->flt_where=NULL;
bsi->sel_len=bsi->from_len=bsi->jwhere_len=bsi->fwhere_len=0;
- bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,
- "SELECT DISTINCT ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
- ", '",bsi->oc->name,"' AS objectClass",
- ", ldap_entries.dn AS dn",
- NULL);
+ if (bsi->bi->oc_cast) {
+ bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,
+ "SELECT DISTINCT ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
+ ", ", bsi->bi->oc_cast, "('",bsi->oc->name,"') AS objectClass",
+ ", ldap_entries.dn AS dn", NULL);
+ } else {
+ bsi->sel=backsql_strcat(bsi->sel,&bsi->sel_len,
+ "SELECT DISTINCT ldap_entries.id,",bsi->oc->keytbl,".",bsi->oc->keycol,
+ ", '",bsi->oc->name,"' AS objectClass",
+ ", ldap_entries.dn AS dn", NULL);
+ }
+
bsi->from=backsql_strcat(bsi->from,&bsi->from_len," FROM ldap_entries,",bsi->oc->keytbl,NULL);
bsi->join_where=backsql_strcat(bsi->join_where,&bsi->jwhere_len," WHERE ",
bsi->oc->keytbl,".",bsi->oc->keycol,"=ldap_entries.keyval AND ",