Example #1
0
    // todo: remove or add clone support
    ConnectionSettings::ConnectionSettings(const mongo::MongoURI& uri, bool isClone)  
        : _connectionName(defaultNameConnection),
        _host(defaultServerHost),
        _port(port),
        _imported(false),
        _sshSettings(new SshSettings()),
        _sslSettings(new SslSettings()),
        _isReplicaSet((uri.type() == mongo::ConnectionString::ConnectionType::SET)),
        _replicaSetSettings(new ReplicaSetSettings(uri)),
        _clone(isClone),
        _uuid(QUuid::createUuid().toString())   // todo
    {
        if (!uri.getServers().empty()) {
            _host = uri.getServers().front().host();
            _port = uri.getServers().front().port();
        }

        auto str = std::string(uri.getOptions().getStringField("ssl"));
        auto sslEnabled = ("true" == str);
        if (sslEnabled) {
            _sslSettings->enableSSL(true);
            _sslSettings->setAllowInvalidCertificates(true);
        }

        auto credential = new CredentialSettings();
        credential->setUserName(uri.getUser());
        credential->setUserPassword(uri.getPassword());
        credential->setDatabaseName(uri.getDatabase());
        if (!credential->userName().empty() && !credential->userPassword().empty()) {   // todo:
            credential->setEnabled(true);
        }
        addCredential(credential);
    }
Example #2
0
		void
		DBImpl::
		setConnectionInfo(std::string& server,
		                  uint32_t port,
		                  std::string& user,
		                  std::string& pw,
		                  std::string& db)
		{
			setServerURL(server);
			setServerPort(port);
			setUserName(user);
			setUserPassword(pw);
			setDatabaseName(db);
		}
Example #3
0
/**
 * Initial the CVSService object and the CVS repository.
 */
CVSService::CVSService(const char *repoPath, const char *tempPath, const char *execPath)
{
	assert(NULL != repoPath);
	assert(NULL != tempPath);
	assert(NULL != execPath);

	// Fill up object fields.
	strncpy(m_repoPath, repoPath, MAX_PATH);
	strncpy(m_tempPath, tempPath, MAX_PATH);
	strncpy(m_execPath, execPath, MAX_PATH);

	// Set up flags.
	m_isRepoInitialized = false;
	m_isDaemonRunning = false;

	// Initial semaphores.
	sem_init(&m_exitThread, 0, 0);
	sem_init(&m_syncThread, 0, 0);

	struct stat statbuf;
	char cvsroot[MAX_PATH + 16];

	// Check repository status.
	if (stat(m_repoPath, &statbuf) < 0) {
		if (ENOENT != errno)
			return;
	} else if (!S_ISDIR(statbuf.st_mode)) {
		return;
	} else if (stat(strcat(strcpy(cvsroot, m_repoPath), "/CVSROOT"), &statbuf) < 0) {
		if (ENOENT != errno)
			return;
	} else if (!S_ISDIR(statbuf.st_mode)) {
		return;
	} else {
		m_isRepoInitialized = true;
	}

	// Initial CVS repository if it is not initialized.
	if (!m_isRepoInitialized) {
		pid_t pid = fork();

		// Invoke "cvs -d <repo> init" command.
		if (pid == 0) {
			execl(m_execPath, "cvs", "-d", m_repoPath, "init", NULL);
			exit(1);
		}

		// Wait for process exit and check the result.
		int status = 0;
		if (pid < 0 || waitpid(pid, &status, 0) < 0 || status != 0)
			return;

		// Set repository initialized flag.
		m_isRepoInitialized = true;

		// Set default user name and password.
		if (!setUserPassword("User", "Ab-123456"))
			return;
	}

}