# # # patch "globish.cc" # from [b0e14f7e3b3c7f895639ab7fddfb6aaee10e3c7d] # to [9873ae64efa8df8f7088496becce1956f26db54e] # # patch "globish.hh" # from [33b7a499a0e37aa3267ccd72326636e39a76b3e7] # to [c9a36702e89840dbda17d23ada528ab476289c51] # # patch "merkle_tree.cc" # from [8dbfd8363164b2ed5046419012ca689a4e51c6c2] # to [2a245c8e472d72cc5678fea6a95fb1fd37b95d47] # # patch "netcmd.cc" # from [bde32fd29cb479216c638281cf494f72af458466] # to [a64b988db860126ce1f292f32110b743fd403fdf] # # patch "netsync.cc" # from [bae7d1252b532383fd50bbdd0da5b842f65baa4c] # to [8a22a378766bf1a545f734810b0d828a93f2f651] # # patch "revision.cc" # from [d90651ce5d000d0d595fa77e096417810dfd8c56] # to [6ec54f14d2ec5ea1badb490d8d746871dfd63d7e] # ============================================================ --- globish.cc b0e14f7e3b3c7f895639ab7fddfb6aaee10e3c7d +++ globish.cc 9873ae64efa8df8f7088496becce1956f26db54e @@ -146,7 +146,8 @@ static void // Compile one fragment of a glob pattern. static void -compile_frag(string const & pat, back_insert_iterator & to) +compile_frag(string const & pat, back_insert_iterator & to, + made_from_t made_from = made_from_local) { unsigned int brace_depth = 0; @@ -235,11 +236,11 @@ static inline string // common code used by the constructors. static inline string -compile(string const & pat) +compile(string const & pat, made_from_t made_from = made_from_local) { string s; back_insert_iterator to = back_inserter(s); - compile_frag(pat, to); + compile_frag(pat, to, made_from); return s; } @@ -269,8 +270,10 @@ compile(vector::const_iterator return s; } -globish::globish(string const & p) : compiled_pattern(compile(p)) {} -globish::globish(char const * p) : compiled_pattern(compile(p)) {} +globish::globish(string const & p, made_from_t made_from) + : compiled_pattern(compile(p, made_from)) {} +globish::globish(char const * p, made_from_t made_from) + : compiled_pattern(compile(p, made_from)) {} globish::globish(vector const & p) : compiled_pattern(compile(p.begin(), p.end())) {} ============================================================ --- globish.hh 33b7a499a0e37aa3267ccd72326636e39a76b3e7 +++ globish.hh c9a36702e89840dbda17d23ada528ab476289c51 @@ -51,8 +51,8 @@ struct globish struct globish { globish() : compiled_pattern() {} - globish(char const * pat); - globish(std::string const & pat); + globish(char const * pat, made_from_t made_from = made_from_local); + globish(std::string const & pat, made_from_t made_from = made_from_local); globish(std::vector const & pat); globish(std::vector::const_iterator const & beg, std::vector::const_iterator const & end); ============================================================ --- merkle_tree.cc 8dbfd8363164b2ed5046419012ca689a4e51c6c2 +++ merkle_tree.cc 2a245c8e472d72cc5678fea6a95fb1fd37b95d47 @@ -298,7 +298,7 @@ read_node(string const & inbuf, size_t & string slot_val = extract_substring(inbuf, pos, constants::merkle_hash_length_in_bytes, "slot value"); - out.set_raw_slot(slot, id(slot_val)); + out.set_raw_slot(slot, id(slot_val, made_from_network)); } } ============================================================ --- netcmd.cc bde32fd29cb479216c638281cf494f72af458466 +++ netcmd.cc a64b988db860126ce1f292f32110b743fd403fdf @@ -215,13 +215,13 @@ netcmd::read_hello_cmd(rsa_keypair_id & string skn_str, sk_str; extract_variable_length_string(payload, skn_str, pos, "hello netcmd, server key name"); - server_keyname = rsa_keypair_id(skn_str); + server_keyname = rsa_keypair_id(skn_str, made_from_network); extract_variable_length_string(payload, sk_str, pos, "hello netcmd, server key"); - server_key = rsa_pub_key(sk_str); + server_key = rsa_pub_key(sk_str, made_from_network); nonce = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "hello netcmd, nonce")); + "hello netcmd, nonce"), made_from_network); assert_end_of_buffer(payload, pos, "hello netcmd payload"); } @@ -275,14 +275,14 @@ netcmd::read_anonymous_cmd(protocol_role string pattern_string; extract_variable_length_string(payload, pattern_string, pos, "anonymous(hmac) netcmd, include_pattern"); - include_pattern = globish(pattern_string); + include_pattern = globish(pattern_string, made_from_network); extract_variable_length_string(payload, pattern_string, pos, "anonymous(hmac) netcmd, exclude_pattern"); - exclude_pattern = globish(pattern_string); + exclude_pattern = globish(pattern_string, made_from_network); string hmac_key_string; extract_variable_length_string(payload, hmac_key_string, pos, "anonymous(hmac) netcmd, hmac_key_encrypted"); - hmac_key_encrypted = rsa_oaep_sha_data(hmac_key_string); + hmac_key_encrypted = rsa_oaep_sha_data(hmac_key_string, made_from_network); assert_end_of_buffer(payload, pos, "anonymous(hmac) netcmd payload"); } @@ -321,24 +321,26 @@ netcmd::read_auth_cmd(protocol_role & ro string pattern_string; extract_variable_length_string(payload, pattern_string, pos, "auth(hmac) netcmd, include_pattern"); - include_pattern = globish(pattern_string); + include_pattern = globish(pattern_string, made_from_network); extract_variable_length_string(payload, pattern_string, pos, "auth(hmac) netcmd, exclude_pattern"); - exclude_pattern = globish(pattern_string); + exclude_pattern = globish(pattern_string, made_from_network); client = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "auth(hmac) netcmd, client identifier")); + "auth(hmac) netcmd, client identifier"), + made_from_network); nonce1 = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "auth(hmac) netcmd, nonce1")); + "auth(hmac) netcmd, nonce1"), + made_from_network); string hmac_key; extract_variable_length_string(payload, hmac_key, pos, "auth(hmac) netcmd, hmac_key_encrypted"); - hmac_key_encrypted = rsa_oaep_sha_data(hmac_key); + hmac_key_encrypted = rsa_oaep_sha_data(hmac_key, made_from_network); string sig_string; extract_variable_length_string(payload, sig_string, pos, "auth(hmac) netcmd, signature"); - signature = rsa_sha1_signature(sig_string); + signature = rsa_sha1_signature(sig_string, made_from_network); assert_end_of_buffer(payload, pos, "auth(hmac) netcmd payload"); } @@ -431,7 +433,8 @@ netcmd::read_data_cmd(netcmd_item_type & type = read_netcmd_item_type(payload, pos, "data netcmd, item type"); item = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "data netcmd, item identifier")); + "data netcmd, item identifier"), + made_from_network); dat.clear(); u8 compressed_p = extract_datum_lsb(payload, pos, @@ -440,7 +443,7 @@ netcmd::read_data_cmd(netcmd_item_type & "data netcmd, data payload"); if (compressed_p == 1) { - gzip zdat(dat); + gzip zdat(dat, made_from_network); data tdat; decode_gzip(zdat, tdat); dat = tdat(); @@ -482,10 +485,12 @@ netcmd::read_delta_cmd(netcmd_item_type type = read_netcmd_item_type(payload, pos, "delta netcmd, item type"); base = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "delta netcmd, base identifier")); + "delta netcmd, base identifier"), + made_from_network); ident = id(extract_substring(payload, pos, constants::merkle_hash_length_in_bytes, - "delta netcmd, ident identifier")); + "delta netcmd, ident identifier"), + made_from_network); u8 compressed_p = extract_datum_lsb(payload, pos, "delta netcmd, compression flag"); string tmp; @@ -493,12 +498,12 @@ netcmd::read_delta_cmd(netcmd_item_type "delta netcmd, delta payload"); if (compressed_p == 1) { - gzip zdel(tmp); + gzip zdel(tmp, made_from_network); decode_gzip(zdel, del); } else { - del = delta(tmp); + del = delta(tmp, made_from_network); } assert_end_of_buffer(payload, pos, "delta netcmd payload"); } @@ -539,7 +544,7 @@ netcmd::read_usher_cmd(utf8 & greeting) size_t pos = 0; string str; extract_variable_length_string(payload, str, pos, "error netcmd, message"); - greeting = utf8(str); + greeting = utf8(str, made_from_network); assert_end_of_buffer(payload, pos, "error netcmd payload"); } ============================================================ --- netsync.cc bae7d1252b532383fd50bbdd0da5b842f65baa4c +++ netsync.cc 8a22a378766bf1a545f734810b0d828a93f2f651 @@ -2273,8 +2273,7 @@ session::process_data_cmd(netcmd_item_ty { L(FL("received revision '%s'") % hitem()); revision_t rev; - rev.made_from = made_from_network; - read_revision(data(dat), rev); + read_revision(data(dat, made_from_network), rev); if (project.db.put_revision(revision_id(item), rev)) written_revisions.push_back(revision_id(item)); } @@ -2283,7 +2282,8 @@ session::process_data_cmd(netcmd_item_ty case file_item: { L(FL("received file '%s'") % hitem()); - project.db.put_file(file_id(item), file_data(dat)); + project.db.put_file(file_id(item), + file_data(dat, made_from_network)); } break; } ============================================================ --- revision.cc d90651ce5d000d0d595fa77e096417810dfd8c56 +++ revision.cc 6ec54f14d2ec5ea1badb490d8d746871dfd63d7e @@ -1870,9 +1870,8 @@ read_revision(data const & dat, { MM(rev); basic_io::input_source src(dat(), "revision"); - // FIXME: maybe this is backwards, and made_from should - // come from @param{dat}? - src.made_from = rev.made_from; + rev.made_from = dat.made_from; + src.made_from = dat.made_from; made_from_t made_from(rev.made_from); basic_io::tokenizer tok(src); basic_io::parser pars(tok); @@ -1994,12 +1993,12 @@ UNIT_TEST(revision, from_network) " foo \"some_file\"\n" }; revision_t rev; - rev.made_from = made_from_network; for (unsigned i = 0; i < sizeof(bad_revisions)/sizeof(char const*); ++i) { UNIT_TEST_CHECKPOINT((string("iteration ") + boost::lexical_cast(i)).c_str()); - UNIT_TEST_CHECK_THROW(read_revision(data(bad_revisions[i]), + UNIT_TEST_CHECK_THROW(read_revision(data(bad_revisions[i], + made_from_network), rev), bad_decode); }