1 2 /** 3 * Copyright (C) 2018-present MongoDB, Inc. 4 * 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the Server Side Public License, version 1, 7 * as published by MongoDB, Inc. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * Server Side Public License for more details. 13 * 14 * You should have received a copy of the Server Side Public License 15 * along with this program. If not, see 16 * <http://www.mongodb.com/licensing/server-side-public-license>. 17 * 18 * As a special exception, the copyright holders give permission to link the 19 * code of portions of this program with the OpenSSL library under certain 20 * conditions as described in each individual source file and distribute 21 * linked combinations including the program with the OpenSSL library. You 22 * must comply with the Server Side Public License in all respects for 23 * all of the code used other than as permitted herein. If you modify file(s) 24 * with this exception, you may extend this exception to your version of the 25 * file(s), but you are not obligated to do so. If you do not wish to do so, 26 * delete this exception statement from your version. If you delete this 27 * exception statement from all source files in the program, then also delete 28 * it in the license file. 29 */ 30 31 #pragma once 32 33 #include <boost/optional.hpp> 34 #include <string> 35 #include <vector> 36 37 #include "mongo/base/status.h" 38 #include "mongo/rpc/protocol.h" 39 40 namespace mongo { 41 42 namespace optionenvironment { 43 class OptionSection; 44 class Environment; 45 } // namespace optionenvironment 46 47 namespace moe = mongo::optionenvironment; 48 49 struct ShellGlobalParams { 50 std::string url; 51 std::string dbhost; 52 std::string port; 53 std::vector<std::string> files; 54 55 std::string username; 56 std::string password; 57 std::string authenticationMechanism; 58 std::string authenticationDatabase; 59 std::string gssapiServiceName; 60 std::string gssapiHostName; 61 std::string networkMessageCompressors; 62 63 bool runShell; 64 bool nodb; 65 bool norc; 66 bool nojit = false; 67 bool javascriptProtection = true; 68 69 std::string script; 70 71 bool autoKillOp = false; 72 bool useWriteCommandsDefault = true; 73 74 std::string writeMode = "commands"; 75 std::string readMode = "compatibility"; 76 bool shouldRetryWrites = false; 77 bool shouldUseImplicitSessions = true; 78 79 boost::optional<rpc::ProtocolSet> rpcProtocols = boost::none; 80 81 int jsHeapLimitMB = 0; 82 }; 83 84 extern ShellGlobalParams shellGlobalParams; 85 86 Status addMongoShellOptions(moe::OptionSection* options); 87 88 std::string getMongoShellHelp(StringData name, const moe::OptionSection& options); 89 90 /** 91 * Handle options that should come before validation, such as "help". 92 * 93 * Returns false if an option was found that implies we should prematurely exit with success. 94 */ 95 bool handlePreValidationMongoShellOptions(const moe::Environment& params, 96 const std::vector<std::string>& args); 97 98 Status storeMongoShellOptions(const moe::Environment& params, const std::vector<std::string>& args); 99 100 void redactPasswordOptions(int argc, char** argv); 101 } 102