diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/couchdb/Makefile.am | 2 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_auth.erl | 4 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 4 | ||||
-rw-r--r-- | src/couchdb/couch_httpd_misc_handlers.erl | 7 | ||||
-rw-r--r-- | src/couchdb/couch_rep.erl | 2 | ||||
-rw-r--r-- | src/couchdb/couch_server.erl | 2 | ||||
-rw-r--r-- | src/couchdb/couch_util.erl | 7 |
7 files changed, 13 insertions, 15 deletions
diff --git a/src/couchdb/Makefile.am b/src/couchdb/Makefile.am index 017dc169..97d8a3b0 100644 --- a/src/couchdb/Makefile.am +++ b/src/couchdb/Makefile.am @@ -101,6 +101,7 @@ source_files = \ couch_stream.erl \ couch_task_status.erl \ couch_util.erl \ + couch_uuids.erl \ couch_view.erl \ couch_view_compactor.erl \ couch_view_updater.erl \ @@ -157,6 +158,7 @@ compiled_files = \ couch_stream.beam \ couch_task_status.beam \ couch_util.beam \ + couch_uuids.beam \ couch_view.beam \ couch_view_compactor.beam \ couch_view_updater.beam \ diff --git a/src/couchdb/couch_httpd_auth.erl b/src/couchdb/couch_httpd_auth.erl index c77376b2..1c1ad0a9 100644 --- a/src/couchdb/couch_httpd_auth.erl +++ b/src/couchdb/couch_httpd_auth.erl @@ -381,9 +381,9 @@ create_user_req(#httpd{method='POST', mochi_req=MochiReq}=Req, Db) -> [?l2b(R) || R <- Roles] end, - UserSalt = couch_util:new_uuid(), + UserSalt = couch_uuids:random(), PasswordHash = hash_password(Password, UserSalt), - DocId = couch_util:new_uuid(), + DocId = couch_uuids:random(), {ok, UserDoc} = user_doc(DocId, UserName, UserSalt, PasswordHash, Email, Active, Roles1), {ok, _Rev} = couch_db:update_doc(Db, UserDoc, []), ?LOG_DEBUG("User ~s (~s) with password, ~s created.", [?b2l(UserName), ?b2l(DocId), ?b2l(Password)]), diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 1a18c4ba..0f3835ae 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -308,7 +308,7 @@ db_req(#httpd{method='POST',path_parts=[DbName]}=Req, Db) -> Doc = couch_doc:from_json_obj(couch_httpd:json_body(Req)), Doc2 = case Doc#doc.id of <<"">> -> - Doc#doc{id=couch_util:new_uuid(), revs={0, []}}; + Doc#doc{id=couch_uuids:new(), revs={0, []}}; _ -> Doc end, @@ -385,7 +385,7 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) -> Doc = couch_doc:from_json_obj(JsonObj), validate_attachment_names(Doc), Id = case Doc#doc.id of - <<>> -> couch_util:new_uuid(); + <<>> -> couch_uuids:new(); Id0 -> Id0 end, case proplists:get_value(<<"_rev">>, ObjProps) of diff --git a/src/couchdb/couch_httpd_misc_handlers.erl b/src/couchdb/couch_httpd_misc_handlers.erl index c3c5b37a..7f5573ff 100644 --- a/src/couchdb/couch_httpd_misc_handlers.erl +++ b/src/couchdb/couch_httpd_misc_handlers.erl @@ -108,11 +108,10 @@ handle_uuids_req(#httpd{method='GET'}=Req) -> Count = list_to_integer(couch_httpd:qs_value(Req, "count", "1")), CacheBustingHeaders = [{"Date", httpd_util:rfc1123_date()}, {"Cache-Control", "no-cache"}, - {"Expires", "Fri, 01 Jan 1990 00:00:00 GMT"}, % Past date, ON PURPOSE! + % Past date, ON PURPOSE! + {"Expires", "Fri, 01 Jan 1990 00:00:00 GMT"}, {"Pragma", "no-cache"}], - % generate the uuids - UUIDs = [ couch_util:new_uuid() || _ <- lists:seq(1,Count)], - % send a JSON response + UUIDs = [couch_uuids:new() || _ <- lists:seq(1, Count)], send_json(Req, 200, CacheBustingHeaders, {[{<<"uuids">>, UUIDs}]}); handle_uuids_req(Req) -> send_method_not_allowed(Req, "GET"). diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl index bcd1807c..c2f691eb 100644 --- a/src/couchdb/couch_rep.erl +++ b/src/couchdb/couch_rep.erl @@ -470,7 +470,7 @@ do_checkpoint(State) -> "replication is redone and documents reexamined.", []), StartSeqNum end, - SessionId = couch_util:new_uuid(), + SessionId = couch_uuids:random(), NewHistoryEntry = {[ {<<"session_id">>, SessionId}, {<<"start_time">>, list_to_binary(ReplicationStartTime)}, diff --git a/src/couchdb/couch_server.erl b/src/couchdb/couch_server.erl index f407acf0..8fab42f1 100644 --- a/src/couchdb/couch_server.erl +++ b/src/couchdb/couch_server.erl @@ -99,7 +99,7 @@ hash_admin_passwords() -> fun({_User, "-hashed-" ++ _}) -> ok; % already hashed ({User, ClearPassword}) -> - Salt = ?b2l(couch_util:new_uuid()), + Salt = ?b2l(couch_uuids:random()), Hashed = couch_util:to_hex(crypto:sha(ClearPassword ++ Salt)), couch_config:set("admins", User, "-hashed-" ++ Hashed ++ "," ++ Salt) end, couch_config:get("admins")). diff --git a/src/couchdb/couch_util.erl b/src/couchdb/couch_util.erl index d967b433..088fde85 100644 --- a/src/couchdb/couch_util.erl +++ b/src/couchdb/couch_util.erl @@ -14,7 +14,7 @@ -export([start_driver/1,terminate_linked/1]). -export([should_flush/0, should_flush/1, to_existing_atom/1]). --export([new_uuid/0, rand32/0, implode/2, collate/2, collate/3]). +-export([rand32/0, implode/2, collate/2, collate/3]). -export([abs_pathname/1,abs_pathname/2, trim/1, ascii_lower/1]). -export([encodeBase64/1, decodeBase64/1, encodeBase64Url/1, decodeBase64Url/1, to_hex/1,parse_term/1, dict_find/3]). @@ -55,9 +55,6 @@ terminate_linked(Reason) -> ok. -new_uuid() -> - list_to_binary(to_hex(crypto:rand_bytes(16))). - to_hex([]) -> []; to_hex(Bin) when is_binary(Bin) -> @@ -394,4 +391,4 @@ url_encode([H|T]) -> end end; url_encode([]) -> - [].
\ No newline at end of file + []. |