# # # patch "cmd_netsync.cc" # from [424c270866fc33f5067b2399f5f77920b9bce99c] # to [37e31660e83fcd5cd6cff8fd3b5b8b2f019181da] # ============================================================ --- cmd_netsync.cc 424c270866fc33f5067b2399f5f77920b9bce99c +++ cmd_netsync.cc 37e31660e83fcd5cd6cff8fd3b5b8b2f019181da @@ -237,6 +237,42 @@ CMD(push, "push", "", CMD_REF(network), client_voice, source_role, info); } +CMD_AUTOMATE(push, N_("[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), + N_("Pushes branches to a netsync server"), + "", + options::opts::set_default | options::opts::exclude | + options::opts::key_to_push | options::opts::do_not_enforce_ssh_agent) +{ + database db(app); + key_store keys(app); + project_t project(db); + + if (!app.opts.do_not_enforce_ssh_agent) + { + // enforce that any command which needs to encrypt a private key later on + // uses the ssh_agent to do the task, because we cannot handle password + // prompts over stdio. basically this is the same as giving --ssh-sign=only + // as option to stdio, but it is more explicit. however, this also leaves + // the opportunity of giving a possible passphrase via the get_passphrase + // lua hook, because the ssh agent is _always_ used, but its a reasonable + // trade-off + keys.enforce_ssh_agent(); + } + + netsync_connection_info info; + extract_client_connection_info(app.opts, app.lua, db, keys, args, info); + + if (app.opts.signing_key() != "" && !app.opts.do_not_enforce_ssh_agent) + { + N(keys.agent_knows_key(app.opts.signing_key), + F("key '%s' is unknown to the running ssh-agent instance") + % app.opts.signing_key); + } + + run_netsync_protocol(app.opts, app.lua, project, keys, + client_voice, source_role, info); +} + CMD(pull, "pull", "", CMD_REF(network), N_("[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), N_("Pulls branches from a netsync server"), @@ -263,8 +299,7 @@ CMD_AUTOMATE(pull, N_("[ADDRESS[:PORTNUM N_("Pulls branches from a netsync server"), "", options::opts::set_default | options::opts::exclude | - options::opts::do_not_enforce_ssh_agent -) + options::opts::do_not_enforce_ssh_agent) { database db(app); key_store keys(app); @@ -310,7 +345,7 @@ CMD(sync, "sync", "", CMD_REF(network), N_("This synchronizes branches that match the pattern given in PATTERN " "with the netsync server at the address ADDRESS."), options::opts::set_default | options::opts::exclude | - options::opts::key_to_push) + options::opts::key_to_push | options::opts::do_not_enforce_ssh_agent) { database db(app); key_store keys(app); @@ -330,6 +365,42 @@ CMD(sync, "sync", "", CMD_REF(network), client_voice, source_and_sink_role, info); } +CMD_AUTOMATE(sync, N_("[ADDRESS[:PORTNUMBER] [PATTERN ...]]"), + N_("Synchronizes branches with a netsync server"), + "", + options::opts::set_default | options::opts::exclude | + options::opts::key_to_push) +{ + database db(app); + key_store keys(app); + project_t project(db); + + if (!app.opts.do_not_enforce_ssh_agent) + { + // enforce that any command which needs to encrypt a private key later on + // uses the ssh_agent to do the task, because we cannot handle password + // prompts over stdio. basically this is the same as giving --ssh-sign=only + // as option to stdio, but it is more explicit. however, this also leaves + // the opportunity of giving a possible passphrase via the get_passphrase + // lua hook, because the ssh agent is _always_ used, but its a reasonable + // trade-off + keys.enforce_ssh_agent(); + } + + netsync_connection_info info; + extract_client_connection_info(app.opts, app.lua, db, keys, args, info); + + if (app.opts.signing_key() != "" && !app.opts.do_not_enforce_ssh_agent) + { + N(keys.agent_knows_key(app.opts.signing_key), + F("key '%s' is unknown to the running ssh-agent instance") + % app.opts.signing_key); + } + + run_netsync_protocol(app.opts, app.lua, project, keys, + client_voice, source_and_sink_role, info); +} + class dir_cleanup_helper { public: