chiark / gitweb /
server: docs: remove deprecated configuration and user upgrade.
[disorder] / lib / trackdb.c
index ddf11afa3c395f3848f9265f9624c6381aa96edf..aa9ad56a4c90abe98c35ea0a931ec40f01c9143f 100644 (file)
@@ -1389,6 +1389,7 @@ int trackdb_obsolete(const char *track, DB_TXN *tid) {
 #define H(name) { #name, offsetof(DB_HASH_STAT, name) }
 #define B(name) { #name, offsetof(DB_BTREE_STAT, name) }
 
+/** @brief Table of libdb stats to return */
 static const struct statinfo {
   const char *name;
   size_t offset;
@@ -2736,16 +2737,18 @@ int trackdb_rescan_underway(void) {
  * @param name Global preference name
  * @param value New value
  * @param who Who is setting it
+ * @return 0 on success, -1 on error
  */
-void trackdb_set_global(const char *name,
+int trackdb_set_global(const char *name,
                         const char *value,
                         const char *who) {
   DB_TXN *tid;
-  int state;
+  int state, err;
 
   for(;;) {
     tid = trackdb_begin_transaction();
-    if(!trackdb_set_global_tid(name, value, tid))
+    err = trackdb_set_global_tid(name, value, tid);
+    if(err != DB_LOCK_DEADLOCK)
       break;
     trackdb_abort_transaction(tid);
   }
@@ -2766,6 +2769,7 @@ void trackdb_set_global(const char *name,
     eventlog("state", state ? "enable_random" : "disable_random", (char *)0);
   }
   eventlog("global_pref", name, value, (char *)0);
+  return err == 0 ? 0 : -1;
 }
 
 /** @brief Set a global preference
@@ -2791,7 +2795,7 @@ int trackdb_set_global_tid(const char *name,
     err = trackdb_globaldb->put(trackdb_globaldb, tid, &k, &d, 0);
   else
     err = trackdb_globaldb->del(trackdb_globaldb, tid, &k, 0);
-  if(err == DB_LOCK_DEADLOCK) return err;
+  if(err == DB_LOCK_DEADLOCK || err == DB_NOTFOUND) return err;
   if(err)
     disorder_fatal(0, "error updating database: %s", db_strerror(err));
   return 0;
@@ -3001,21 +3005,6 @@ void trackdb_gc(void) {
 
 /* user database *************************************************************/
 
-/** @brief Return true if @p user is trusted
- * @param user User to look up
- * @return Nonzero if they are in the 'trusted' list
- *
- * Now used only in upgrade from old versions.
- */
-static int trusted(const char *user) {
-  int n;
-
-  for(n = 0; (n < config->trust.n
-             && strcmp(config->trust.s[n], user)); ++n)
-    ;
-  return n < config->trust.n;
-}
-
 /** @brief Add a user
  * @param user Username
  * @param password Initial password or NULL
@@ -3092,41 +3081,6 @@ static int one_old_user(const char *user, const char *password,
                      tid, DB_NOOVERWRITE);
 }
 
-/** @brief Upgrade old users
- * @param tid Owning transaction
- * @return 0 or DB_LOCK_DEADLOCK
- */
-static int trackdb_old_users_tid(DB_TXN *tid) {
-  int n;
-
-  for(n = 0; n < config->allow.n; ++n) {
-    switch(one_old_user(config->allow.s[n].s[0], config->allow.s[n].s[1],
-                        tid)) {
-    case 0:
-      disorder_info("created user %s from 'allow' directive",
-                    config->allow.s[n].s[0]);
-      break;
-    case DB_KEYEXIST:
-      disorder_error(0, "user %s already exists, delete 'allow' directive",
-            config->allow.s[n].s[0]);
-          /* This won't ever become fatal - eventually 'allow' will be
-           * disabled. */
-      break;
-    case DB_LOCK_DEADLOCK:
-      return DB_LOCK_DEADLOCK;
-    }
-  }
-  return 0;
-}
-
-/** @brief Read old 'allow' directives and copy them to the users database */
-void trackdb_old_users(void) {
-  int e;
-
-  if(config->allow.n)
-    WITH_TRANSACTION(trackdb_old_users_tid(tid));
-}
-
 /** @brief Create a root user in the user database if there is none */
 void trackdb_create_root(void) {
   int e;