Subject: Bug#563340: Updated patch to honor the sql_defaultrealm option also in method sql_auxprop_store.

From: Christian Schulte <[email-masked]>
Date: Sat, 02 Jan 2010 06:35:22 +0100

#! /bin/sh /usr/share/dpatch/dpatch-run
## 0024_add_sql_defaultrealm_option.dpatch by  Christian Schulte <[email-masked]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: A patch adding an sql_defaultrealm option.

@DPATCH@

--- cyrus-sasl2_2.1.23.dfsg1.orig/plugins/sql.c	2009-04-28 17:09:17.000000000 +0200
+++ cyrus-sasl2_2.1.23.dfsg1/plugins/sql.c	2010-01-02 06:24:12.000000000 +0100
@@ -53,6 +53,7 @@
     const char *sql_select;
     const char *sql_insert;
     const char *sql_update;
+    const char *sql_defaultrealm;
     int sql_usessl;
 } sql_settings_t;
 
@@ -677,6 +678,12 @@
 	settings->sql_update = SQL_BLANK_STRING;
     }
 
+    r = utils->getopt(utils->getopt_context, "SQL", "sql_defaultrealm",
+		       &settings->sql_defaultrealm, NULL);
+    if(r || !settings->sql_defaultrealm) {
+	settings->sql_defaultrealm = NULL;
+    }
+
     r = utils->getopt(utils->getopt_context, "SQL", "sql_usessl",
 		  &usessl, NULL);
     if (r || !usessl) usessl = "no";
@@ -781,6 +788,8 @@
     
     if(sparams->user_realm) {
 	user_realm = sparams->user_realm;
+    } else if(settings->sql_defaultrealm) {
+        user_realm = settings->sql_defaultrealm;
     } else {
 	user_realm = sparams->serverFQDN;
     }
@@ -933,8 +942,9 @@
     
     if (sparams->user_realm) {
 	user_realm = sparams->user_realm;
-    }
-    else {
+    } else if(settings->sql_defaultrealm) {
+        user_realm = settings->sql_defaultrealm;
+    } else {
 	user_realm = sparams->serverFQDN;
     }