Tue, 29 Mar 2011 20:04:34 +0200
Rework package yet again, correcting and introducing new buildconf logic:
Conditionally disable bootstrap stage comparison correctly, correct
english grammar, better find system as(1) and ld(1), indotruce detailed
optimization option messages, more completely guess cpu types, allow
profiled bootstrapping without a preinstalled GCC because many other
compilers have long since implemented 64-bit arithmetic, instruct make
to build sequentially (not in sparallel) when building a profiled
bootstrap as GCC online documents recommend, and generally improve
comment blocks.
The single most important correction in this changeset relates to the
GCC changed optimization policy since at least GCC 4.5, in which -march
is always passed and not always correctly guessed. In the case of this
package, allowing GCC to guess the architecture leads to wild build
errors at various subcomponents (zlib, libgcc, libiberty...) and
bootstrap stages. It seems quite platform specific, and the safest
approach to correcting this seems to be explicitly always specifying the
-march argument when bootstrapping GCC. Because the best choice 'native'
is not available when bootstrapping using a foreign (non GCC) compiler,
a guess is made according to rpmmacros l_platform in that case.
It is questionable as to whether these recent optimization changes
on the part of GCC or this package are compatible with each other,
or if either are complete or correct at all. At least applying these
corrections allows this package to build again in most cases test.
michael@144 | 1 | Index: configure |
michael@144 | 2 | --- configure.orig 2006-05-18 21:30:13 +0200 |
michael@144 | 3 | +++ configure 2008-12-25 18:48:51 +0100 |
michael@144 | 4 | @@ -3944,9 +3944,6 @@ |
michael@144 | 5 | |
michael@144 | 6 | fi |
michael@144 | 7 | |
michael@144 | 8 | -if test "$ac_cv_c_compiler_gnu" = yes; then |
michael@144 | 9 | - CFLAGS="-Wall -W ${CFLAGS}" |
michael@144 | 10 | -fi |
michael@144 | 11 | |
michael@144 | 12 | |
michael@144 | 13 | # Check whether --with-purecov or --without-purecov was given. |
michael@144 | 14 | @@ -5125,7 +5122,7 @@ |
michael@144 | 15 | fi |
michael@144 | 16 | |
michael@144 | 17 | saved_LIBS=$LIBS |
michael@144 | 18 | - for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db |
michael@144 | 19 | + for dbname in db |
michael@144 | 20 | do |
michael@144 | 21 | LIBS="$saved_LIBS -l$dbname" |
michael@144 | 22 | cat >conftest.$ac_ext <<_ACEOF |
michael@144 | 23 | @@ -5205,6 +5202,54 @@ |
michael@144 | 24 | fi |
michael@144 | 25 | rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext |
michael@144 | 26 | fi |
michael@144 | 27 | + if test "$dblib" = "no"; then |
michael@144 | 28 | + cat >conftest.$ac_ext <<_ACEOF |
michael@144 | 29 | +/* confdefs.h. */ |
michael@144 | 30 | +_ACEOF |
michael@144 | 31 | +cat confdefs.h >>conftest.$ac_ext |
michael@144 | 32 | +cat >>conftest.$ac_ext <<_ACEOF |
michael@144 | 33 | +/* end confdefs.h. */ |
michael@144 | 34 | +#include <db.h> |
michael@144 | 35 | +int |
michael@144 | 36 | +main () |
michael@144 | 37 | +{ |
michael@144 | 38 | +dbm_open(NULL, 0, 0, 0, NULL, NULL, NULL); |
michael@144 | 39 | + ; |
michael@144 | 40 | + return 0; |
michael@144 | 41 | +} |
michael@144 | 42 | +_ACEOF |
michael@144 | 43 | +rm -f conftest.$ac_objext conftest$ac_exeext |
michael@144 | 44 | +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 |
michael@144 | 45 | + (eval $ac_link) 2>conftest.er1 |
michael@144 | 46 | + ac_status=$? |
michael@144 | 47 | + grep -v '^ *+' conftest.er1 >conftest.err |
michael@144 | 48 | + rm -f conftest.er1 |
michael@144 | 49 | + cat conftest.err >&5 |
michael@144 | 50 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 51 | + (exit $ac_status); } && |
michael@144 | 52 | + { ac_try='test -z "$ac_c_werror_flag" |
michael@144 | 53 | + || test ! -s conftest.err' |
michael@144 | 54 | + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 |
michael@144 | 55 | + (eval $ac_try) 2>&5 |
michael@144 | 56 | + ac_status=$? |
michael@144 | 57 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 58 | + (exit $ac_status); }; } && |
michael@144 | 59 | + { ac_try='test -s conftest$ac_exeext' |
michael@144 | 60 | + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 |
michael@144 | 61 | + (eval $ac_try) 2>&5 |
michael@144 | 62 | + ac_status=$? |
michael@144 | 63 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 64 | + (exit $ac_status); }; }; then |
michael@144 | 65 | + BDB_LIBADD="$BDB_LIBADD -ldb"; dblib="berkeley"; dbname=db |
michael@144 | 66 | +else |
michael@144 | 67 | + echo "$as_me: failed program was:" >&5 |
michael@144 | 68 | +sed 's/^/| /' conftest.$ac_ext >&5 |
michael@144 | 69 | + |
michael@144 | 70 | +dblib="no" |
michael@144 | 71 | +fi |
michael@144 | 72 | +rm -f conftest.err conftest.$ac_objext \ |
michael@144 | 73 | + conftest$ac_exeext conftest.$ac_ext |
michael@144 | 74 | + fi |
michael@144 | 75 | LIBS=$saved_LIBS |
michael@144 | 76 | |
michael@144 | 77 | LDFLAGS=$BDB_SAVE_LDFLAGS |
michael@144 | 78 | @@ -5882,7 +5927,7 @@ |
michael@144 | 79 | fi |
michael@144 | 80 | |
michael@144 | 81 | saved_LIBS=$LIBS |
michael@144 | 82 | - for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db-3.3 db3.3 db33 db-3.2 db3.2 db32 db-3.1 db3.1 db31 db-3 db30 db3 db |
michael@144 | 83 | + for dbname in db |
michael@144 | 84 | do |
michael@144 | 85 | LIBS="$saved_LIBS -l$dbname" |
michael@144 | 86 | cat >conftest.$ac_ext <<_ACEOF |
michael@144 | 87 | @@ -5962,6 +6007,54 @@ |
michael@144 | 88 | fi |
michael@144 | 89 | rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext |
michael@144 | 90 | fi |
michael@144 | 91 | + if test "$dblib" = "no"; then |
michael@144 | 92 | + cat >conftest.$ac_ext <<_ACEOF |
michael@144 | 93 | +/* confdefs.h. */ |
michael@144 | 94 | +_ACEOF |
michael@144 | 95 | +cat confdefs.h >>conftest.$ac_ext |
michael@144 | 96 | +cat >>conftest.$ac_ext <<_ACEOF |
michael@144 | 97 | +/* end confdefs.h. */ |
michael@144 | 98 | +#include <db.h> |
michael@144 | 99 | +int |
michael@144 | 100 | +main () |
michael@144 | 101 | +{ |
michael@144 | 102 | +dbm_open(NULL, 0, 0, 0, NULL, NULL, NULL); |
michael@144 | 103 | + ; |
michael@144 | 104 | + return 0; |
michael@144 | 105 | +} |
michael@144 | 106 | +_ACEOF |
michael@144 | 107 | +rm -f conftest.$ac_objext conftest$ac_exeext |
michael@144 | 108 | +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 |
michael@144 | 109 | + (eval $ac_link) 2>conftest.er1 |
michael@144 | 110 | + ac_status=$? |
michael@144 | 111 | + grep -v '^ *+' conftest.er1 >conftest.err |
michael@144 | 112 | + rm -f conftest.er1 |
michael@144 | 113 | + cat conftest.err >&5 |
michael@144 | 114 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 115 | + (exit $ac_status); } && |
michael@144 | 116 | + { ac_try='test -z "$ac_c_werror_flag" |
michael@144 | 117 | + || test ! -s conftest.err' |
michael@144 | 118 | + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 |
michael@144 | 119 | + (eval $ac_try) 2>&5 |
michael@144 | 120 | + ac_status=$? |
michael@144 | 121 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 122 | + (exit $ac_status); }; } && |
michael@144 | 123 | + { ac_try='test -s conftest$ac_exeext' |
michael@144 | 124 | + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 |
michael@144 | 125 | + (eval $ac_try) 2>&5 |
michael@144 | 126 | + ac_status=$? |
michael@144 | 127 | + echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
michael@144 | 128 | + (exit $ac_status); }; }; then |
michael@144 | 129 | + BDB_LIBADD="$BDB_LIBADD -ldb"; dblib="berkeley"; dbname=db |
michael@144 | 130 | +else |
michael@144 | 131 | + echo "$as_me: failed program was:" >&5 |
michael@144 | 132 | +sed 's/^/| /' conftest.$ac_ext >&5 |
michael@144 | 133 | + |
michael@144 | 134 | +dblib="no" |
michael@144 | 135 | +fi |
michael@144 | 136 | +rm -f conftest.err conftest.$ac_objext \ |
michael@144 | 137 | + conftest$ac_exeext conftest.$ac_ext |
michael@144 | 138 | + fi |
michael@144 | 139 | LIBS=$saved_LIBS |
michael@144 | 140 | |
michael@144 | 141 | LDFLAGS=$BDB_SAVE_LDFLAGS |
michael@144 | 142 | @@ -12005,20 +12098,20 @@ |
michael@144 | 143 | fi |
michael@144 | 144 | |
michael@144 | 145 | LIB_SQLITE_DIR=$LIB_SQLITE |
michael@144 | 146 | - LIB_SQLITE="$LIB_SQLITE -lsqlite" |
michael@144 | 147 | + LIB_SQLITE="$LIB_SQLITE -lsqlite3" |
michael@144 | 148 | |
michael@144 | 149 | if test -d ${with_sqlite}/include; then |
michael@144 | 150 | CPPFLAGS="${CPPFLAGS} -I${with_sqlite}/include" |
michael@144 | 151 | else |
michael@144 | 152 | CPPFLAGS="${CPPFLAGS} -I${with_sqlite}" |
michael@144 | 153 | fi |
michael@144 | 154 | - echo "$as_me:$LINENO: checking for sqlite_open in -lsqlite" >&5 |
michael@144 | 155 | -echo $ECHO_N "checking for sqlite_open in -lsqlite... $ECHO_C" >&6 |
michael@144 | 156 | + echo "$as_me:$LINENO: checking for sqlite3_open in -lsqlite3" >&5 |
michael@144 | 157 | +echo $ECHO_N "checking for sqlite3_open in -lsqlite3... $ECHO_C" >&6 |
michael@144 | 158 | if test "${ac_cv_lib_sqlite_sqlite_open+set}" = set; then |
michael@144 | 159 | echo $ECHO_N "(cached) $ECHO_C" >&6 |
michael@144 | 160 | else |
michael@144 | 161 | ac_check_lib_save_LIBS=$LIBS |
michael@144 | 162 | -LIBS="-lsqlite $LIB_SQLITE_DIR $LIBS" |
michael@144 | 163 | +LIBS="-lsqlite3 $LIB_SQLITE_DIR $LIBS" |
michael@144 | 164 | cat >conftest.$ac_ext <<_ACEOF |
michael@144 | 165 | #line $LINENO "configure" |
michael@144 | 166 | /* confdefs.h. */ |
michael@144 | 167 | @@ -12033,11 +12126,11 @@ |
michael@144 | 168 | #endif |
michael@144 | 169 | /* We use char because int might match the return type of a gcc2 |
michael@144 | 170 | builtin and then its argument prototype would still apply. */ |
michael@144 | 171 | -char sqlite_open (); |
michael@144 | 172 | +char sqlite3_open (); |
michael@144 | 173 | int |
michael@144 | 174 | main () |
michael@144 | 175 | { |
michael@144 | 176 | -sqlite_open (); |
michael@144 | 177 | +sqlite3_open (); |
michael@144 | 178 | ; |
michael@144 | 179 | return 0; |
michael@144 | 180 | } |
michael@144 | 181 | Index: lib/saslint.h |
michael@144 | 182 | --- lib/saslint.h.orig 2006-04-18 22:25:45 +0200 |
michael@144 | 183 | +++ lib/saslint.h 2008-12-25 18:48:51 +0100 |
michael@144 | 184 | @@ -109,8 +109,6 @@ |
michael@144 | 185 | const char *appname; |
michael@144 | 186 | } sasl_global_callbacks_t; |
michael@144 | 187 | |
michael@144 | 188 | -extern sasl_global_callbacks_t global_callbacks; |
michael@144 | 189 | - |
michael@144 | 190 | typedef struct _sasl_external_properties |
michael@144 | 191 | { |
michael@144 | 192 | sasl_ssf_t ssf; |
michael@144 | 193 | Index: lib/server.c |
michael@144 | 194 | --- lib/server.c.orig 2006-05-17 18:46:13 +0200 |
michael@144 | 195 | +++ lib/server.c 2008-12-25 18:48:51 +0100 |
michael@144 | 196 | @@ -95,7 +95,7 @@ |
michael@144 | 197 | |
michael@144 | 198 | static mech_list_t *mechlist = NULL; /* global var which holds the list */ |
michael@144 | 199 | |
michael@144 | 200 | -sasl_global_callbacks_t global_callbacks; |
michael@144 | 201 | +static sasl_global_callbacks_t global_callbacks; |
michael@144 | 202 | |
michael@144 | 203 | /* set the password for a user |
michael@144 | 204 | * conn -- SASL connection |
michael@144 | 205 | @@ -477,16 +477,8 @@ |
michael@144 | 206 | return SASL_CONTINUE; |
michael@144 | 207 | } |
michael@144 | 208 | |
michael@144 | 209 | - /* get the path to the config file */ |
michael@144 | 210 | - getconfpath_cb = _sasl_find_getconfpath_callback( global_callbacks.callbacks ); |
michael@144 | 211 | - if (getconfpath_cb == NULL) return SASL_BADPARAM; |
michael@144 | 212 | - |
michael@144 | 213 | - /* getconfpath_cb->proc MUST be a sasl_getconfpath_t; if only C had a type |
michael@144 | 214 | - system */ |
michael@144 | 215 | - result = ((sasl_getconfpath_t *)(getconfpath_cb->proc))(getconfpath_cb->context, |
michael@144 | 216 | - &path_to_config); |
michael@144 | 217 | - if (result != SASL_OK) goto done; |
michael@144 | 218 | - if (path_to_config == NULL) path_to_config = ""; |
michael@144 | 219 | + result = SASL_OK; |
michael@144 | 220 | + path_to_config = "@l_sysconfdir@"; |
michael@144 | 221 | |
michael@144 | 222 | next = path_to_config; |
michael@144 | 223 | |
michael@144 | 224 | Index: plugins/sql.c |
michael@144 | 225 | --- plugins/sql.c.orig 2006-04-07 15:42:16 +0200 |
michael@144 | 226 | +++ plugins/sql.c 2008-12-25 21:57:47 +0100 |
michael@144 | 227 | @@ -150,9 +150,15 @@ |
michael@144 | 228 | return -1; |
michael@144 | 229 | } |
michael@144 | 230 | if (value) { |
michael@144 | 231 | - strncpy(value, row[0], size-2); |
michael@144 | 232 | - value[size-1] = '\0'; |
michael@144 | 233 | - if (value_len) *value_len = strlen(value); |
michael@144 | 234 | + unsigned long *col_lens; |
michael@144 | 235 | + size_t col_len; |
michael@144 | 236 | + col_lens = mysql_fetch_lengths(result); |
michael@144 | 237 | + col_len = (size_t)col_lens[0]; |
michael@144 | 238 | + if (col_len > size - 1); |
michael@144 | 239 | + col_len = size - 1; |
michael@144 | 240 | + memcpy(value, row[0], col_len); |
michael@144 | 241 | + value[col_len] = '\0'; |
michael@144 | 242 | + if (value_len) *value_len = col_len; |
michael@144 | 243 | } |
michael@144 | 244 | |
michael@144 | 245 | /* free result */ |
michael@144 | 246 | @@ -277,7 +283,7 @@ |
michael@144 | 247 | ExecStatusType status; |
michael@144 | 248 | |
michael@144 | 249 | /* run the query */ |
michael@144 | 250 | - result = PQexec(conn, cmd); |
michael@144 | 251 | + result = PQexecParams(conn, cmd, 0, NULL, NULL, NULL, NULL, 1); |
michael@144 | 252 | |
michael@144 | 253 | /* check the status */ |
michael@144 | 254 | status = PQresultStatus(result); |
michael@144 | 255 | @@ -298,6 +304,7 @@ |
michael@144 | 256 | row_count = PQntuples(result); |
michael@144 | 257 | if (!row_count) { |
michael@144 | 258 | /* umm nothing found */ |
michael@144 | 259 | + utils->log(NULL, SASL_LOG_DEBUG, "sql plugin: no result found for query %s", cmd); |
michael@144 | 260 | utils->log(NULL, SASL_LOG_NOTE, "sql plugin: no result found"); |
michael@144 | 261 | PQclear(result); |
michael@144 | 262 | return -1; |
michael@144 | 263 | @@ -310,9 +317,26 @@ |
michael@144 | 264 | /* now get the result set value and value_len */ |
michael@144 | 265 | /* we only fetch one because we don't care about the rest */ |
michael@144 | 266 | if (value) { |
michael@144 | 267 | - strncpy(value, PQgetvalue(result,0,0), size-2); |
michael@144 | 268 | - value[size-1] = '\0'; |
michael@144 | 269 | - if (value_len) *value_len = strlen(value); |
michael@144 | 270 | + if (PQgetisnull(result, 0, 0)) { |
michael@144 | 271 | + size_t col_len; |
michael@144 | 272 | + col_len = strlen(SQL_NULL_VALUE); |
michael@144 | 273 | + if (col_len > size - 1) |
michael@144 | 274 | + col_len = size - 1; |
michael@144 | 275 | + memcpy(value, SQL_NULL_VALUE, col_len); |
michael@144 | 276 | + value[col_len] = '\0'; |
michael@144 | 277 | + if (value_len) |
michael@144 | 278 | + *value_len = col_len; |
michael@144 | 279 | + } |
michael@144 | 280 | + else { |
michael@144 | 281 | + size_t col_len; |
michael@144 | 282 | + col_len = (size_t)PQgetlength(result, 0, 0); |
michael@144 | 283 | + if (col_len > size - 1); |
michael@144 | 284 | + col_len = size - 1; |
michael@144 | 285 | + memcpy(value, PQgetvalue(result, 0, 0), col_len); |
michael@144 | 286 | + value[col_len] = '\0'; |
michael@144 | 287 | + if (value_len) |
michael@144 | 288 | + *value_len = col_len; |
michael@144 | 289 | + } |
michael@144 | 290 | } |
michael@144 | 291 | |
michael@144 | 292 | /* free result */ |
michael@144 | 293 | @@ -342,7 +366,7 @@ |
michael@144 | 294 | #endif /* HAVE_PGSQL */ |
michael@144 | 295 | |
michael@144 | 296 | #ifdef HAVE_SQLITE |
michael@144 | 297 | -#include <sqlite.h> |
michael@144 | 298 | +#include <sqlite3.h> |
michael@144 | 299 | |
michael@144 | 300 | static void *_sqlite_open(char *host __attribute__((unused)), |
michael@144 | 301 | char *port __attribute__((unused)), |
michael@144 | 302 | @@ -352,21 +376,23 @@ |
michael@144 | 303 | const char *database, const sasl_utils_t *utils) |
michael@144 | 304 | { |
michael@144 | 305 | int rc; |
michael@144 | 306 | - sqlite *db; |
michael@144 | 307 | + sqlite3 *db; |
michael@144 | 308 | char *zErrMsg = NULL; |
michael@144 | 309 | |
michael@144 | 310 | - db = sqlite_open(database, 0, &zErrMsg); |
michael@144 | 311 | - if (db == NULL) { |
michael@144 | 312 | + rc = sqlite3_open(database, &db); |
michael@144 | 313 | + if (rc != SQLITE_OK) { |
michael@144 | 314 | + zErrMsg = (char *)sqlite3_errmsg(db); |
michael@144 | 315 | utils->log(NULL, SASL_LOG_ERR, "sql plugin: %s", zErrMsg); |
michael@144 | 316 | - sqlite_freemem (zErrMsg); |
michael@144 | 317 | + sqlite3_free (zErrMsg); |
michael@144 | 318 | + sqlite3_close (db); |
michael@144 | 319 | return NULL; |
michael@144 | 320 | } |
michael@144 | 321 | |
michael@144 | 322 | - rc = sqlite_exec(db, "PRAGMA empty_result_callbacks = ON", NULL, NULL, &zErrMsg); |
michael@144 | 323 | + rc = sqlite3_exec(db, "PRAGMA empty_result_callbacks = ON", NULL, NULL, &zErrMsg); |
michael@144 | 324 | if (rc != SQLITE_OK) { |
michael@144 | 325 | utils->log(NULL, SASL_LOG_ERR, "sql plugin: %s", zErrMsg); |
michael@144 | 326 | - sqlite_freemem (zErrMsg); |
michael@144 | 327 | - sqlite_close(db); |
michael@144 | 328 | + sqlite3_free (zErrMsg); |
michael@144 | 329 | + sqlite3_close(db); |
michael@144 | 330 | return NULL; |
michael@144 | 331 | } |
michael@144 | 332 | |
michael@144 | 333 | @@ -388,62 +414,67 @@ |
michael@144 | 334 | return 0; |
michael@144 | 335 | } |
michael@144 | 336 | |
michael@144 | 337 | -static int sqlite_my_callback(void *pArg, int argc __attribute__((unused)), |
michael@144 | 338 | - char **argv, |
michael@144 | 339 | - char **columnNames __attribute__((unused))) |
michael@144 | 340 | -{ |
michael@144 | 341 | - char **result = (char**)pArg; |
michael@144 | 342 | - |
michael@144 | 343 | - if (argv == NULL) { |
michael@144 | 344 | - *result = NULL; /* no record */ |
michael@144 | 345 | - } else if (argv[0] == NULL) { |
michael@144 | 346 | - *result = strdup(SQL_NULL_VALUE); /* NULL IS SQL_NULL_VALUE */ |
michael@144 | 347 | - } else { |
michael@144 | 348 | - *result = strdup(argv[0]); |
michael@144 | 349 | - } |
michael@144 | 350 | - |
michael@144 | 351 | - return /*ABORT*/1; |
michael@144 | 352 | -} |
michael@144 | 353 | - |
michael@144 | 354 | static int _sqlite_exec(void *db, const char *cmd, char *value, size_t size, |
michael@144 | 355 | size_t *value_len, const sasl_utils_t *utils) |
michael@144 | 356 | { |
michael@144 | 357 | int rc; |
michael@144 | 358 | - char *result = NULL; |
michael@144 | 359 | - char *zErrMsg = NULL; |
michael@144 | 360 | + sqlite3_stmt *stmt; |
michael@144 | 361 | + const char *todo; |
michael@144 | 362 | + size_t len; |
michael@144 | 363 | |
michael@144 | 364 | - rc = sqlite_exec((sqlite*)db, cmd, sqlite_my_callback, (void*)&result, &zErrMsg); |
michael@144 | 365 | - if (rc != SQLITE_OK && rc != SQLITE_ABORT) { |
michael@144 | 366 | - utils->log(NULL, SASL_LOG_DEBUG, "sql plugin: %s ", zErrMsg); |
michael@144 | 367 | - sqlite_freemem (zErrMsg); |
michael@144 | 368 | + rc = sqlite3_prepare((sqlite3*)db, cmd, (int)strlen(cmd), &stmt, &todo); |
michael@144 | 369 | + if (rc != SQLITE_OK) { |
michael@144 | 370 | + utils->log(NULL, SASL_LOG_DEBUG, "sql plugin error: %s", sqlite3_errmsg((sqlite3*)db)); |
michael@144 | 371 | return -1; |
michael@144 | 372 | } |
michael@144 | 373 | - |
michael@144 | 374 | - if (rc == SQLITE_OK) { |
michael@144 | 375 | + rc = sqlite3_step(stmt); |
michael@144 | 376 | + if (rc != SQLITE_ROW && rc != SQLITE_DONE) { |
michael@144 | 377 | + utils->log(NULL, SASL_LOG_DEBUG, "sql plugin error: %s", sqlite3_errmsg((sqlite3*)db)); |
michael@144 | 378 | + sqlite3_finalize(stmt); |
michael@144 | 379 | + return -1; |
michael@144 | 380 | + } |
michael@144 | 381 | + if (sqlite3_column_count(stmt) == 0) { |
michael@144 | 382 | /* no results (BEGIN, COMMIT, DELETE, INSERT, UPDATE) */ |
michael@144 | 383 | + sqlite3_finalize(stmt); |
michael@144 | 384 | return 0; |
michael@144 | 385 | } |
michael@144 | 386 | - |
michael@144 | 387 | - if (result == NULL) { |
michael@144 | 388 | + if (rc == SQLITE_DONE) { |
michael@144 | 389 | /* umm nothing found */ |
michael@144 | 390 | + utils->log(NULL, SASL_LOG_DEBUG, "sql plugin: no result found for query %s", cmd); |
michael@144 | 391 | utils->log(NULL, SASL_LOG_NOTE, "sql plugin: no result found"); |
michael@144 | 392 | + sqlite3_finalize(stmt); |
michael@144 | 393 | return -1; |
michael@144 | 394 | } |
michael@144 | 395 | - |
michael@144 | 396 | - /* XXX: Duplication cannot be found by this method. */ |
michael@144 | 397 | - |
michael@144 | 398 | - /* now get the result set value and value_len */ |
michael@144 | 399 | - /* we only fetch one because we don't care about the rest */ |
michael@144 | 400 | - if (value) { |
michael@144 | 401 | - strncpy(value, result, size - 2); |
michael@144 | 402 | - value[size - 1] = '\0'; |
michael@144 | 403 | - if (value_len) { |
michael@144 | 404 | - *value_len = strlen(value); |
michael@144 | 405 | - } |
michael@144 | 406 | + rc = sqlite3_column_type(stmt, 0); |
michael@144 | 407 | + switch (rc) { |
michael@144 | 408 | + case SQLITE_NULL: { |
michael@144 | 409 | + len = strlen(SQL_NULL_VALUE); |
michael@144 | 410 | + if (len > size - 1) |
michael@144 | 411 | + len = size - 1; |
michael@144 | 412 | + memcpy(value, SQL_NULL_VALUE, len); |
michael@144 | 413 | + value[len] = '\0'; |
michael@144 | 414 | + if (value_len) |
michael@144 | 415 | + *value_len = len; |
michael@144 | 416 | + break; |
michael@144 | 417 | + } |
michael@144 | 418 | + default: { |
michael@144 | 419 | + const void *blob = sqlite3_column_blob(stmt, 0); |
michael@144 | 420 | + len = (size_t)sqlite3_column_bytes(stmt, 0); |
michael@144 | 421 | + if (len > size - 1) |
michael@144 | 422 | + len = size - 1; |
michael@144 | 423 | + memcpy(value, blob, len); |
michael@144 | 424 | + value[len] = '\0'; |
michael@144 | 425 | + if (value_len) |
michael@144 | 426 | + *value_len = len; |
michael@144 | 427 | + break; |
michael@144 | 428 | + } |
michael@144 | 429 | } |
michael@144 | 430 | - |
michael@144 | 431 | - /* free result */ |
michael@144 | 432 | - free(result); |
michael@144 | 433 | + rc = sqlite3_step(stmt); |
michael@144 | 434 | + if (rc != SQLITE_DONE) { |
michael@144 | 435 | + utils->log(NULL, SASL_LOG_WARN, |
michael@144 | 436 | + "sql plugin: found duplicate row for query %s", cmd); |
michael@144 | 437 | + } |
michael@144 | 438 | + sqlite3_finalize(stmt); |
michael@144 | 439 | return 0; |
michael@144 | 440 | } |
michael@144 | 441 | |
michael@144 | 442 | @@ -464,7 +495,7 @@ |
michael@144 | 443 | |
michael@144 | 444 | static void _sqlite_close(void *db) |
michael@144 | 445 | { |
michael@144 | 446 | - sqlite_close((sqlite*)db); |
michael@144 | 447 | + sqlite3_close((sqlite3 *)db); |
michael@144 | 448 | } |
michael@144 | 449 | #endif /* HAVE_SQLITE */ |
michael@144 | 450 | |
michael@144 | 451 | @@ -771,7 +802,7 @@ |
michael@144 | 452 | settings = (sql_settings_t *) glob_context; |
michael@144 | 453 | |
michael@144 | 454 | sparams->utils->log(NULL, SASL_LOG_DEBUG, |
michael@144 | 455 | - "sql plugin Parse the username %s\n", user); |
michael@144 | 456 | + "sql plugin parse the username %s\n", user); |
michael@144 | 457 | |
michael@144 | 458 | user_buf = sparams->utils->malloc(ulen + 1); |
michael@144 | 459 | if (!user_buf) goto done; |
michael@144 | 460 | @@ -849,7 +880,7 @@ |
michael@144 | 461 | } |
michael@144 | 462 | |
michael@144 | 463 | sparams->utils->log(NULL, SASL_LOG_DEBUG, |
michael@144 | 464 | - "sql plugin create statement from %s %s %s\n", |
michael@144 | 465 | + "sql plugin create statement from name=%s user=%s realm=%s\n", |
michael@144 | 466 | realname, escap_userid, escap_realm); |
michael@144 | 467 | |
michael@144 | 468 | /* create a statement that we will use */ |
michael@144 | 469 | @@ -864,9 +895,15 @@ |
michael@144 | 470 | /* run the query */ |
michael@144 | 471 | if (!settings->sql_engine->sql_exec(conn, query, value, sizeof(value), |
michael@144 | 472 | &value_len, sparams->utils)) { |
michael@144 | 473 | + sparams->utils->log(NULL, SASL_LOG_DEBUG, |
michael@144 | 474 | + "sql plugin query successful\n"); |
michael@144 | 475 | sparams->utils->prop_set(sparams->propctx, cur->name, |
michael@144 | 476 | value, value_len); |
michael@144 | 477 | } |
michael@144 | 478 | + else { |
michael@144 | 479 | + sparams->utils->log(NULL, SASL_LOG_DEBUG, |
michael@144 | 480 | + "sql plugin query failed\n"); |
michael@144 | 481 | + } |
michael@144 | 482 | |
michael@144 | 483 | sparams->utils->free(query); |
michael@144 | 484 | } |
michael@144 | 485 | Index: sample/client.c |
michael@144 | 486 | --- sample/client.c.orig 2004-03-09 18:35:32 +0100 |
michael@144 | 487 | +++ sample/client.c 2008-12-25 18:48:51 +0100 |
michael@144 | 488 | @@ -133,13 +133,11 @@ |
michael@144 | 489 | return SASL_OK; |
michael@144 | 490 | } |
michael@144 | 491 | |
michael@144 | 492 | -#ifndef HAVE_GETPASSPHRASE |
michael@144 | 493 | static char * |
michael@144 | 494 | -getpassphrase(const char *prompt) |
michael@144 | 495 | +my_getpassphrase(const char *prompt) |
michael@144 | 496 | { |
michael@144 | 497 | return getpass(prompt); |
michael@144 | 498 | } |
michael@144 | 499 | -#endif /* ! HAVE_GETPASSPHRASE */ |
michael@144 | 500 | |
michael@144 | 501 | static int |
michael@144 | 502 | getsecret(sasl_conn_t *conn, |
michael@144 | 503 | @@ -155,7 +153,7 @@ |
michael@144 | 504 | if (! conn || ! psecret || id != SASL_CB_PASS) |
michael@144 | 505 | return SASL_BADPARAM; |
michael@144 | 506 | |
michael@144 | 507 | - password = getpassphrase("Password: "); |
michael@144 | 508 | + password = my_getpassphrase("Password: "); |
michael@144 | 509 | if (! password) |
michael@144 | 510 | return SASL_FAIL; |
michael@144 | 511 | |
michael@144 | 512 | Index: sample/sample-client.c |
michael@144 | 513 | --- sample/sample-client.c.orig 2004-10-26 13:14:33 +0200 |
michael@144 | 514 | +++ sample/sample-client.c 2008-12-25 18:48:51 +0100 |
michael@144 | 515 | @@ -244,13 +244,11 @@ |
michael@144 | 516 | return SASL_OK; |
michael@144 | 517 | } |
michael@144 | 518 | |
michael@144 | 519 | -#ifndef HAVE_GETPASSPHRASE |
michael@144 | 520 | static char * |
michael@144 | 521 | -getpassphrase(const char *prompt) |
michael@144 | 522 | +my_getpassphrase(const char *prompt) |
michael@144 | 523 | { |
michael@144 | 524 | return getpass(prompt); |
michael@144 | 525 | } |
michael@144 | 526 | -#endif /* ! HAVE_GETPASSPHRASE */ |
michael@144 | 527 | |
michael@144 | 528 | static int |
michael@144 | 529 | getsecret(sasl_conn_t *conn, |
michael@144 | 530 | @@ -264,7 +262,7 @@ |
michael@144 | 531 | if (! conn || ! psecret || id != SASL_CB_PASS) |
michael@144 | 532 | return SASL_BADPARAM; |
michael@144 | 533 | |
michael@144 | 534 | - password = getpassphrase("Password: "); |
michael@144 | 535 | + password = my_getpassphrase("Password: "); |
michael@144 | 536 | if (! password) |
michael@144 | 537 | return SASL_FAIL; |
michael@144 | 538 | |
michael@144 | 539 | @@ -307,7 +305,7 @@ |
michael@144 | 540 | fflush(stdout); |
michael@144 | 541 | |
michael@144 | 542 | if (id == SASL_CB_ECHOPROMPT) { |
michael@144 | 543 | - char *original = getpassphrase(""); |
michael@144 | 544 | + char *original = my_getpassphrase(""); |
michael@144 | 545 | if (! original) |
michael@144 | 546 | return SASL_FAIL; |
michael@144 | 547 | if (*original) |
michael@144 | 548 | Index: saslauthd/Makefile.am |
michael@144 | 549 | --- saslauthd/Makefile.am.orig 2006-05-17 18:46:17 +0200 |
michael@144 | 550 | +++ saslauthd/Makefile.am 2008-12-25 18:48:51 +0100 |
michael@144 | 551 | @@ -36,4 +36,4 @@ |
michael@144 | 552 | |
michael@144 | 553 | install-data-local: saslauthd.8 |
michael@144 | 554 | $(mkinstalldirs) $(DESTDIR)$(mandir)/man8 |
michael@144 | 555 | - $(INSTALL_DATA) $(srcdir)/saslauthd.8 $(DESTDIR)$(mandir)/man8/saslauthd.8 |
michael@144 | 556 | + $(INSTALL_DATA) $(srcdir)/saslauthd.mdoc $(DESTDIR)$(mandir)/man8/saslauthd.8 |
michael@144 | 557 | Index: saslauthd/Makefile.in |
michael@144 | 558 | --- saslauthd/Makefile.in.orig 2008-12-25 18:48:51 +0100 |
michael@144 | 559 | +++ saslauthd/Makefile.in 2008-12-25 18:48:51 +0100 |
michael@144 | 560 | @@ -621,7 +621,7 @@ |
michael@144 | 561 | |
michael@144 | 562 | install-data-local: saslauthd.8 |
michael@144 | 563 | $(mkinstalldirs) $(DESTDIR)$(mandir)/man8 |
michael@144 | 564 | - $(INSTALL_DATA) $(srcdir)/saslauthd.8 $(DESTDIR)$(mandir)/man8/saslauthd.8 |
michael@144 | 565 | + $(INSTALL_DATA) $(srcdir)/saslauthd.mdoc $(DESTDIR)$(mandir)/man8/saslauthd.8 |
michael@144 | 566 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
michael@144 | 567 | # Otherwise a system limit (for SysV at least) may be exceeded. |
michael@144 | 568 | .NOEXPORT: |
michael@144 | 569 | Index: saslauthd/lak.c |
michael@144 | 570 | --- saslauthd/lak.c.orig 2005-05-15 07:49:51 +0200 |
michael@144 | 571 | +++ saslauthd/lak.c 2008-12-25 18:48:51 +0100 |
michael@144 | 572 | @@ -47,6 +47,7 @@ |
michael@144 | 573 | #include <crypt.h> |
michael@144 | 574 | #endif |
michael@144 | 575 | |
michael@144 | 576 | +#include "saslauthd.h" /* get strlcpy macro for non-BSD; get HAVE_OPENSSL from config.h */ |
michael@144 | 577 | #ifdef HAVE_OPENSSL |
michael@144 | 578 | #ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT |
michael@144 | 579 | #define OPENSSL_DISABLE_OLD_DES_SUPPORT |
michael@144 | 580 | @@ -57,7 +58,7 @@ |
michael@144 | 581 | |
michael@144 | 582 | #include <ldap.h> |
michael@144 | 583 | #include <lber.h> |
michael@144 | 584 | -#include <sasl.h> |
michael@144 | 585 | +#include "sasl.h" |
michael@144 | 586 | #include "lak.h" |
michael@144 | 587 | |
michael@144 | 588 | typedef struct lak_auth_method { |
michael@144 | 589 | Index: utils/pluginviewer.c |
michael@144 | 590 | --- utils/pluginviewer.c.orig 2006-05-17 18:46:17 +0200 |
michael@144 | 591 | +++ utils/pluginviewer.c 2008-12-25 18:48:51 +0100 |
michael@144 | 592 | @@ -536,7 +536,7 @@ |
michael@144 | 593 | fprintf(stderr, "%s: Usage: %s [-a] [-s] [-c] [-b min=N,max=N] [-e ssf=N,id=ID] [-m MECHS] [-x AUXPROP_MECH] [-f FLAGS] [-i local=IP,remote=IP] [-p PATH]\n" |
michael@144 | 594 | "\t-a\tlist auxprop plugins\n" |
michael@144 | 595 | "\t-s\tlist server authentication (SASL) plugins\n" |
michael@144 | 596 | - "\t-s\tlist client authentication (SASL) plugins\n" |
michael@144 | 597 | + "\t-c\tlist client authentication (SASL) plugins\n" |
michael@144 | 598 | "\t-b ...\t#bits to use for encryption\n" |
michael@144 | 599 | "\t\tmin=N\tminumum #bits to use (1 => integrity)\n" |
michael@144 | 600 | "\t\tmax=N\tmaximum #bits to use\n" |