[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Monotone-commits-diffs] net.venge.monotone: 929a68cba94945ced461581d7c
From: |
code |
Subject: |
[Monotone-commits-diffs] net.venge.monotone: 929a68cba94945ced461581d7c9a80a037050fde |
Date: |
Mon, 21 Feb 2011 04:03:55 +0100 (CET) |
revision: 929a68cba94945ced461581d7c9a80a037050fde
date: 2011-02-21T03:03:05
author: Richard Levitte <address@hidden>
branch: net.venge.monotone
changelog:
merge of '1c7ee25eb013bddef5de8d11a8cf4df0980bf74a'
and '3fdbae2f1a2277e919238fb62b72455dcfd3acc0'
manifest:
format_version "1"
new_manifest [a27f540ffd1c346c1c476c8b5ae28257409efd62]
old_revision [1c7ee25eb013bddef5de8d11a8cf4df0980bf74a]
rename "test/func/netsync_key_hook"
to "test/func/netsync_key_hooks"
add_dir "test/func/netsync_bind_opt"
add_file "test/func/netsync_bind_opt/__driver__.lua"
content [153c2be3d3c3c37b4fea590633d2d3be9bae5e82]
add_file "test/func/netsync_key_hooks/server-hooks.lua"
content [434dab628a58b2c644f5ad6997420f1186cabbb5]
patch ".mtn-ignore"
from [ee776b54b58b1d3cc4265cdfa09a6d426ae1f6c5]
to [347361ce3fa47016cbe4f5ba29188696d939a1d8]
patch "NEWS"
from [967b9dd1fb16df472af1276784e67aa20fb49b53]
to [848a8d23c760b709d5954ef1ca4a812c72404343]
patch "doc/monotone.texi"
from [73e344eb1ba340193ab61f755d72979a29c58fde]
to [5c18cff828089e592f5f2d53c2d60793715a4a40]
patch "src/keys.cc"
from [bdf4a6b94902d29411b16cb169851986a16b3956]
to [19db9fa939a1d87aba964f4e84743adcfff6fdd2]
patch "src/lua_hooks.cc"
from [33d6643e8776fa87296f47658fdbfd3001e3cfd9]
to [1c178085332c73dcefb4681d205d17b059e52080]
patch "src/lua_hooks.hh"
from [325fd5a4b588ff4d41e3cec69cbf652089a33fa9]
to [66412b9fa5db97cd3b3ec01cadf036fb346ac161]
patch "src/network/connection_info.cc"
from [78789566ad076c92d8795ea7e3877646c3749693]
to [b732c16161db2394aac449f50c6a6921e553ef22]
patch "src/network/connection_info.hh"
from [8841c299c1a214c46071b6f77c3a5dbadeaf4959]
to [0ba5fc1778b78fb3446ad345ec78e073fd9221e4]
patch "test/func/netsync_key_hooks/__driver__.lua"
from [87963f895052ee9dd35d513e23004811169bca38]
to [d7fad5a70688d3db512a05ebb0e3643006f8c7e2]
patch "test/func/netsync_key_hooks/client-hooks.lua"
from [f60d553a6bff838e53904f94294588d9f9ed84ee]
to [e9eb38666d23a1f4a5be33404220902ee90756eb]
old_revision [3fdbae2f1a2277e919238fb62b72455dcfd3acc0]
patch "Makefile.am"
from [76876b1be2336cc1f70ad906309e148e5d67ff7d]
to [3ed4ef8a5b08b7c1e4bf6dc3fe0c9c41c40ff64f]
patch "contrib/monotone-cluster-push.lua"
from [2ee0e849058ea7bbef9487fc21772d1fb66500d6]
to [3a4f3bd0394d70d5c07c9314ad42026b212a4983]
============================================================
--- NEWS 967b9dd1fb16df472af1276784e67aa20fb49b53
+++ NEWS 848a8d23c760b709d5954ef1ca4a812c72404343
@@ -29,6 +29,13 @@ XXX XXX XX XX:XX:XX UTC 2011
messages from mtn automate, regardless of the locale of the
calling process.
+ - The hook 'get_netsync_key' has been split up into two separate
+ hooks, one for client usage ('get_netsync_client_key', with
+ the same arguments as the original 'get_netsync_key') and one
+ for server usage ('get_netsync_server_key', with a single table
+ argument containing all the given '--bind' options). Please
+ review your custom hooks accordingly.
+
- Short options ('-b', '-d', ...) are no longer completed. This
fixes an invariant failure originating from wrong option usage.
(closes monotone issue 141)
@@ -87,6 +94,19 @@ XXX XXX XX XX:XX:XX UTC 2011
if no database is specified for these commands.
(fixes monotone issue 113)
+ - If 'mtn serve' is called with one or more '--bind' options, then
+ the arguments to these options can now be specified again
+ as follows:
+
+ '<ip-or-host>'
+ to listen to IP or host on the default port
+ '<ip-or-host>:<port>'
+ to listen to IP or host on the specified port - or
+ ':<port>'
+ to listen on all interfaces on the specified port
+
+ (fixes monotone issue 119)
+
- monotone does no longer enforce ".mtn" as file extension
for managed databases. Instead a new Lua hook,
get_default_database_glob(), is used to determine a pattern
============================================================
--- src/keys.cc bdf4a6b94902d29411b16cb169851986a16b3956
+++ src/keys.cc 19db9fa939a1d87aba964f4e84743adcfff6fdd2
@@ -183,13 +183,20 @@ cache_netsync_key(options const & opts,
found_key = true;
}
}
- else if (lua.hook_get_netsync_key(utf8(info->client.get_uri().resource(), origin::user),
- info->client.get_include_pattern(),
- info->client.get_exclude_pattern(),
- keys, project, key))
+ else if (info->info_type == netsync_connection_info::client_info &&
+ lua.hook_get_netsync_client_key(utf8(info->client.get_uri().resource(), origin::user),
+ info->client.get_include_pattern(),
+ info->client.get_exclude_pattern(),
+ keys, project, key))
{
found_key = true;
}
+ else if (info->info_type == netsync_connection_info::server_info &&
+ lua.hook_get_netsync_server_key(info->server.addrs,
+ keys, project, key))
+ {
+ found_key = true;
+ }
else
{
found_key = get_only_key(keys, key_requiredness, key);
============================================================
--- src/lua_hooks.cc 33d6643e8776fa87296f47658fdbfd3001e3cfd9
+++ src/lua_hooks.cc 1c178085332c73dcefb4681d205d17b059e52080
@@ -783,17 +783,17 @@ bool
}
bool
-lua_hooks::hook_get_netsync_key(utf8 const & server_address,
- globish const & include,
- globish const & exclude,
- key_store & keys,
- project_t & project,
- key_id & k)
+lua_hooks::hook_get_netsync_client_key(utf8 const & server_address,
+ globish const & include,
+ globish const & exclude,
+ key_store & keys,
+ project_t & project,
+ key_id & k)
{
string name;
bool exec_ok
= Lua(st)
- .func("get_netsync_key")
+ .func("get_netsync_client_key")
.push_str(server_address())
.push_str(include())
.push_str(exclude())
@@ -812,6 +812,41 @@ lua_hooks::hook_get_netsync_key(utf8 con
}
}
+bool
+lua_hooks::hook_get_netsync_server_key(vector<utf8> const & server_ports,
+ key_store & keys,
+ project_t & project,
+ key_id & k)
+{
+ string name;
+ Lua ll(st);
+ ll.func("get_netsync_server_key");
+
+ ll.push_table();
+ vector<utf8>::const_iterator i;
+ int j;
+ for (i = server_ports.begin(), j = 1; i != server_ports.end(); ++i, ++j)
+ {
+ ll.push_int(j);
+ ll.push_str((*i)());
+ ll.set_table();
+ }
+
+ bool exec_ok = ll.call(1, 1)
+ .extract_str(name)
+ .ok();
+
+ if (!exec_ok || name.empty())
+ return false;
+ else
+ {
+ key_identity_info identity;
+ project.get_key_identity(keys, *this, external_key_name(name, origin::user), identity);
+ k = identity.id;
+ return true;
+ }
+}
+
static void
push_uri(uri_t const & uri, Lua & ll)
{
============================================================
--- src/lua_hooks.hh 325fd5a4b588ff4d41e3cec69cbf652089a33fa9
+++ src/lua_hooks.hh 66412b9fa5db97cd3b3ec01cadf036fb346ac161
@@ -80,12 +80,16 @@ public:
map<key_id, bool> const & new_results);
// network hooks
- bool hook_get_netsync_key(utf8 const & server_address,
- globish const & include,
- globish const & exclude,
- key_store & keys,
- project_t & project,
- key_id & k);
+ bool hook_get_netsync_client_key(utf8 const & server_address,
+ globish const & include,
+ globish const & exclude,
+ key_store & keys,
+ project_t & project,
+ key_id & k);
+ bool hook_get_netsync_server_key(vector<utf8> const & server_ports,
+ key_store & keys,
+ project_t & project,
+ key_id & k);
bool hook_get_netsync_connect_command(uri_t const & uri,
globish const & include_pattern,
globish const & exclude_pattern,
============================================================
--- doc/monotone.texi 73e344eb1ba340193ab61f755d72979a29c58fde
+++ doc/monotone.texi 5c18cff828089e592f5f2d53c2d60793715a4a40
@@ -4687,12 +4687,15 @@ @subsection Global Options
For a non-netsync command, the Lua hook @address@hidden is
called.
-For a netsync command, the Lua hook @address@hidden is
-called.
+For a client-side netsync command, the Lua hook
address@hidden@ref{get_netsync_client_key}} is called.
-If the hook returns non-nil, the return value is the name of the
-key.
+For a command that starts a monotone server, the Lua hook
address@hidden@ref{get_netsync_server_key}} is used.
+If any of the aforementioned hooks returns non-nil, the return value
+is the name of the key.
+
@item
If there is only one key in the keydir, that is the key.
@@ -11419,12 +11422,12 @@ @subsection User Defaults
There is no default definition for this hook; it returns nil.
address@hidden@item get_netsync_key(@var{server}, @var{include}, @var{exclude})
address@hidden@item get_netsync_client_key(@var{server}, @var{include}, @var{exclude})
-Called by the server and client when a netsync connection is being
-established, and @address@hidden was not given. Returns a string
-which is the name or hash of the key to use to authenticate the
-netsync connection.
+Called by the client when a netsync connection is being established,
+and @address@hidden was not given. Returns a string which is the name
+or hash of the key to use to authenticate the client side of a netsync
+connection.
Note that netsync commands do not need a signing key; they only transmit
already signed information.
@@ -11432,32 +11435,44 @@ @subsection User Defaults
See @address@hidden for a discussion of how monotone determines
what key to use.
-Arguments, when called by the server:
+Arguments, when called:
@table @var
@item server
-The address monotone is listening on.
+The scheme, user, host, port, and path fields from the URI provided on
+the command line. See @ref{netsync uri}.
@item include
-"*"
+The include pattern in the URI provided on the command line.
@item exclude
-""
+The exclude pattern in the URI provided on the command line.
+
@end table
-When called by the client:
address@hidden@item get_netsync_server_key(@var{addresses})
address@hidden @var
address@hidden server
-The scheme, user, host, port, and path fields from the URI provided on
-the command line. See @ref{netsync uri}.
+Called by the server when a new netsync server instance is created, and
address@hidden@ref{--key}} was not given. Returns a string which is the name
+or hash of the key to use to authenticate the server side of a netsync
+connection.
address@hidden include
-The include pattern in the URI provided on the command line.
+Note that netsync commands do not need a signing key; they only transmit
+already signed information.
address@hidden exclude
-The exclude pattern in the URI provided on the command line.
+See @address@hidden for a discussion of how monotone determines
+what key to use.
+Arguments, when called:
+
address@hidden @var
address@hidden addresses
+A table of addresses given to monotone via the @option{--bind} option that
+denote the addresses and / or ports monotone is listening on for connections.
+If the address in one of the table entries is omitted, the port must be given
+with a leading colon; in this case monotone listens on all interfaces on this
+port.
+
@end table
@address@hidden get_default_command_options(@var{command})
============================================================
--- .mtn-ignore ee776b54b58b1d3cc4265cdfa09a6d426ae1f6c5
+++ .mtn-ignore 347361ce3fa47016cbe4f5ba29188696d939a1d8
@@ -16,7 +16,8 @@
^doc/stamp-vti$
^doc/texinfo\.tex$
^doc/version\.texi$
-^html
+^extra/building/dump-test-logs.sh$
+^extra/shell/monotone.bash_completion$
^install-sh$
^m4/codeset\.m4$
^m4/gettext\.m4$
@@ -55,7 +56,7 @@
^po/insert-header\.sin$
^po/monotone\.pot$
^po/quot\.sed$
-^run_(func|tester|unit)_tests$
+^run_(extra|func|tester|unit)_tests$
^src/package_(full_)?revision(\.cc|\.txt|_(dist|raw)\.txt)$
^src/schema\.cc$
^src/std_hooks\.cc$
============================================================
--- test/func/netsync_key_hook/__driver__.lua 87963f895052ee9dd35d513e23004811169bca38
+++ test/func/netsync_key_hooks/__driver__.lua d7fad5a70688d3db512a05ebb0e3643006f8c7e2
@@ -1,6 +1,10 @@ mtn_setup()
includecommon("netsync.lua")
mtn_setup()
+
+--
+-- test get_netsync_client_key
+--
netsync.setup()
writefile("foo", "bar")
@@ -21,6 +25,7 @@ function client(what, ret)
"--keydir=keys",
"--db=test.db", srv.address,
"--rcfile=client-hooks.lua",
+ "--no-workspace",
"*"}
for k, v in pairs(args) do
table.insert(what, v)
@@ -34,3 +39,33 @@ srv:stop()
client({"pull", "address@hidden"}, 1)
srv:stop()
+
+--
+-- test get_netsync_server_key
+--
+
+get("server-hooks.lua")
+-- we send a SIGTERM to the server process to stop it, so this is also
+-- what we expect as (negated) return value
+SIGTERM=15
+
+function server(what, ret, exp_err)
+ local addr = "localhost:" .. math.random(1024, 65535)
+ args = {"--rcfile=test_hooks.lua",
+ "--keydir=keys",
+ "--db=test.db", "--bind=" .. addr,
+ "--no-workspace",
+ "serve"}
+ for k, v in pairs(args) do
+ table.insert(what, v)
+ end
+ srv = bg(raw_mtn(unpack(what)), ret, false, true)
+ srv:finish(3)
+ if exp_err ~= nil then
+ check(qgrep(exp_err, "stderr"))
+ end
+end
+
+server({}, 1, "you have multiple private keys")
+server({"--rcfile", "server-hooks.lua"}, -SIGTERM, "beginning service on localhost")
+
============================================================
--- test/func/netsync_key_hook/client-hooks.lua f60d553a6bff838e53904f94294588d9f9ed84ee
+++ test/func/netsync_key_hooks/client-hooks.lua e9eb38666d23a1f4a5be33404220902ee90756eb
@@ -1,3 +1,3 @@
-function get_netsync_key(server, include, exclude)
+function get_netsync_client_key(server, include, exclude)
return "address@hidden"
end
============================================================
--- src/network/connection_info.cc 78789566ad076c92d8795ea7e3877646c3749693
+++ src/network/connection_info.cc b732c16161db2394aac449f50c6a6921e553ef22
@@ -279,7 +279,7 @@ netsync_connection_info::Client::set_raw
if (uri.scheme.empty())
uri.scheme = "mtn";
-
+
E(uri.scheme != "mtn" || !uri.host.empty(), origin::user,
F("a non-empty hostname is expected for the 'mtn' uri scheme"));
@@ -400,6 +400,7 @@ netsync_connection_info::setup_default(o
shared_conn_info & info)
{
info.reset(new netsync_connection_info(db, opts));
+ info->info_type = client_info;
info->client.conn_type = type;
info->client.ensure_completeness();
@@ -414,6 +415,7 @@ netsync_connection_info::setup_from_sync
shared_conn_info & info)
{
info.reset(new netsync_connection_info(db, opts));
+ info->info_type = client_info;
info->client.conn_type = netsync_connection;
info->client.set_raw_uri(request.address);
@@ -461,6 +463,7 @@ netsync_connection_info::setup_from_uri(
shared_conn_info & info)
{
info.reset(new netsync_connection_info(db, opts));
+ info->info_type = client_info;
info->client.conn_type = type;
info->client.set_raw_uri(uri());
@@ -497,6 +500,7 @@ netsync_connection_info::setup_from_serv
"please consider using the URI calling syntax instead"));
info.reset(new netsync_connection_info(db, opts));
+ info->info_type = client_info;
info->client.conn_type = type;
info->client.set_raw_uri(host());
@@ -515,6 +519,7 @@ netsync_connection_info::setup_for_serve
shared_conn_info & info)
{
info.reset(new netsync_connection_info(db, opts));
+ info->info_type = server_info;
info->server.addrs = opts.bind_uris;
info->client.conn_type = netsync_connection;
@@ -523,16 +528,6 @@ netsync_connection_info::setup_for_serve
E(lua.hook_persist_phrase_ok(), origin::user,
F("need permission to store persistent passphrase "
"(see hook persist_phrase_ok())"));
-
- // the uri as well as the include / exclude pattern are
- // not used directly for serve, but need to be configured
- // in order to let keys::cache_netsync_key() call the
- // get_netsync_key() hook properly
- if (!opts.bind_uris.empty())
- info->client.set_raw_uri((*opts.bind_uris.begin())());
-
- info->client.include_pattern = globish("*", origin::internal);
- info->client.exclude_pattern = globish("", origin::internal);
}
else if (!opts.bind_stdio)
W(F("The --no-transport-auth option is usually only used "
============================================================
--- src/network/connection_info.hh 8841c299c1a214c46071b6f77c3a5dbadeaf4959
+++ src/network/connection_info.hh 0ba5fc1778b78fb3446ad345ec78e073fd9221e4
@@ -102,6 +102,8 @@ struct netsync_connection_info
struct netsync_connection_info
{
+ enum { client_info, server_info } info_type;
+
class Server
{
public:
============================================================
--- /dev/null
+++ test/func/netsync_bind_opt/__driver__.lua 153c2be3d3c3c37b4fea590633d2d3be9bae5e82
@@ -0,0 +1,27 @@
+skip_if(not existsonpath("netstat"))
+
+includecommon("netsync.lua")
+mtn_setup()
+netsync.setup()
+
+math.randomseed(get_pid())
+local port = math.random(1024, 65535)
+
+-- test with host:port
+srv = netsync.start({"--bind", "localhost:" .. port})
+check({"netstat", "-a", "-n"}, 0, true, false)
+check(qgrep("127[.]0[.]0[.]1[.:]" .. port, "stdout"))
+srv:stop()
+
+-- test with ip:port
+srv = netsync.start({"--bind", "127.0.0.1:" .. port})
+check({"netstat", "-a", "-n"}, 0, true, false)
+check(qgrep("127[.]0[.]0[.]1[.:]" .. port, "stdout"))
+srv:stop()
+
+-- test only with :port
+srv = netsync.start({"--bind", ":" .. port})
+check({"netstat", "-a", "-n"}, 0, true, false)
+check(qgrep("([*]|0[.]0[.]0[.]0)[.:]" .. port, "stdout"))
+srv:stop()
+
============================================================
--- /dev/null
+++ test/func/netsync_key_hooks/server-hooks.lua 434dab628a58b2c644f5ad6997420f1186cabbb5
@@ -0,0 +1,3 @@
+function get_netsync_server_key(addresses)
+ return "address@hidden"
+end
============================================================
--- Makefile.am 76876b1be2336cc1f70ad906309e148e5d67ff7d
+++ Makefile.am 3ed4ef8a5b08b7c1e4bf6dc3fe0c9c41c40ff64f
@@ -257,6 +257,11 @@ dist_mtnscripts_SCRIPTS = extra/mtn-hook
mtnscriptsdir = $(monotonedir)/scripts
dist_mtnscripts_SCRIPTS = extra/mtn-hooks/monotone-mail-notify
+# Some of the smaller programs do not have --help or --version,
+# make them exempt of the check for those. NOTE: use this sparingly!
+AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = \
+ extra/bin/mtn-cleanup extra/mtn-hooks/monotone-mail-notify
+
# flags
# sets DEFS for just this object (autoconf's -DHAVE_CONFIG_H is useless)
@@ -693,7 +698,8 @@ BUILT_SOURCES = $(PCH_FILE) $(PCH_BUILD)
BUILT_SOURCES = $(PCH_FILE) $(PCH_BUILD)
-CLEANFILES = $(bin_SCRIPTS) $(bashcomp_DATA) $(BUILT_SOURCES) $(CLEAN_SRCS) $(CLEAN_POFILES)
+CLEANFILES = $(bin_SCRIPTS) $(noinst_SCRIPTS) $(bashcomp_DATA) \
+ $(BUILT_SOURCES) $(CLEAN_SRCS) $(CLEAN_POFILES)
# automake provides no nice way to build a helper program to execute
# on the build machine, so we need our own rule. almost all the
============================================================
--- contrib/monotone-cluster-push.lua 2ee0e849058ea7bbef9487fc21772d1fb66500d6
+++ contrib/monotone-cluster-push.lua 3a4f3bd0394d70d5c07c9314ad42026b212a4983
@@ -210,7 +210,7 @@ do
end
if certs_in > 0 or revs_in > 0 or keys_in > 0 then
local pattern_branches =
- process_rcfile("not_netsync_end", MCP_rcfile, nil)
+ process_rcfile("note_netsync_end", MCP_rcfile, nil)
if pattern_branches then
for pattern, servers in pairs(pattern_branches) do
if globish_match(pattern, branch) then
@@ -222,7 +222,7 @@ do
io.stderr:write("note_netsync_end: ",
"pushing pattern \"", pattern,
"\" to server ", server, "\n")
- server_request_sync("push", server, pattern, "")
+ server_request_sync("push", server.."?"..pattern, "")
end
end
end
@@ -232,7 +232,5 @@ do
end
}
- local saved_note_mtn_startup = note_mtn_startup
-
push_netsync_notifier(notifier)
end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Monotone-commits-diffs] net.venge.monotone: 929a68cba94945ced461581d7c9a80a037050fde,
code <=