]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/mysql.c
Fix DiskToCatalog seg fault
[bacula/bacula] / bacula / src / cats / mysql.c
index 7f8891acf1e7ea1a747d8b2c975d886be0fecd3c..719aab5cd8db50da25287b4ff8fc3d15c673d2ac 100644 (file)
@@ -61,6 +61,10 @@ db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
 {
    B_DB *mdb;
 
+   if (!db_user) {             
+      Jmsg(jcr, M_FATAL, 0, _("A user name for MySQL must be supplied.\n"));
+      return NULL;
+   }
    P(mutex);                         /* lock DB queue */
    /* Look to see if DB already open */
    for (mdb=NULL; (mdb=(B_DB *)qnext(&db_list, &mdb->bq)); ) {
@@ -76,7 +80,9 @@ db_init_database(JCR *jcr, char *db_name, char *db_user, char *db_password,
    memset(mdb, 0, sizeof(B_DB));
    mdb->db_name = bstrdup(db_name);
    mdb->db_user = bstrdup(db_user);
-   mdb->db_password = bstrdup(db_password);
+   if (db_password) {
+      mdb->db_password = bstrdup(db_password);
+   }
    if (db_address) {
       mdb->db_address = bstrdup(db_address);
    }
@@ -170,7 +176,9 @@ It is probably not running or your password is incorrect.\n"),
       return 0;
    }
 
+#ifdef HAVE_TREAD_SAFE_MYSQL
    my_thread_init();
+#endif
 
    mdb->connected = TRUE;
    V(mutex);
@@ -182,7 +190,9 @@ db_close_database(JCR *jcr, B_DB *mdb)
 {
    P(mutex);
    mdb->ref_count--;
+#ifdef HAVE_TREAD_SAFE_MYSQL
    my_thread_end();
+#endif
    if (mdb->ref_count == 0) {
       qdchain(&mdb->bq);
       if (mdb->connected && mdb->db) {
@@ -236,7 +246,7 @@ int db_next_index(JCR *jcr, B_DB *mdb, char *table, char *index)
  * Escape strings so that MySQL is happy
  *
  *   NOTE! len is the length of the old string. Your new
- *        string must be long enough (max 2*old) to hold
+ *        string must be long enough (max 2*old+1) to hold
  *        the escaped output.
  */
 void