Browse code

auth_db: option to skip checking version table

- new parameter 'version_table' to be able to disable checking for
version table
- useful when connecting to a different database to fetch the password

Daniel-Constantin Mierla authored on 24/06/2011 18:46:11
Showing 1 changed files
... ...
@@ -93,6 +93,7 @@ str domain_column           = {DOMAIN_COL, DOMAIN_COL_LEN};
93 93
 str pass_column             = {PASS_COL, PASS_COL_LEN};
94 94
 str pass_column_2           = {PASS_COL_2, PASS_COL_2_LEN};
95 95
 
96
+static int version_table_check = 1;
96 97
 
97 98
 int calc_ha1                = 0;
98 99
 int use_domain              = 0; /* Use also domain when looking up in table */
... ...
@@ -127,14 +128,15 @@ static cmd_export_t cmds[] = {
127 128
  * Exported parameters
128 129
  */
129 130
 static param_export_t params[] = {
130
-	{"db_url",            STR_PARAM, &db_url.s           },
131
-	{"user_column",       STR_PARAM, &user_column.s      },
132
-	{"domain_column",     STR_PARAM, &domain_column.s    },
133
-	{"password_column",   STR_PARAM, &pass_column.s      },
134
-	{"password_column_2", STR_PARAM, &pass_column_2.s    },
135
-	{"calculate_ha1",     INT_PARAM, &calc_ha1           },
136
-	{"use_domain",        INT_PARAM, &use_domain         },
137
-	{"load_credentials",  STR_PARAM, &credentials_list   },
131
+	{"db_url",            STR_PARAM, &db_url.s            },
132
+	{"user_column",       STR_PARAM, &user_column.s       },
133
+	{"domain_column",     STR_PARAM, &domain_column.s     },
134
+	{"password_column",   STR_PARAM, &pass_column.s       },
135
+	{"password_column_2", STR_PARAM, &pass_column_2.s     },
136
+	{"calculate_ha1",     INT_PARAM, &calc_ha1            },
137
+	{"use_domain",        INT_PARAM, &use_domain          },
138
+	{"load_credentials",  STR_PARAM, &credentials_list    },
139
+	{"version_table",     INT_PARAM, &version_table_check },
138 140
 	{0, 0, 0}
139 141
 };
140 142
 
... ...
@@ -250,7 +252,9 @@ static int auth_fixup(void** param, int param_no)
250 252
 			LM_ERR("unable to open database connection\n");
251 253
 			return -1;
252 254
 		}
253
-		if(db_check_table_version(&auth_dbf, dbh, &name, TABLE_VERSION) < 0) {
255
+		if(version_table_check!=0
256
+				&& db_check_table_version(&auth_dbf, dbh, &name,
257
+					TABLE_VERSION) < 0) {
254 258
 			LM_ERR("error during table version check.\n");
255 259
 			auth_dbf.close(dbh);
256 260
 			return -1;