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

« back to all changes in this revision

Viewing changes to src/mongo/db/commands/connection_status.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
/*
 
2
 *    Copyright (C) 2010 10gen Inc.
 
3
 *
 
4
 *    This program is free software: you can redistribute it and/or  modify
 
5
 *    it under the terms of the GNU Affero General Public License, version 3,
 
6
 *    as published by the Free Software Foundation.
 
7
 *
 
8
 *    This program is distributed in the hope that it will be useful,
 
9
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 *    GNU Affero General Public License for more details.
 
12
 *
 
13
 *    You should have received a copy of the GNU Affero General Public License
 
14
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include <mongo/pch.h>
 
18
 
 
19
#include "mongo/db/auth/authorization_manager.h"
 
20
#include "mongo/db/commands.h"
 
21
 
 
22
namespace mongo {
 
23
    class CmdConnectionStatus : public Command {
 
24
    public:
 
25
        CmdConnectionStatus() : Command("connectionStatus") {}
 
26
        virtual bool requiresAuth() { return false; }
 
27
        virtual bool logTheOp() { return false; }
 
28
        virtual bool slaveOk() const { return true; }
 
29
        virtual LockType locktype() const { return NONE; }
 
30
        virtual void addRequiredPrivileges(const std::string& dbname,
 
31
                                           const BSONObj& cmdObj,
 
32
                                           std::vector<Privilege>* out) {} // No auth required
 
33
 
 
34
        void help(stringstream& h) const {
 
35
            h << "Returns connection-specific information such as logged-in users";
 
36
        }
 
37
 
 
38
        bool run(const string&, BSONObj& cmdObj, int, string& errmsg,
 
39
                 BSONObjBuilder& result, bool fromRepl) {
 
40
            AuthorizationManager* authMgr = ClientBasic::getCurrent()->getAuthorizationManager();
 
41
 
 
42
            BSONObjBuilder authInfo(result.subobjStart("authInfo"));
 
43
            {
 
44
                BSONArrayBuilder authenticatedUsers(authInfo.subarrayStart("authenticatedUsers"));
 
45
 
 
46
                PrincipalSet::NameIterator nameIter = authMgr->getAuthenticatedPrincipalNames();
 
47
                for ( ; nameIter.more(); nameIter.next()) {
 
48
                    BSONObjBuilder principal(authenticatedUsers.subobjStart());
 
49
                    principal.append("user", nameIter->getUser());
 
50
                    principal.append("userSource", nameIter->getDB());
 
51
                    principal.doneFast();
 
52
                }
 
53
                authenticatedUsers.doneFast();
 
54
            }
 
55
            authInfo.doneFast();
 
56
 
 
57
            return true;
 
58
        }
 
59
    } cmdConnectionStatus;
 
60
}