Пример #1
0
 virtual bool run(const string& dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
     string fromhost = cmdObj.getStringField("fromhost");
     if ( fromhost.empty() ) {
         /* copy from self */
         stringstream ss;
         ss << "localhost:" << cmdLine.port;
         fromhost = ss.str();
     }
     string fromdb = cmdObj.getStringField("fromdb");
     string todb = cmdObj.getStringField("todb");
     if ( fromhost.empty() || todb.empty() || fromdb.empty() ) {
         errmsg = "parms missing - {copydb: 1, fromhost: <hostname>, fromdb: <db>, todb: <db>}";
         return false;
     }
     Cloner c;
     string username = cmdObj.getStringField( "username" );
     string nonce = cmdObj.getStringField( "nonce" );
     string key = cmdObj.getStringField( "key" );
     if ( !username.empty() && !nonce.empty() && !key.empty() ) {
         uassert( 13008, "must call copydbgetnonce first", authConn_.get() );
         BSONObj ret;
         {
             dbtemprelease t;
             if ( !authConn_->runCommand( fromdb, BSON( "authenticate" << 1 << "user" << username << "nonce" << nonce << "key" << key ), ret ) ) {
                 errmsg = "unable to login " + string( ret );
                 return false;
             }
         }
         c.setConnection( authConn_.release() );
     }
     Client::Context ctx(todb);
     bool res = c.go(fromhost.c_str(), errmsg, fromdb, /*logForReplication=*/!fromRepl, /*slaveok*/false, /*replauth*/false, /*snapshot*/true);
     return res;
 }
Пример #2
0
    Glob::Glob(const std::string& pattern, GlobFlags flags)
    {
        globObject.reset(this);

        posix::glob_t glob;
        posix::glob(pattern.c_str(), flags, &onGlobError, &glob);

        globObject.release();

        if (glob.gl_pathc) {
            for (char** p = glob.gl_pathv; *p != NULL; ++p) {
                pathNames_.push_back(*p);
            }
        }

        posix::globfree(&glob);
    }