Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-8492

Initial admin user can't be added over a Unix domain socket on OSX

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7.1
    • Affects Version/s: None
    • Component/s: Security
    • None
    • ALL

      On Linux an initial admin user can be added over a Unix domain socket:

      MongoDB shell version: 2.2.3
      connecting to: /tmp/mongodb-27017.sock:27017/test
      repl0:PRIMARY> use admin
      switched to db admin
      repl0:PRIMARY> db.runCommand('getCmdLineOpts')
      {
      	"argv" : [
      		"./mongod",
      		"--dbpath",
      		"/storage/data/rs0",
      		"--port",
      		"27017",
      		"--replSet",
      		"repl0",
      		"--keyFile",
      		"/home/behackett/work/key"
      	],
      	"parsed" : {
      		"dbpath" : "/storage/data/rs0",
      		"keyFile" : "/home/behackett/work/key",
      		"port" : 27017,
      		"replSet" : "repl0"
      	},
      	"ok" : 1
      }
      repl0:PRIMARY> db.sytem.users.find()
      repl0:PRIMARY> db.addUser('admin', 'pass')
      {
      	"user" : "admin",
      	"readOnly" : false,
      	"pwd" : "e4e538f5dcb52537cad02bbf8491693c",
      	"_id" : ObjectId("511583981babfde6e653926b")
      }
      addUser succeeded, but cannot wait for replication since we no longer have auth
      
      > db.auth('admin', 'pass')
      1
      repl0:PRIMARY> 
      

      On OSX this isn't possible:

      ./mongo --host /tmp/mongodb-27017.sock
      MongoDB shell version: 2.2.3
      connecting to: /tmp/mongodb-27017.sock:27017/test
      > use admin
      switched to db admin
      > db.runCommand('getCmdLineOpts')
      { "errmsg" : "need to login", "ok" : 0 }
      > db.system.users.find()
      error: {
      	"$err" : "unauthorized db:admin ns:admin.system.users lock type:1 client:",
      	"code" : 10057
      }
      > 
      

      Using a regular socket works fine:

      ./mongo
      MongoDB shell version: 2.2.3
      connecting to: test
      > use admin
      switched to db admin
      > db.runCommand('getCmdLineOpts')
      {
      	"argv" : [
      		"./mongod",
      		"--dbpath",
      		"/Users/behackett/data/db",
      		"--auth"
      	],
      	"parsed" : {
      		"auth" : true,
      		"dbpath" : "/Users/behackett/data/db"
      	},
      	"ok" : 1
      }
      

      I've tried this with both replica sets and a single mongod instance. The behavior is the same in both cases.

            Assignee:
            david.hows David Hows
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: