chiark / gitweb /
Merge from 3.0 fixes branch
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 20 Apr 2008 19:17:45 +0000 (20:17 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 20 Apr 2008 19:17:45 +0000 (20:17 +0100)
CHANGES
lib/client.c
lib/trackdb-stub.c
lib/trackdb.c
lib/trackdb.h

diff --git a/CHANGES b/CHANGES
index 773115330e041288ee788b7ec30701b1c04756b9..91ab4e1f26f3546b61e43dec5917406d44299719 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,8 @@ Builds --without-server should work again.
 The web interface is a bit more liberal in the cookie value syntax it
 will accept.
 
+Clients fail more gracefully if no password is available.
+
 * Changes up to version 3.0.1
 
 Debian upgrades from 2.0.x should now work better.
index 75381c6f26354ccc9bc1981854b741d278802eb9..4dfd10cc27b9b11e321a9d44405595a12a8c1e5d 100644 (file)
@@ -389,9 +389,8 @@ int disorder_connect(disorder_client *c) {
     return -1;
   }
   password = config->password;
-  if(!password) {
-    /* Maybe we can read the database */
-    /* TODO failure to open the database should not be fatal */
+  /* Maybe we can read the database */
+  if(!password && trackdb_readable()) {
     trackdb_init(TRACKDB_NO_RECOVER|TRACKDB_NO_UPGRADE);
     trackdb_open(TRACKDB_READ_ONLY);
     password = trackdb_get_password(username);
index 22174d396f93369ddbe2e6aa97fde16740f573c6..3b92c97627277d14bf921ea88967e2edbee86ca5 100644 (file)
@@ -44,6 +44,10 @@ void trackdb_open(int attribute((unused)) flags) {
 void trackdb_init(int attribute((unused)) flags) {
 }
 
+int trackdb_readable(void) {
+  return 0;
+}
+
 /*
 Local Variables:
 c-basic-offset:2
index 80bfa01e0647e402b4658eb1fd24e6a6b8618bea..53d7cf311239f056d6c25953ad9e0d5284063edb 100644 (file)
@@ -162,6 +162,16 @@ static int compare(DB attribute((unused)) *db_,
   return compare_path_raw(a->data, a->size, b->data, b->size);
 }
 
+/** @brief Test whether the track database can be read
+ * @return 1 if it can, 0 if it cannot
+ */
+int trackdb_readable(void) {
+  char *usersdb;
+
+  byte_xasprintf(&usersdb, "%s/users.db", config->home);
+  return access(usersdb, R_OK) == 0;
+}
+
 /** @brief Open database environment
  * @param flags Flags word
  *
index e39de6e419454b6494a7dd010c7f2529dbaf4a12..f372f4cf0586e9fbe57e6fa3138a157d10d5eacc 100644 (file)
@@ -171,6 +171,7 @@ int trackdb_edituserinfo(const char *user,
 char **trackdb_listusers(void);
 int trackdb_confirm(const char *user, const char *confirmation,
                     rights_type *rightsp);
+int trackdb_readable(void);
 
 typedef void random_callback(struct ev_source *ev,
                              const char *track);