diff options
author | Jan Lehnardt <jan@apache.org> | 2009-09-13 11:14:59 +0000 |
---|---|---|
committer | Jan Lehnardt <jan@apache.org> | 2009-09-13 11:14:59 +0000 |
commit | c1f2441020fcba500821981013144aff1fd8f8b9 (patch) | |
tree | bcd5c2827fa55d91aa22807b02d78f9636f81956 /src/couchdb/couch_server.erl | |
parent | 8a05205d2c2256b58335d70a5700ff2590481e31 (diff) |
allow config callbacks to get passed the X-Couch-Persist flag
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@814300 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_server.erl')
-rw-r--r-- | src/couchdb/couch_server.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl index 8fab42f1..afdf9365 100644 --- a/src/couchdb/couch_server.erl +++ b/src/couchdb/couch_server.erl @@ -95,13 +95,17 @@ get_full_filename(Server, DbName) -> filename:join([Server#server.root_dir, "./" ++ DbName ++ ".couch"]). hash_admin_passwords() -> + hash_admin_passwords(true). + +hash_admin_passwords(Persist) -> lists:foreach( fun({_User, "-hashed-" ++ _}) -> ok; % already hashed ({User, ClearPassword}) -> Salt = ?b2l(couch_uuids:random()), Hashed = couch_util:to_hex(crypto:sha(ClearPassword ++ Salt)), - couch_config:set("admins", User, "-hashed-" ++ Hashed ++ "," ++ Salt) + couch_config:set("admins", + User, "-hashed-" ++ Hashed ++ "," ++ Salt, Persist) end, couch_config:get("admins")). init([]) -> @@ -125,10 +129,10 @@ init([]) -> end), hash_admin_passwords(), ok = couch_config:register( - fun("admins") -> + fun("admins", _Key, _Value, Persist) -> % spawn here so couch_config doesn't try to call itself - spawn(fun() -> hash_admin_passwords() end) - end), + spawn(fun() -> hash_admin_passwords(Persist) end) + end, false), {ok, RegExp} = re:compile("^[a-z][a-z0-9\\_\\$()\\+\\-\\/]*$"), ets:new(couch_dbs_by_name, [set, private, named_table]), ets:new(couch_dbs_by_pid, [set, private, named_table]), |