~ubuntu-branches/ubuntu/wily/juju-mongodb/wily-proposed

« back to all changes in this revision

Viewing changes to src/mongo/s/shard.cpp

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-22 14:52:36 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140122145236-exgvx1pxk4fu9o4c
Tags: 2.4.9-0ubuntu1
* New upstream point release.
* d/p/0003-SERVER-12064-Use-gcc-atomic-builtins-if-available.patch:
  Dropped - not really needed for this version on mongodb.
* d/install: Don't ship mongo binary, its broken without a JS engine
  (LP: #1270098).
* d/p/0005-disable-jstests.patch: Dropped in preference to updates to
  d/p/0001-Add-option-to-disable-javascript.patch - rebased on revised
  upstream pull request.
* d/rules: Don't strip binaries during build so we get a ddeb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "mongo/db/auth/privilege.h"
31
31
#include "mongo/db/commands.h"
32
32
#include "mongo/db/jsobj.h"
 
33
#include "mongo/db/server_parameters.h"
33
34
#include "mongo/s/client_info.h"
34
35
#include "mongo/s/config.h"
35
36
#include "mongo/s/request.h"
39
40
 
40
41
namespace mongo {
41
42
 
 
43
    MONGO_EXPORT_SERVER_PARAMETER(authOnPrimaryOnly, bool, true);
 
44
 
42
45
    class StaticShardInfo {
43
46
    public:
44
47
        StaticShardInfo() : _mutex("StaticShardInfo"), _rsMutex("RSNameMap") { }
411
414
 
412
415
    void ShardingConnectionHook::onCreate( DBClientBase * conn ) {
413
416
        if( !noauth ) {
 
417
            bool result;
414
418
            string err;
415
419
            LOG(2) << "calling onCreate auth for " << conn->toString() << endl;
416
420
 
417
 
            bool result = conn->auth( "local",
418
 
                                      internalSecurity.user,
419
 
                                      internalSecurity.pwd,
420
 
                                      err,
421
 
                                      false );
 
421
            if ( conn->type() == ConnectionString::SET && !authOnPrimaryOnly ) {
 
422
                DBClientReplicaSet* setConn = dynamic_cast<DBClientReplicaSet*>(conn);
 
423
                verify(setConn);
 
424
                result = setConn->authAny( "local",
 
425
                                           internalSecurity.user,
 
426
                                           internalSecurity.pwd,
 
427
                                           err,
 
428
                                           false );
 
429
            }
 
430
            else {
 
431
                result = conn->auth( "local",
 
432
                                     internalSecurity.user,
 
433
                                     internalSecurity.pwd,
 
434
                                     err,
 
435
                                     false );
 
436
            }
422
437
 
423
438
            uassert( 15847, str::stream() << "can't authenticate to server "
424
439
                                          << conn->getServerAddress() << causedBy( err ), result );