[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] --non-interactive: run in non-interactive

From: Zbigniew Zagórski
Subject: [Monotone-devel] --non-interactive: run in non-interactive
Date: Wed, 30 Jan 2008 23:58:39 +0100
User-agent: Thunderbird (Windows/20071031)


I'm hacking silently at mtteam again I hit the wall of "safe commit".

Safe means that I'm sure that monotone will not ask anything from
stdin/tty user but fail miserably with some error message. Thus it's
guarantee that it will never hang up.

The only two places that monotone interacts with user are:
 - commit
 - cert, approve, testresult
 - merge*
 - genkey (doesn't count, because it has automate counterpart)

From my point of view interesting commands are commit and cert*
derivatives. They can ask for password. GUI doesn't like it.

So i invented --never-prompt-password, and started to hack ;). Later
on I've decided that --non-interactive global option will be better.

When you'll specify this option to mtn it will never ask for a password. If the password is needed (no lua hook, no key in ssh-agent) it will clearly fail with some informative message.

In current state this option will affect password prompt only, but it can be used in future commands to check if user wants to make decisions.

back to the patch ...

After five minutes it appeared that almost all functions from keys.hh
must accept app_state& instead of lua_hooks& only:

-get_private_key(lua_hooks & lua, ...
+get_private_key(app_state & app, ...
-get_passphrase(lua_hooks & lua, ...
+get_passphrase(app_state & app, ...
-void encrypt_rsa(lua_hooks & lua,
+void encrypt_rsa(app_state & app,
-void decrypt_rsa(lua_hooks & lua,
+void decrypt_rsa(app_state & app,

and so on. Is it ok for you ?

Core of patch consist of
1. adding --non-interactive "run in non-interactive mode (never ask

2. modification of get_passphrase(

@@ -75,7 +75,7 @@ void
 // 'force_from_user' means that we don't use the passphrase cache,
 // don't use the get_passphrase hook.
-get_passphrase(lua_hooks & lua,
+get_passphrase(app_state & app,
                rsa_keypair_id const & keyid,
                utf8 & phrase,
                bool confirm_phrase,

   string lua_phrase;
-  if (!force_from_user && lua.hook_get_passphrase(keyid, lua_phrase))
+  if (!force_from_user && app.lua.hook_get_passphrase(keyid,
+       lua_phrase))
       phrase = utf8(lua_phrase);
       N(phrase != utf8(""),
         F("got empty passphrase from get_passphrase() hook"));
+  else if( app.opts.non_interactive )
+    {
+      F("reading passphrase from terminal forbidden by explicit "
+        "option");
+    }
       char pass1[constants::maxpasswd];


Do you like this idea ? I'll send finished patch for review.

PS. I know that commit from automate would be the best way but we
can't wait for it (sadly, it's too big task for me to do it now ).
mtteam is in almost usable state and the only blocking issue is
commit. We'll gladly switch to 'automate commit' when it will be done.

PS2. I'm sure guitone also looks for solution to "commit from GUI"

Best regards,
Zbigniew Zagórski
/ software developer / geek / happy daddy /

reply via email to

[Prev in Thread] Current Thread [Next in Thread]