Uploaded image for project: 'MongoDB Database Tools'
  1. MongoDB Database Tools
  2. TOOLS-2688

mongodump does not handle EOF when passing in the password as STDIN

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Trivial - P5 Trivial - P5
    • 100.2.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      mongodump version: 4.0.18

      $ mongodump --version
      mongodump version: r4.0.18
      git version: 6883bdfb8b8cff32176b1fd176df04da9165fd67
      Go version: go1.11.13
         os: linux
         arch: amd64
         compiler: gc
      OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
      

      We're using a new method (vault kv get) to get the admin passwords for our mongodb clusters, however, it gets the password without an EOF. This is fine for the mongo CLI, but not for mongodump.

      For example, this works with the mongo cli:

      # 'echo -n' simulates the password output from {{vault kv get}}
      echo -n PASSWORD | mongo --host mongohost:27017 --authenticationDatabase admin -u admin --password '' --eval 'db.version()'
      

      However, I get the following error when attempting to use mongodump with a password without EOF:

      $ echo -n PASSWORD | mongodump --oplog --host configReplSet/mongohost:27019 --authenticationDatabase admin -u admin -p '' --out ~/backup.$(date +'%Y%m%d-%H%M')
      
      2020-08-05T10:16:27.834+0100    reading password from standard input
      Enter password:panic: EOF
      
      goroutine 1 [running]:
      github.com/mongodb/mongo-tools/common/password.readPassFromStdin(0x563f43b86e20, 0xc000092010)
              /data/mci/ce93d12bfe87820173b89f89a2440d85/src/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/password/password.go:52 +0x1ec
      github.com/mongodb/mongo-tools/common/password.Prompt(0x563f43b53d20, 0xc0000cc3c0)
              /data/mci/ce93d12bfe87820173b89f89a2440d85/src/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/password/password.go:38 +0x162
      github.com/mongodb/mongo-tools/common/db.NewSessionProvider(0x563f4364687c, 0x9, 0x563f43754a60, 0x7, 0xc000186000, 0xc0000a0800, 0xc0000a0820, 0xc000131080, 0xc0000cc320, 0xc000096780, ...)
              /data/mci/ce93d12bfe87820173b89f89a2440d85/src/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/db/db.go:218 +0x234
      github.com/mongodb/mongo-tools/mongodump.(*MongoDump).Init(0xc000098180, 0x563f43b82f20, 0xc000070360)
              /data/mci/ce93d12bfe87820173b89f89a2440d85/src/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/mongodump.go:132 +0x11c
      main.main()
              /data/mci/ce93d12bfe87820173b89f89a2440d85/src/src/mongo/gotools/src/github.com/mongodb/mongo-tools/mongodump/main/mongodump.go:81 +0x5ea
      

      Any chance both mongo and mongodump can handle passwords without EOF? For now we have a workaround.

      Here's more information on Hashicorp's vault kv get:
      https://www.vaultproject.io/docs/commands/kv/get

      Thanks,
      Robert

            Assignee:
            varsha.subrahmanyam@mongodb.com Varsha Subrahmanyam (Inactive)
            Reporter:
            rseaman@ahl.com Robert Seaman
            Huan Li, Ryan Chipman, Tim Fogarty
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: