AUDIT: r21269 - gnucash/trunk/src - [Bug #645216] Wrong permissions on server result in bogus error message
John Ralls
jralls at code.gnucash.org
Sun Sep 18 13:57:28 EDT 2011
Author: jralls
Date: 2011-09-18 13:57:28 -0400 (Sun, 18 Sep 2011)
New Revision: 21269
Trac: http://svn.gnucash.org/trac/changeset/21269
Modified:
gnucash/trunk/src/backend/dbi/gnc-backend-dbi-priv.h
gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
gnucash/trunk/src/gnome-utils/gnc-file.c
gnucash/trunk/src/libqof/qof/qofbackend.h
Log:
[Bug #645216] Wrong permissions on server result in bogus error message
Author: John W. O'Brien <john at saltant.com>
In gnc-backend-dbi.c, accept enumerated result from conn_test_dbi_library(),
then throw ERR_SQL_DBI_UNTESTABLE if the test setup failed, or ERR_SQL_BAD_DBI
if at least one test case failed.
Define ERR_SQL_DBI_UNTESTABLE error code and message.
Define GncDbiTestResult enumerated type.
BP
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi-priv.h
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi-priv.h 2011-09-18 17:28:03 UTC (rev 21268)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi-priv.h 2011-09-18 17:57:28 UTC (rev 21269)
@@ -43,6 +43,19 @@
drop_backup
} TableOpType;
+/**
+ * Return values from conn_test_dbi_library
+ * @var GNC_DBI_PASS Did not find the large numbers bug
+ * @var GNC_DBI_FAIL_SETUP Could not completed the test
+ * @var GNC_DBI_FAIL_TEST Found the large numbers bug
+ */
+typedef enum
+{
+ GNC_DBI_PASS = 0,
+ GNC_DBI_FAIL_SETUP,
+ GNC_DBI_FAIL_TEST
+} GncDbiTestResult;
+
typedef gchar* (*CREATE_TABLE_DDL_FN)( GncSqlConnection* conn,
const gchar* table_name,
const GList* col_info_list );
Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2011-09-18 17:28:03 UTC (rev 21268)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c 2011-09-18 17:57:28 UTC (rev 21269)
@@ -137,7 +137,7 @@
const gchar* table_name,
GList* col_info_list );
static GncSqlConnection* create_dbi_connection( /*@ observer @*/ provider_functions_t* provider, /*@ observer @*/ QofBackend* qbe, /*@ observer @*/ dbi_conn conn );
-static gboolean conn_test_dbi_library( dbi_conn conn );
+static GncDbiTestResult conn_test_dbi_library( dbi_conn conn );
#define GNC_DBI_PROVIDER_SQLITE (&provider_sqlite3)
#define GNC_DBI_PROVIDER_MYSQL (&provider_mysql)
#define GNC_DBI_PROVIDER_PGSQL (&provider_pgsql)
@@ -242,6 +242,7 @@
gchar *filepath = NULL;
gchar *msg = " ";
gboolean file_exists;
+ GncDbiTestResult dbi_test_result = GNC_DBI_PASS;
g_return_if_fail( qbe != NULL );
g_return_if_fail( session != NULL );
@@ -316,10 +317,26 @@
goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) )
+ dbi_test_result = conn_test_dbi_library( be->conn );
+ switch( dbi_test_result )
{
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe, "DBI library fails large number test" );
+ case GNC_DBI_PASS:
+ break;
+
+ case GNC_DBI_FAIL_SETUP:
+ qof_backend_set_error( qbe, ERR_SQL_DBI_UNTESTABLE );
+ qof_backend_set_message( qbe,
+ "SQLite3: Failed to setup for large number test" );
+ break;
+
+ case GNC_DBI_FAIL_TEST:
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "SQLite3 DBI library fails large number test" );
+ break;
+ }
+ if ( dbi_test_result != GNC_DBI_PASS )
+ {
if ( create && !file_exists ) /* File didn't exist before, but it */
{
/* does now, and we don't want to */
@@ -736,6 +753,7 @@
gint portnum = 0;
gint result;
gboolean success = FALSE;
+ GncDbiTestResult dbi_test_result = GNC_DBI_PASS;
g_return_if_fail( qbe != NULL );
g_return_if_fail( session != NULL );
@@ -772,11 +790,26 @@
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
- if ( !conn_test_dbi_library( be->conn ) )
+ dbi_test_result = conn_test_dbi_library( be->conn );
+ switch( dbi_test_result )
{
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
+ case GNC_DBI_PASS:
+ break;
+
+ case GNC_DBI_FAIL_SETUP:
+ qof_backend_set_error( qbe, ERR_SQL_DBI_UNTESTABLE );
+ qof_backend_set_message( qbe,
+ "DBI library large number test incomplete" );
+ break;
+
+ case GNC_DBI_FAIL_TEST:
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ break;
+ }
+ if ( GNC_DBI_PASS != dbi_test_result )
+ {
goto exit;
}
if (create && !force && save_may_clobber_data( qbe ) )
@@ -845,11 +878,26 @@
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) )
+ dbi_test_result = conn_test_dbi_library( be->conn );
+ switch( dbi_test_result )
{
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
+ case GNC_DBI_PASS:
+ break;
+
+ case GNC_DBI_FAIL_SETUP:
+ qof_backend_set_error( qbe, ERR_SQL_DBI_UNTESTABLE );
+ qof_backend_set_message( qbe,
+ "MySql: Failed to setup for large number test" );
+ break;
+
+ case GNC_DBI_FAIL_TEST:
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "MySql DBI library fails large number test" );
+ break;
+ }
+ if ( dbi_test_result != GNC_DBI_PASS )
+ {
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbname );
goto exit;
}
@@ -1008,6 +1056,7 @@
gchar* translog_path = NULL;
gboolean success = FALSE;
gint portnum = 0;
+ GncDbiTestResult dbi_test_result = GNC_DBI_PASS;
g_return_if_fail( qbe != NULL );
g_return_if_fail( session != NULL );
@@ -1051,11 +1100,26 @@
result = dbi_conn_connect( be->conn );
if ( result == 0 )
{
- if ( !conn_test_dbi_library( be->conn ) )
+ dbi_test_result = conn_test_dbi_library( be->conn );
+ switch ( dbi_test_result )
{
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
+ case GNC_DBI_PASS:
+ break;
+
+ case GNC_DBI_FAIL_SETUP:
+ qof_backend_set_error( qbe, ERR_SQL_DBI_UNTESTABLE );
+ qof_backend_set_message( qbe,
+ "Postgresql: Failed to setup for large number test" );
+ break;
+
+ case GNC_DBI_FAIL_TEST:
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "Postgresql DBI library fails large number test" );
+ break;
+ }
+ if ( dbi_test_result != GNC_DBI_PASS )
+ {
goto exit;
}
if (create && !force && save_may_clobber_data( qbe ) )
@@ -1125,11 +1189,26 @@
qof_backend_set_error( qbe, ERR_BACKEND_SERVER_ERR );
goto exit;
}
- if ( !conn_test_dbi_library( be->conn ) )
+ dbi_test_result = conn_test_dbi_library( be->conn );
+ switch( dbi_test_result )
{
- qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
- qof_backend_set_message( qbe,
- "DBI library fails large number test" );
+ case GNC_DBI_PASS:
+ break;
+
+ case GNC_DBI_FAIL_SETUP:
+ qof_backend_set_error( qbe, ERR_SQL_DBI_UNTESTABLE );
+ qof_backend_set_message( qbe,
+ "DBI library large number test incomplete" );
+ break;
+
+ case GNC_DBI_FAIL_TEST:
+ qof_backend_set_error( qbe, ERR_SQL_BAD_DBI );
+ qof_backend_set_message( qbe,
+ "DBI library fails large number test" );
+ break;
+ }
+ if ( GNC_DBI_PASS != dbi_test_result )
+ {
dbi_conn_select_db( be->conn, "template1" );
dbi_conn_queryf( be->conn, "DROP DATABASE %s", dbnamelc );
goto exit;
@@ -2901,9 +2980,11 @@
* compiler option it fails to correctly handle saving of 64-bit
* values. This function tests for the problem.
* @param: conn: The just-opened dbi_conn
- * @returns: TRUE if the dbi library is safe to use, FALSE otherwise.
+ * @returns: GNC_DBI_PASS if the dbi library is safe to use,
+ * GNC_DBI_FAIL_SETUP if the test could not be completed, or
+ * GNC_DBI_FAIL_TEST if the bug was found.
*/
-static gboolean
+static GncDbiTestResult
conn_test_dbi_library( dbi_conn conn )
{
gint64 testlonglong = -9223372036854775807LL, resultlonglong = 0;
@@ -2911,7 +2992,7 @@
gdouble testdouble = 1.7976921348623157E+307, resultdouble = 0.0;
dbi_result result;
gchar doublestr[G_ASCII_DTOSTR_BUF_SIZE], *querystr;
- gboolean retval = TRUE;
+ GncDbiTestResult retval = GNC_DBI_PASS;
memset( doublestr, 0, sizeof(doublestr));
result = dbi_conn_query( conn, "CREATE TEMPORARY TABLE numtest "
@@ -2920,7 +3001,7 @@
if ( result == NULL )
{
PWARN("Test_DBI_Library: Create table failed");
- return FALSE;
+ return GNC_DBI_FAIL_SETUP;
}
dbi_result_free( result );
g_ascii_dtostr( doublestr, sizeof(doublestr), testdouble );
@@ -2932,7 +3013,7 @@
if ( result == NULL )
{
PWARN("Test_DBI_Library: Failed to insert test row into table" );
- return FALSE;
+ return GNC_DBI_FAIL_SETUP;
}
dbi_result_free( result );
gnc_push_locale( LC_NUMERIC, "C");
@@ -2944,7 +3025,7 @@
PWARN("Test_DBI_Library: Failed to retrieve test row into table: %s",
errmsg );
result = dbi_conn_query( conn, "DROP TABLE numtest" );
- return FALSE;
+ return GNC_DBI_FAIL_SETUP;
}
while ( dbi_result_next_row( result ))
{
@@ -2957,13 +3038,13 @@
{
PWARN( "Test_DBI_Library: LongLong Failed %" G_GINT64_FORMAT " != % " G_GINT64_FORMAT,
testlonglong, resultlonglong );
- retval = FALSE;
+ retval = GNC_DBI_FAIL_TEST;
}
if ( testulonglong != resultulonglong )
{
PWARN( "Test_DBI_Library: Unsigned longlong Failed %" G_GUINT64_FORMAT " != %" G_GUINT64_FORMAT,
testulonglong, resultulonglong );
- retval = FALSE;
+ retval = GNC_DBI_FAIL_TEST;
}
/* A bug in libdbi stores only 7 digits of precision */
if ( testdouble >= resultdouble + 0.000001e307 ||
@@ -2971,7 +3052,7 @@
{
PWARN( "Test_DBI_Library: Double Failed %17e != %17e",
testdouble, resultdouble );
- retval = FALSE;
+ retval = GNC_DBI_FAIL_TEST;
}
return retval;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c 2011-09-18 17:28:03 UTC (rev 21268)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c 2011-09-18 17:57:28 UTC (rev 21269)
@@ -447,6 +447,17 @@
gnc_error_dialog (parent, "%s", fmt);
break;
+ case ERR_SQL_DBI_UNTESTABLE:
+
+ fmt = _("GnuCash could not complete a critical test for the presence of "
+ "a bug in the \"libdbi\" library. This may be caused by a "
+ "permissions misconfiguration of your SQL database. Please see "
+ "https://bugzilla.gnome.org/show_bug.cgi?id=645216 for more "
+ "information.");
+
+ gnc_error_dialog (parent, "%s", fmt);
+ break;
+
default:
PERR("FIXME: Unhandled error %d", io_error);
fmt = _("An unknown I/O error (%d) occurred.");
Modified: gnucash/trunk/src/libqof/qof/qofbackend.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qofbackend.h 2011-09-18 17:28:03 UTC (rev 21268)
+++ gnucash/trunk/src/libqof/qof/qofbackend.h 2011-09-18 17:57:28 UTC (rev 21269)
@@ -110,6 +110,7 @@
ERR_SQL_DB_TOO_NEW, /**< database is newer, we can't write to it */
ERR_SQL_DB_BUSY, /**< database is busy, cannot upgrade version */
ERR_SQL_BAD_DBI, /**< LibDBI has numeric errors */
+ ERR_SQL_DBI_UNTESTABLE, /**< could not complete test for LibDBI bug */
/* RPC errors */
ERR_RPC_HOST_UNK = 4000, /**< Host unknown */
More information about the gnucash-changes
mailing list