Browse code

use_domain parameter added

Jan Janak authored on 23/06/2003 10:46:59
Showing 3 changed files
... ...
@@ -86,6 +86,7 @@ char* domain_column    = "domain";
86 86
 char* pass_column      = "ha1";
87 87
 char* pass_column_2    = "ha1b";
88 88
 int   calc_ha1         = 0;
89
+int   use_domain       = 1;    /* Use also domain when looking up a table row */
89 90
 
90 91
 db_con_t* db_handle;   /* Database connection handle */
91 92
 
... ...
@@ -110,6 +111,7 @@ static param_export_t params[] = {
110 111
 	{"password_column",   STR_PARAM, &pass_column  },
111 112
 	{"password_column_2", STR_PARAM, &pass_column_2},
112 113
 	{"calculate_ha1",     INT_PARAM, &calc_ha1     },
114
+	{"use_domain",        INT_PARAM, &use_domain   },
113 115
 	{0, 0, 0}
114 116
 };
115 117
 
... ...
@@ -49,6 +49,7 @@ extern char* pass_column_2;   /* Column containg HA1 string constructed
49 49
 			       */
50 50
 
51 51
 extern int calc_ha1;          /* if set to 1, ha1 is calculated by the server */
52
+extern int use_domain;        /* If set to 1 then the domain will be used when selecting a row */
52 53
 extern db_con_t* db_handle;   /* Database connection handle */
53 54
 
54 55
 extern pre_auth_f pre_auth_func;
... ...
@@ -69,14 +69,14 @@ static inline int get_ha1(str* _user, str* _domain, int use_ha1b, char* _table,
69 69
 	VAL_STR(vals + 1).len = _domain->len;
70 70
 
71 71
 	db_use_table(db_handle, _table);
72
-	if (db_query(db_handle, keys, 0, vals, col, 2, 1, 0, &res) < 0) {
72
+	if (db_query(db_handle, keys, 0, vals, col, (use_domain ? 2 : 1), 1, 0, &res) < 0) {
73 73
 		LOG(L_ERR, "get_ha1(): Error while querying database\n");
74 74
 		return -1;
75 75
 	}
76 76
 
77 77
 	if (RES_ROW_N(res) == 0) {
78 78
 		DBG("get_ha1(): no result for user \'%.*s@%.*s\'\n", 
79
-		    _user->len, ZSW(_user->s), _domain->len, ZSW(_domain->s));
79
+		    _user->len, ZSW(_user->s), (use_domain ? (_domain->len) : 0), ZSW(_domain->s));
80 80
 		db_free_query(db_handle, res);
81 81
 		return 1;
82 82
 	}