~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/db/commands/hashcmd.cpp

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* hashcmd.cpp
2
 
 *
3
 
 * Defines a shell command for hashing a BSONElement value
4
 
 */
5
 
 
 
1
// hashcmd.cpp
6
2
 
7
3
/**
8
4
*    Copyright (C) 2012 10gen Inc.
20
16
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
17
*/
22
18
 
 
19
/*
 
20
 * Defines a shell command for hashing a BSONElement value
 
21
 */
 
22
 
 
23
#include <string>
 
24
#include <vector>
 
25
 
 
26
#include "mongo/base/init.h"
 
27
#include "mongo/base/status.h"
 
28
#include "mongo/db/auth/action_set.h"
 
29
#include "mongo/db/auth/action_type.h"
 
30
#include "mongo/db/auth/authorization_manager.h"
 
31
#include "mongo/db/auth/privilege.h"
23
32
#include "mongo/db/commands.h"
24
33
#include "mongo/db/hasher.h"
 
34
#include "mongo/db/jsobj.h"
25
35
 
26
36
namespace mongo {
27
37
 
 
38
    // Testing only, enabled via command-line.
28
39
    class CmdHashElt : public Command {
29
40
    public:
30
41
        CmdHashElt() : Command("_hashBSONElement") {};
31
42
        virtual LockType locktype() const { return NONE; }
32
43
        virtual bool slaveOk() const { return true; }
 
44
        // No auth needed because it only works when enabled via command line.
 
45
        virtual bool requiresAuth() { return false; }
 
46
        virtual void addRequiredPrivileges(const std::string& dbname,
 
47
                                           const BSONObj& cmdObj,
 
48
                                           std::vector<Privilege>* out) {}
33
49
        virtual void help( stringstream& help ) const {
34
50
            help << "returns the hash of the first BSONElement val in a BSONObj";
35
51
        }
66
82
            result.append( "out" , BSONElementHasher::hash64( cmdObj.firstElement() , seed ) );
67
83
            return true;
68
84
        }
69
 
    } cmdHashElt;
 
85
    };
 
86
    MONGO_INITIALIZER(RegisterHashEltCmd)(InitializerContext* context) {
 
87
        if (Command::testCommandsEnabled) {
 
88
            // Leaked intentionally: a Command registers itself when constructed.
 
89
            new CmdHashElt();
 
90
        }
 
91
        return Status::OK();
 
92
    }
70
93
}