RPC: Add option -stdinrpcpass to bitcoin-cli to allow RPC password to be read from standard input #10997

pull jharvell wants to merge 1 commits into bitcoin:master from jharvell:stdinrpcpass changing 1 files +10 −3
  1. jharvell commented at 4:14 pm on August 6, 2017: none

    Add a new command-line option to bitcoin-cli that allows the RPC password to be read from standard intput. The purpose of this option is to allow secure RPC password input to bitcoin-cli through an external program that is capable of disabling terminal echo.

    This option works similarly to the existing -stdin option, and also works when combined with that option.

    I have also written a simple ncurses based program that disables echo, gets input from the terminal and writes to standard output. I couldn’t find an existing askpass program that doesn’t require graphics libraries, since they are primarily used for getting passwords in a graphics environment. Unless someone can point out a suitable existing askpass program, I plan to submit my ncurses program to the contrib directory separately from this pull request.

  2. jharvell renamed this:
    Add option -stdinrpcpass to allow RPC password to be read from stdin
    RPC: Add option -stdinrpcpass to allow RPC password to be read from standard input
    on Aug 6, 2017
  3. jharvell renamed this:
    RPC: Add option -stdinrpcpass to allow RPC password to be read from standard input
    RPC: Add option -stdinrpcpass to bitcoin-cli to allow RPC password to be read from standard input
    on Aug 7, 2017
  4. jharvell commented at 6:18 am on August 7, 2017: none
    I created an askpass utility program (https://github.com/jharvell/askpass) since I didn’t find one to my liking. In particular, this one supports mult-line input which would be needed for -stdinrpcpass combined with -stdin.
  5. fanquake added the label RPC/REST/ZMQ on Aug 7, 2017
  6. in src/bitcoin-cli.cpp:310 in 558ba86d1a outdated
    301@@ -293,6 +302,13 @@ int CommandLineRPC(int argc, char *argv[])
    302             argc--;
    303             argv++;
    304         }
    305+        std::string rpcPass;
    306+        if (GetBoolArg("-stdinrpcpass", false)) {
    307+            if(!std::getline(std::cin,rpcPass)) {
    308+                std::cerr<<"error: -stdinrpcpass specified but failed to read from standard input\n";
    309+                return EXIT_FAILURE;
    310+            }
    


    laanwj commented at 9:32 am on August 8, 2017:
    Suggestion: ForceSetArg("-rpcpassword", rpcPass) here, I think this avoids most of the other changes.

    jharvell commented at 5:40 pm on August 8, 2017:
    done
  7. in src/bitcoin-cli.cpp:308 in 558ba86d1a outdated
    301@@ -293,6 +302,13 @@ int CommandLineRPC(int argc, char *argv[])
    302             argc--;
    303             argv++;
    304         }
    305+        std::string rpcPass;
    306+        if (GetBoolArg("-stdinrpcpass", false)) {
    307+            if(!std::getline(std::cin,rpcPass)) {
    308+                std::cerr<<"error: -stdinrpcpass specified but failed to read from standard input\n";
    


    laanwj commented at 9:35 am on August 8, 2017:
    Please use throw std::runtime_error("-stdinrpcpass specified but failed to read from standard input"), this will do automatically the right thing (like adding error: in front, adding a newline and setting the return code).

    jharvell commented at 5:39 pm on August 8, 2017:
    done
  8. jharvell force-pushed on Aug 8, 2017
  9. jharvell commented at 10:52 pm on August 8, 2017: none

    I realized I had committed with the wrong author email. So I did a rebase where I amended the author email. Both commits are the same content, just now with the correct author email (and hash).

    Also, let me know if you want me to do one last rebase and squash to a single commit if/before you merge to master.

  10. in src/bitcoin-cli.cpp:233 in cb8cf16fd1 outdated
    232     } else {
    233-        strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", "");
    234+        strRPCUserColonPass = GetArg("-rpcuser", strRPCUserColonPass);
    235+        if (strRPCUserColonPass.empty()) {
    236+            throw std::runtime_error(strprintf(
    237+                _("Could not locate RPC credentials. No authentication cookie could be found, and RPC user is not set.  See -rpcuser.  Configuration file: (%s)"),
    


    laanwj commented at 8:35 am on August 10, 2017:
    I don’t understand this change. I think it’s better to leave it out as it’s not relevant to adding -stdinrpcpass, it also duplicates the credentials error which is a bit ugly.

    jharvell commented at 3:59 pm on August 10, 2017:

    Without this change, it is possible to specify an RPC password (either through explicit option for via -stdinrpcpass) without specifying an RPC user. In this case, the authentication token is “:<rpcpass>”. I had assumed that this could never match and was an error. Now that I think about it, perhaps this was an intentional mechanism to allow an empty RPC user.

    In any case, I will remove this change.


    jharvell commented at 4:07 pm on August 10, 2017:

    done.

    Also, let me know if/when to rebase to combine these three commits into one.

  11. laanwj commented at 10:41 am on August 23, 2017: member

    Looks good to me now utACK. Would be nice if someone could test, though.

    Also, let me know if you want me to do one last rebase and squash to a single commit if/before you merge to master.

    Yes please.

  12. laanwj assigned laanwj on Aug 23, 2017
  13. jonasschnelli commented at 10:52 am on August 23, 2017: contributor
    utACK 4bd8775ec3ea1d32a15aad9ceb6fcf21694df9d6 (yes, please squash).
  14. Add option -stdinrpcpass to allow RPC password to be read from standard input 79191f51b5
  15. jharvell force-pushed on Aug 23, 2017
  16. jharvell commented at 6:52 pm on August 23, 2017: none
    squashed to single commit
  17. laanwj commented at 6:53 am on August 24, 2017: member
    Tested ACK 79191f5
  18. laanwj merged this on Aug 24, 2017
  19. laanwj closed this on Aug 24, 2017

  20. laanwj referenced this in commit affe9271aa on Aug 24, 2017
  21. in src/bitcoin-cli.cpp:299 in 79191f51b5
    293@@ -293,6 +294,12 @@ int CommandLineRPC(int argc, char *argv[])
    294             argc--;
    295             argv++;
    296         }
    297+        std::string rpcPass;
    298+        if (gArgs.GetBoolArg("-stdinrpcpass", false)) {
    299+            if(!std::getline(std::cin,rpcPass))
    


    promag commented at 1:06 pm on August 24, 2017:
    Nit, missing spaces after if and , and missing {. @laanwj I’m writing a test for bitcoin-cli, maybe add a commit there to fix these?
  22. jharvell deleted the branch on Aug 25, 2017
  23. luke-jr referenced this in commit 3b78bd259c on Sep 2, 2017
  24. laanwj referenced this in commit 645a7ecc0b on Sep 6, 2017
  25. PastaPastaPasta referenced this in commit 6c988088cd on Sep 19, 2019
  26. PastaPastaPasta referenced this in commit ab126d100b on Sep 23, 2019
  27. PastaPastaPasta referenced this in commit 74801efebf on Sep 23, 2019
  28. PastaPastaPasta referenced this in commit 2ff19a464f on Sep 24, 2019
  29. PastaPastaPasta referenced this in commit a1b2915923 on Sep 24, 2019
  30. PastaPastaPasta referenced this in commit 43c8313303 on Nov 19, 2019
  31. PastaPastaPasta referenced this in commit 502b1c0387 on Nov 19, 2019
  32. PastaPastaPasta referenced this in commit fd8237ca96 on Nov 21, 2019
  33. PastaPastaPasta referenced this in commit 7329569cda on Nov 21, 2019
  34. PastaPastaPasta referenced this in commit 9b27f06121 on Dec 9, 2019
  35. PastaPastaPasta referenced this in commit 82035124bf on Dec 9, 2019
  36. PastaPastaPasta referenced this in commit 95de0a358f on Jan 1, 2020
  37. PastaPastaPasta referenced this in commit e9355f9eec on Jan 1, 2020
  38. PastaPastaPasta referenced this in commit 6068e2714a on Jan 2, 2020
  39. PastaPastaPasta referenced this in commit 871903f0d2 on Jan 2, 2020
  40. PastaPastaPasta referenced this in commit c68bb7a697 on Jan 2, 2020
  41. PastaPastaPasta referenced this in commit 946eb1599f on Jan 2, 2020
  42. PastaPastaPasta referenced this in commit cb7c8b1b80 on Jan 2, 2020
  43. PastaPastaPasta referenced this in commit 8aeb9e2f86 on Jan 2, 2020
  44. PastaPastaPasta referenced this in commit 94e31aef89 on Jan 2, 2020
  45. PastaPastaPasta referenced this in commit 9ae12e04e2 on Jan 2, 2020
  46. PastaPastaPasta referenced this in commit 39c2079743 on Jan 2, 2020
  47. PastaPastaPasta referenced this in commit 8931d4dd85 on Jan 2, 2020
  48. PastaPastaPasta referenced this in commit eac4ea76e4 on Jan 2, 2020
  49. PastaPastaPasta referenced this in commit 3b620c356c on Jan 3, 2020
  50. PastaPastaPasta referenced this in commit 7214f07e78 on Jan 3, 2020
  51. PastaPastaPasta referenced this in commit 3b1696a7e6 on Jan 4, 2020
  52. PastaPastaPasta referenced this in commit 09e4b00321 on Jan 12, 2020
  53. PastaPastaPasta referenced this in commit 1e1a79a68f on Jan 12, 2020
  54. PastaPastaPasta referenced this in commit 5de97013f2 on Jan 12, 2020
  55. jasonbcox referenced this in commit d4280f43d3 on Oct 25, 2020
  56. ckti referenced this in commit a2de18cba1 on Mar 28, 2021
  57. ckti referenced this in commit 6ae78314c7 on Mar 28, 2021
  58. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-29 07:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me