}
return 0;
default:
+ *aliasp = 0;
return err;
}
}
for(;;) {
tid = trackdb_begin_transaction();
err = trackdb_notice_tid(track, path, tid);
- if((err == DB_LOCK_DEADLOCK)) goto fail;
+ if(err == DB_LOCK_DEADLOCK) goto fail;
break;
fail:
trackdb_abort_transaction(tid);
/* 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
return trackdb_putdata(trackdb_usersdb, user, k, tid, flags);
}
-/** @brief Add one pre-existing user
- * @param user Username
- * @param password password
- * @param tid Owning transaction
- * @return 0, DB_KEYEXIST or DB_LOCK_DEADLOCK
- *
- * Used only in upgrade from old versions.
- */
-static int one_old_user(const char *user, const char *password,
- DB_TXN *tid) {
- const char *rights;
-
- /* www-data doesn't get added */
- if(!strcmp(user, "www-data")) {
- disorder_info("not adding www-data to user database");
- return 0;
- }
- /* pick rights */
- if(!strcmp(user, "root"))
- rights = "all";
- else if(trusted(user)) {
- rights_type r;
-
- parse_rights(config->default_rights, &r, 1);
- r &= ~(rights_type)(RIGHT_SCRATCH__MASK|RIGHT_MOVE__MASK|RIGHT_REMOVE__MASK);
- r |= (RIGHT_ADMIN|RIGHT_RESCAN
- |RIGHT_SCRATCH_ANY|RIGHT_MOVE_ANY|RIGHT_REMOVE_ANY);
- rights = rights_string(r);
- } else
- rights = config->default_rights;
- return create_user(user, password, rights, 0/*email*/, 0/*confirmation*/,
- 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;