Exemple #1
0
bool ScmdServer_Impl::HandleScmdMessage( HCLIENT hClient, ILTMessage_Read& msg )
{
	// Check if SCMD commands are not allowed.
	if( !m_bAllowScmdCommands )
	{
		return true;
	}

	// Read the scmd command.
	ScmdCommand eScmdCommand = ( ScmdCommand )msg.Readuint8( );

	// Check if we're not controlled by an admin.  Since Login is the only
	// command you can send without being logged in, it has special handling.
	if( eScmdCommand != kScmdCommandLogin &&
		( m_eAdminControl == kAdminControlNone ) ||
		( m_eAdminControl == kAdminControlClient && hClient != m_hAdminClient ) ||
		( m_eAdminControl == kAdminControlServerapp && hClient != NULL ))
	{
		// Doesn't have privileges.
		SendStatusMessage( hClient, eScmdCommand, kScmdCommandStatusNotLoggedIn );
		return false;
	}


	switch( eScmdCommand )
	{
		case kScmdCommandLogin:
			return HandleLogin( hClient, msg );
			break;

		case kScmdCommandLogout:
			return HandleLogout( hClient, msg );
			break;

		case kScmdCommandListClients:
			return HandleListClients( hClient, msg );
			break;

		case kScmdCommandListMissions:
			return HandleListMissions( hClient, msg );
			break;

		case kScmdCommandNextMission:
			return HandleNextMission( hClient, msg );
			break;

		case kScmdCommandNextRound:
			return HandleNextRound( hClient, msg );
			break;

		case kScmdCommandSetMission:
			return HandleSetMission( hClient, msg );
			break;

		case kScmdCommandBootName:
			return HandleBootName( hClient, msg );
			break;

		case kScmdCommandBootId:
			return HandleBootId( hClient, msg );
			break;

		case kScmdCommandAddBan:
			return HandleAddBan( hClient, msg );
			break;

		case kScmdCommandRemoveBan:
			return HandleRemoveBan( hClient, msg );
			break;

		case kScmdCommandListBans:
			return HandleListBans( hClient, msg );
			break;

		case kScmdCommandBanClient:
			return HandleBanClient( hClient, msg );
			break;

		case kScmdCommandListGameOptions:
			return HandleListGameOptions( hClient, msg );
			break;

		case kScmdCommandSetGameOption:
			return HandleSetGameOption( hClient, msg );
			break;

	}

	return false;
}
Exemple #2
0
DWORD
DispatchInitFunctions(po::variables_map argsMap,po::options_description& config)
{
    DWORD dwError = ERROR_SUCCESS;

    dwError = SetSrpAuthenticationInfo();
    BAIL_ON_ERROR(dwError);

    if (argsMap.count("selfca")) {
        if ( ParserConfigFile(config, argConfig) != 0 )  {
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
        }

        if (argPredates > VMCA_MAX_PREDATE_PERMITED || argPredates < 0)
        {
            std::cout << "Invalid start time predate specified it should be between "
                << VMCA_MAX_PREDATE_PERMITED << " and 0 "<<std::endl;
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
        }

        dwError = HandleCreateSelfSignedCA();
        BAIL_ON_ERROR(dwError);
    }
    if (argsMap.count("rootca")) {
        if(!argsMap.count("privkey") ||
                !argsMap.count("cert")) {
            std::cout << "To upload a Root CA Cert, we need both Cert and Private Key.\n\n"
                      << "Example: certool --rootca --cert=root.cert --privkey=privatekey.pem\n"
                      << std::endl;
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
        }
        dwError = HandleRootCACertificate();
        BAIL_ON_ERROR(dwError);
    }

    if (argsMap.count("gencsr") || argsMap.count("initcsr")) {
        if (argsMap.count("initcsr")) {
            std::cout << "This is deprecated. Use gencsr instead.\n";
        }
        if(!argsMap.count("privkey") ||
                !argsMap.count("pubkey")  ||
                !argsMap.count("csrfile")) {
            std::cout << "To create a CSR we need a private key path.\n\n"
                      << "Example : certool --gencsr --privkey=<filename> --pubkey=<filename>"
                      << " --csrfile=<filename>\n";
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
        }

        if ( ParserConfigFile(config, argConfig) != 0 )  {
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
        }

        dwError = HandleInitCSR();
        BAIL_ON_ERROR(dwError);
    }

    if(argsMap.count("getdc")) {
        dwError = HandleGetDC();
        BAIL_ON_ERROR(dwError);
    }


    if(argsMap.count("WaitVMCA")) {
        dwError = HandleWaitVMCA();
        BAIL_ON_ERROR(dwError);
    }

    if(argsMap.count("WaitVMDIR")) {
        dwError = HandleWaitVMDIR();
        BAIL_ON_ERROR(dwError);
    }


    if(argsMap.count("login")){
         if(!argsMap.count("user") ||
            !argsMap.count("password") ||
            !argsMap.count("domain")) {
                std::cout << "To login we need a user name and password.\n"
                      << "Example : certool --login --user=administrator"
                      << " --domain=VSPHERE.LOCAL"
                      << " --password=<password>\n";
            dwError =  VMCA_ARGUMENT_ERROR;
            BAIL_ON_ERROR(dwError);
         }

        dwError = HandleLogin();
        BAIL_ON_ERROR(dwError);
    }

    if(argsMap.count("logout")) {
        dwError = HandleLogout();
        BAIL_ON_ERROR(dwError);
    }

    if(argsMap.count("publish-roots")){
        dwError = HandlePublishRoots();
        BAIL_ON_ERROR(dwError);
    }

    if(argsMap.count("updateschema")) {
        dwError = HandleUpdateSchema();
        BAIL_ON_ERROR(dwError);
    }

error:
    return dwError;
}