コード例 #1
0
    virtual int removeFile(
        const char* path)
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_REMOVE_FILE_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorRemoveFileRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.path, path, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorRemoveFileResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        return response.status;
    }
コード例 #2
0
    virtual int challengeLocal(
        const char* username,
        char challengeFilePath[EXECUTOR_BUFFER_SIZE])
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_CHALLENGE_LOCAL_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorChallengeLocalRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.user, username, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorChallengeLocalResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        Strlcpy(challengeFilePath, response.challenge, EXECUTOR_BUFFER_SIZE);

        return response.status;
    }
コード例 #3
0
/// Stop playing
void CStreamSource::stop()
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);
	
	// nldebug("CStreamSource %p : stop", (CAudioMixerUser::IMixerEvent*)this);
	// nlassert(_Playing);
	
	if (!_Playing)
		return;
	
	if (hasPhysicalSource())
		releasePhysicalSource();
	
	CSourceCommon::stop();

	m_FreeBuffers = 3;
	m_NextBuffer = 0;
	
	if (_Spawn)
	{
		if (_SpawnEndCb != NULL)
			_SpawnEndCb(this, _CbUserParam);
		delete this;
	}
}
コード例 #4
0
    virtual int updateLogLevel(
        const char* logLevel)
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_UPDATE_LOG_LEVEL_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body:

        ExecutorUpdateLogLevelRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.logLevel, logLevel, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorUpdateLogLevelResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        return response.status;
    }
コード例 #5
0
/*
 * Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional)
 */
void CStreamSource::setDirection(const NLMISC::CVector& dir)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setDirection(dir);

	// Set the direction
	if (hasPhysicalSource())
	{
		if (!m_Buffers[0]->isStereo())
		{
			static bool coneset = false;
			if (dir.isNull()) // workaround // For what?
			{
				getPhysicalSource()->setCone(float(Pi * 2), float(Pi * 2), 1.0f); // because the direction with 0 is not enough for a non-directional source!
				getPhysicalSource()->setDirection(CVector::I);  // Don't send a 0 vector, DSound will complain. Send (1,0,0), it's omnidirectional anyway.
				coneset = false;
			}
			else
			{
//				if (!coneset)
				{
					getPhysicalSource()->setCone(m_StreamSound->getConeInnerAngle(), m_StreamSound->getConeOuterAngle(), m_StreamSound->getConeOuterGain());
					coneset = true;
				}
				getPhysicalSource()->setDirection(dir);
			}
		}
	}
}
コード例 #6
0
    virtual int authenticatePassword(
        const char* username,
        const char* password)
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_AUTHENTICATE_PASSWORD_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorAuthenticatePasswordRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.username, username, EXECUTOR_BUFFER_SIZE);
        Strlcpy(request.password, password, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorAuthenticatePasswordResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        return response.status;
    }
コード例 #7
0
    virtual int validateUser(
        const char* username)
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_VALIDATE_USER_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorValidateUserRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.username, username, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorValidateUserResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        return response.status;
    }
コード例 #8
0
void CStreamSource::setSourceRelativeMode(bool mode)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setSourceRelativeMode(mode);
	if (hasPhysicalSource())
		getPhysicalSource()->setSourceRelativeMode(mode);
}
コード例 #9
0
void CStreamSource::setPitch(float pitch)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setPitch(pitch);
	if (hasPhysicalSource())
		getPhysicalSource()->setPitch(pitch);
}
コード例 #10
0
void CStreamSource::setVelocity(const NLMISC::CVector& vel)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setVelocity(vel);
	if (hasPhysicalSource())
		getPhysicalSource()->setVelocity(vel);
}
コード例 #11
0
void CStreamSource::setPos(const NLMISC::CVector& pos)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setPos(pos);
	if (hasPhysicalSource())
		getPhysicalSource()->setPos(getVirtualPos());
}
コード例 #12
0
void CStreamSource::setRelativeGain(float gain)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);

	CSourceCommon::setRelativeGain(gain);
	if (hasPhysicalSource())
		getPhysicalSource()->setGain(_Gain);
}
コード例 #13
0
/// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL when all the buffer space is already filled. Call setFormat() first.
uint8 *CStreamSource::lock(uint capacity)
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);
	updateAvailableBuffers();
	if (m_FreeBuffers > 0)
		return m_Buffers[m_NextBuffer]->lock(capacity);
	return NULL;
}
コード例 #14
0
uint32 CStreamSource::getTime()
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);
	
	if (hasPhysicalSource())
		return getPhysicalSource()->getTime();
	else
		return 0;
}
コード例 #15
0
    virtual FILE* openFile(
        const char* path,
        int mode)
    {
        AutoMutex autoMutex(_mutex);

        if (mode != 'r' && mode != 'w' && mode != 'a')
            return NULL;

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_OPEN_FILE_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return NULL;

        // Send request body.

        ExecutorOpenFileRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.path, path, EXECUTOR_BUFFER_SIZE);
        request.mode = mode;

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return NULL;

        // Receive the response

        ExecutorOpenFileResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return NULL;

        // Receive descriptor (if response successful).

        if (response.status == 0)
        {
            int fds[1];

            if (RecvDescriptorArray(_sock, fds, 1) != 0)
                return NULL;

            if (fds[0] == -1)
                return NULL;
            else
            {
                if (mode == 'r')
                    return fdopen(fds[0], "rb");
                else
                    return fdopen(fds[0], "wb");
            }
        }

        return NULL;
    }
コード例 #16
0
ファイル: APLCertif.cpp プロジェクト: Andhr3y/dcfd-mw-applet
void APL_Certif::initInfo()
{
	if(m_initInfo)
		return;

	if(!m_info)
	{
		CAutoMutex autoMutex(&m_Mutex);		//We lock for unly one instanciation
		if(!m_info)
			m_info=new tCertifInfo;
	}

	if(m_cryptoFwk->getCertInfo(getData(), *m_info))
		m_initInfo=true;
}
コード例 #17
0
ファイル: APLCertif.cpp プロジェクト: Andhr3y/dcfd-mw-applet
APL_OcspResponse *APL_Certif::getOcspResponse()
{
	if(!m_ocsp)
	{
		CAutoMutex autoMutex(&m_Mutex);		//We lock for only one instance
		if(!m_ocsp)
		{
			std::string url;
			if(m_cryptoFwk->GetOCSPUrl(getData(),url))
				m_ocsp=new APL_OcspResponse(url.c_str(),this);
		}
	}

	return m_ocsp;
}
コード例 #18
0
ファイル: APLCertif.cpp プロジェクト: Andhr3y/dcfd-mw-applet
APL_Crl *APL_Certif::getCRL()
{
	if(!m_crl)
	{
		CAutoMutex autoMutex(&m_Mutex);		//We lock for only one instance
		if(!m_crl)
		{
			std::string url;
			if(m_cryptoFwk->GetCDPUrl(getData(),url))
				m_crl=new APL_Crl(url.c_str(),this);
		}
	}

	return m_crl;
}
コード例 #19
0
/// Notify that you are done writing to the locked buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok.
bool CStreamSource::unlock(uint size)
{
	nlassert(m_FreeBuffers > 0);
	
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);
	IBuffer *buffer = m_Buffers[m_NextBuffer];
	bool result = buffer->unlock(size);

	if (size > 0)
	{
		++m_NextBuffer; m_NextBuffer %= 3;
		--m_FreeBuffers;
		if (hasPhysicalSource())
			getPhysicalSource()->submitStreamingBuffer(buffer);
		m_LastSize = size;
	}

	return result;
}
コード例 #20
0
ファイル: APLCertif.cpp プロジェクト: Andhr3y/dcfd-mw-applet
APL_Certif *APL_Certifs::getCertFromCard(unsigned long ulIndex)
{
	if(!m_card)
		throw CMWEXCEPTION(EIDMW_ERR_BAD_USAGE);

	if(ulIndex<0 || ulIndex>=countFromCard())
		throw CMWEXCEPTION(EIDMW_ERR_PARAM_RANGE);

	std::map<unsigned long ,APL_Certif *>::const_iterator itr;
	APL_Certif *cert=NULL;

	for(itr=m_certifs.begin();itr!=m_certifs.end();itr++)
	{
		cert=itr->second;
		if(cert->getIndexOnCard()==ulIndex)
			return cert;
	}

	{
		CAutoMutex autoMutex(&m_Mutex);		//We lock for only one instanciation

		for(itr=m_certifs.begin();itr!=m_certifs.end();itr++)
		{
			cert=itr->second;
			if(cert->getIndexOnCard()==ulIndex)
				return cert;
		}

		cert = new APL_Certif(m_card,this,ulIndex);

		unsigned long ulUniqueId=ulIndex;//cert->getUniqueId();
		itr = m_certifs.find(ulUniqueId);
		if(itr==m_certifs.end())
		{
			m_certifs[ulUniqueId]=cert;
			m_certifsOrder.push_back(ulUniqueId);
		}

		return cert;
	}

}
コード例 #21
0
ファイル: logbase.cpp プロジェクト: Andhr3y/dcfd-mw-applet
//Get the singleton instance of the logger
CLogger &CLogger::instance()
{
	if(m_bApplicationLeaving)
		throw CMWEXCEPTION(EIDMW_ERR_LOGGER_APPLEAVING);


    if (m_instance.get() == 0)
	{
#ifdef WIN32
		//----------------------------------------------
		// always create the logger mutex. Only the first time the named mutex is
		// used, it is created. After that it is equivalent to opening the mutex
		//----------------------------------------------
		LogMutex = CreateMutex(0, FALSE, L"LogMutex");
#endif
		CAutoMutex autoMutex(&m_mutex);
		m_instance.reset(new CLogger);
	}
    return *m_instance;
}
コード例 #22
0
    virtual int daemonizeExecutor()
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_DAEMONIZE_EXECUTOR_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Receive the response

        ExecutorDaemonizeExecutorResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        return response.status;
    }
コード例 #23
0
    virtual int ping()
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_PING_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        ExecutorPingResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        if (response.magic == EXECUTOR_PING_MAGIC)
            return 0;

        return -1;
    }
コード例 #24
0
    virtual int authenticateLocal(
        const char* challengeFilePath,
        const char* response)
    {
        AutoMutex autoMutex(_mutex);

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_AUTHENTICATE_LOCAL_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorAuthenticateLocalRequest request;
        memset(&request, 0, sizeof(request));
        Strlcpy(request.challenge, challengeFilePath, EXECUTOR_BUFFER_SIZE);
        Strlcpy(request.response, response, EXECUTOR_BUFFER_SIZE);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorAuthenticateLocalResponse response_;

        if (RecvBlock(_sock, &response_, sizeof(response_)) !=
                sizeof(response_))
        {
            return -1;
        }

        return response_.status;
    }
コード例 #25
0
    virtual int startProviderAgent(
        const char* module,
        const String& pegasusHome,
        const String& userName,
        int& pid,
        AnonymousPipe*& readPipe,
        AnonymousPipe*& writePipe)
    {
        PEG_METHOD_ENTER(TRC_SERVER,"ExecutorLoopbackImpl::startProviderAgent");

#if !defined(PEGASUS_ENABLE_PRIVILEGE_SEPARATION)

        // Resolve full path of "cimprovagt" program.

        String path = FileSystem::getAbsolutePath(
            pegasusHome.getCString(), PEGASUS_PROVIDER_AGENT_PROC_NAME);

        // Create CString handles for cimprovagt arguments

        CString agentProgramPath = path.getCString();
        CString userNameCString = userName.getCString();

# if defined(PEGASUS_DISABLE_PROV_USERCTXT)
        const char* setUserContextFlag = "0";    // False
# else
        const char* setUserContextFlag = "1";    // True
# endif

# if defined(PEGASUS_OS_TYPE_WINDOWS)

        AutoMutex autoMutex(_mutex);

        // Set output parameters in case of failure.

        pid = 0;
        readPipe = 0;
        writePipe = 0;

        // Create pipes. Export handles to string.

        AutoPtr<AnonymousPipe> pipeFromAgent(new AnonymousPipe());
        AutoPtr<AnonymousPipe> pipeToAgent(new AnonymousPipe());

        char readHandle[32];
        char writeHandle[32];
        pipeToAgent->exportReadHandle(readHandle);
        pipeFromAgent->exportWriteHandle(writeHandle);

        // Initialize PROCESS_INFORMATION.

        PROCESS_INFORMATION piProcInfo;
        ZeroMemory(&piProcInfo, sizeof (PROCESS_INFORMATION));

        // Initialize STARTUPINFO.

        STARTUPINFO siStartInfo;
        ZeroMemory(&siStartInfo, sizeof (STARTUPINFO));
        siStartInfo.cb = sizeof (STARTUPINFO);

        // Format command line.

        char cmdLine[2048];

        sprintf(cmdLine, "\"%s\" %s %s %s \"%s\" \"%s\"",
            (const char*)agentProgramPath,
            setUserContextFlag,
            readHandle,
            writeHandle,
            (const char*)userNameCString,
            module);

        //  Create provider agent proess.

        if (!CreateProcess (
            NULL,          //
            cmdLine,       //  command line
            NULL,          //  process security attributes
            NULL,          //  primary thread security attributes
            TRUE,          //  handles are inherited
            0,             //  creation flags
            NULL,          //  use parent's environment
            NULL,          //  use parent's current directory
            &siStartInfo,  //  STARTUPINFO
            &piProcInfo))  //  PROCESS_INFORMATION
        {
            PEG_METHOD_EXIT();
            return -1;
        }

        CloseHandle(piProcInfo.hProcess);
        CloseHandle(piProcInfo.hThread);

        // Close our copies of the agent's ends of the pipes

        pipeToAgent->closeReadHandle();
        pipeFromAgent->closeWriteHandle();

        readPipe = pipeFromAgent.release();
        writePipe = pipeToAgent.release();

        PEG_METHOD_EXIT();
        return 0;

# else /* POSIX CASE FOLLOWS */
        
        AutoMutex autoMutex(_mutex);

        // Initialize output parameters in case of error.

        pid = -1;
        readPipe = 0;
        writePipe = 0;

        // Pipes:

        int to[2];
        int from[2];
        char toPipeArg[32];
        char fromPipeArg[32];

        do
        {
            // Create "to-agent" pipe:

            if (pipe(to) != 0)
            {
                PEG_METHOD_EXIT();
                return -1;
            }
                
            // Create "from-agent" pipe:

            if (pipe(from) != 0)
            {
                PEG_METHOD_EXIT();
                return -1;
            }

            // Initialize the cimprovagt pipe arguments:

            sprintf(toPipeArg, "%d", to[0]);
            sprintf(fromPipeArg, "%d", from[1]);

            // Start provider agent:

#  if defined(PEGASUS_OS_ZOS)
            // zOS uses __spawn2() instead of fork() to start provider agent

            struct __inheritance inherit;
            const char *c_argv[7];

            c_argv[0] = agentProgramPath;
            c_argv[1] = setUserContextFlag;
            c_argv[2] = toPipeArg;
            c_argv[3] = fromPipeArg;
            c_argv[4] = userNameCString;
            c_argv[5] = module; 
            c_argv[6] = NULL;

            // reset the inherit structure
            memset(&inherit,0,sizeof(inherit));

            // The provider agent should get a defined JobName.
            inherit.flags=SPAWN_SETJOBNAME;
            memcpy( inherit.jobname,"CFZOOPA ",
                    sizeof(inherit.jobname));
            
            PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
                "Starting provider agent: %s %s %s %s %s %s %s",
                (const char*)agentProgramPath,
                c_argv[0],
                c_argv[1],
                c_argv[2],
                c_argv[3],
                c_argv[4],
                c_argv[5]));

            pid = __spawn2(agentProgramPath,0,NULL,&inherit,
                           c_argv,(const char **)environ);

            if (pid < 0)
            {
                PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                    "Spawn of provider agent fails:%s "
                        "( errno %d , reason code %08X )", 
                    strerror(errno) ,errno,__errno2()));
                PEG_METHOD_EXIT();
                return -1;
            }

#  else    // !defined(PEGASUS_OS_ZOS)

#   if defined(PEGASUS_OS_VMS)
            pid = (int)vfork();
#   elif defined(PEGASUS_OS_PASE)
            pid = (int)fork400("QUMEPRVAGT",0);
#   else
            pid = (int)fork();
#   endif

            if (pid < 0)
            {
                PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                     "Fork for provider agent fails: errno = %d",errno)); 
                PEG_METHOD_EXIT();
                return -1;
            }
                
            if (pid == 0)
            {
                // Child process

#   if !defined(PEGASUS_OS_VMS)
                // Close unused pipe descriptors:

                close(to[1]);
                close(from[0]);

                // Close unused descriptors. Leave stdin, stdout, stderr,
                // and the child's pipe descriptors open.
                //
                // Honor rlimit (rlim_cur) unless it's too large; this can be a
                // 64-bit number on some platforms, causing us to stop responding

                struct rlimit rlim;
                int fdLimit = 0;

                if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
                {
                    fdLimit = int(rlim.rlim_cur);
                    if (fdLimit > 2500)
                    {
                        fdLimit = 2500;
                    }
                }
                else
                {
                    fdLimit = 2500;
                }

                for (int i = 3; i < fdLimit; i++)
                {
                    if (i != to[0] && i != from[1])
                        close(i);
                }
#   endif /* !defined(PEGASUS_OS_VMS) */

                // Exec the cimprovagt program.

                {
                    if (execl(
                            agentProgramPath,
                            agentProgramPath,
                            setUserContextFlag,
                            toPipeArg,
                            fromPipeArg,
                            (const char*)userNameCString,
                            module,
                            (char*)0) == -1)
                    {
                        PEG_TRACE((TRC_SERVER, Tracer::LEVEL1,
                            "execl() failed.  errno = %d.", errno));
                        _exit(1);
                    }
                }
            }
#  endif /* PEGASUS_OS_ZOS */
        }
        while (0);

        PEG_TRACE((TRC_SERVER, Tracer::LEVEL4,
            "Provider agent started: pid(%d).", pid));

        // Close unused pipe descriptors.

        close(to[0]);
        close(from[1]);

        // Set output parameters.

        int readFd = from[0];
        int writeFd = to[1];

        // Create to and from AnonymousPipe instances to correspond to the pipe
        // descriptors created above.

        char readFdStr[32];
        char writeFdStr[32];
        sprintf(readFdStr, "%d", readFd);
        sprintf(writeFdStr, "%d", writeFd);

        readPipe = new AnonymousPipe(readFdStr, 0);
        writePipe = new AnonymousPipe(0, writeFdStr);

#  if defined(PEGASUS_HAS_SIGNALS)
#   if !defined(PEGASUS_DISABLE_PROV_USERCTXT) && !defined(PEGASUS_OS_ZOS)
        // The cimprovagt forks and returns right away.  Clean up the zombie
        // process now instead of in reapProviderAgent().
        int status = 0;
        while ((status = waitpid(pid, 0, 0)) == -1 && errno == EINTR)
            ;
#   endif
#  endif

        PEG_METHOD_EXIT();
        return 0;

# endif /* POSIX CASE */

#else /* PEGASUS_ENABLE_PRIVILEGE_SEPARATION is defined */

        // Out-of-Process providers are never started by the cimserver process
        // when Privilege Separation is enabled.
        return -1;

#endif
    }
コード例 #26
0
    virtual int startProviderAgent(
        const char* module,
        const String& pegasusHome,
        const String& userName,
        int& pid,
        AnonymousPipe*& readPipe,
        AnonymousPipe*& writePipe)
    {
        AutoMutex autoMutex(_mutex);

        readPipe = 0;
        writePipe = 0;

        // Reject strings longer than EXECUTOR_BUFFER_SIZE.

        size_t moduleNameLength = strlen(module);

        if (moduleNameLength >= EXECUTOR_BUFFER_SIZE)
            return -1;

        CString userNameCString = userName.getCString();
        size_t userNameLength = strlen(userNameCString);

        if (userNameLength >= EXECUTOR_BUFFER_SIZE)
            return -1;

        // Send request header:

        ExecutorRequestHeader header;
        header.code = EXECUTOR_START_PROVIDER_AGENT_MESSAGE;

        if (SendBlock(_sock, &header, sizeof(header)) != sizeof(header))
            return -1;

        // Send request body.

        ExecutorStartProviderAgentRequest request;
        memset(&request, 0, sizeof(request));
        memcpy(request.module, module, moduleNameLength);
        memcpy(request.userName, userNameCString, userNameLength);

        if (SendBlock(_sock, &request, sizeof(request)) != sizeof(request))
            return -1;

        // Receive the response

        ExecutorStartProviderAgentResponse response;

        if (RecvBlock(_sock, &response, sizeof(response)) != sizeof(response))
            return -1;

        // Check response status and pid.

        if (response.status != 0)
            return -1;

        // Get pid:

        pid = response.pid;

        // Receive descriptors.

        int descriptors[2];
        int result = RecvDescriptorArray(_sock, descriptors, 2);

        if (result == 0)
        {
            int readFd = descriptors[0];
            int writeFd = descriptors[1];

            // Create to and from AnonymousPipe instances to correspond to
            // the pipe descriptors created above.

            char readFdStr[32];
            char writeFdStr[32];
            sprintf(readFdStr, "%d", readFd);
            sprintf(writeFdStr, "%d", writeFd);

            readPipe = new AnonymousPipe(readFdStr, 0);
            writePipe = new AnonymousPipe(0, writeFdStr);
        }

        return result;
    }
コード例 #27
0
ファイル: CardFile.cpp プロジェクト: Andhr3y/dcfd-mw-applet
tCardFileStatus APL_CardFile::LoadData(bool bForceReload)
{
	CAutoMutex autoMutex(&m_Mutex);		//We lock for only one instantiation

	std::wstring strPath = utilStringWiden(m_path);
	const wchar_t *wsPath= strPath.c_str();

	if(m_card!=NULL && (m_status==CARDFILESTATUS_UNREAD || bForceReload))
	{
		try
		{
			//Fill the m_data with the content of the file
			MWLOG(LEV_INFO, MOD_APL, L"LoadData: Ask for file %ls", wsPath);	//TODO replace by DEBUG
			ReadFile();
			MWLOG(LEV_INFO, MOD_APL, L"LoadData: Read file %ls ok", wsPath);	//TODO replace by DEBUG
		}
		catch(CMWException& e)
		{
			unsigned long err = e.GetError();
			if (err == EIDMW_ERR_FILE_NOT_FOUND)
			{
				MWLOG(LEV_INFO, MOD_APL, L"LoadData: File %ls not found", wsPath);
				m_status=CARDFILESTATUS_ERROR_NOFILE;
				return m_status;
			}

			if (err == EIDMW_ERR_CARD_COMM)
			{
				MWLOG(LEV_WARN, MOD_APL, L"LoadData: Could not read file : %ls - Error : 0x%x", wsPath,e.GetError());
				m_status=CARDFILESTATUS_ERROR_NOFILE;
				return m_status;
			}

			if (err == EIDMW_ERR_NOT_ACTIVATED)
			{
				MWLOG(LEV_WARN, MOD_APL, L"LoadData: Could not read file : %ls - Error : 0x%x", wsPath,e.GetError());
				m_status=CARDFILESTATUS_ERROR_NOFILE;
				return m_status;
			}

			MWLOG(LEV_ERROR, MOD_APL, L"LoadData: Could not read file : %ls - Error : 0x%x", wsPath,e.GetError());
			throw e;
		}
	}

	//Get the status
	//m_status=VerifyFile();
	m_status=CARDFILESTATUS_OK;

	//If Status ok, map the fields
	if(m_status==CARDFILESTATUS_OK)
		if(!MapFields())
			m_status=CARDFILESTATUS_ERROR_FORMAT;

	if(m_status!=CARDFILESTATUS_OK)
	{
		EmptyFields();
		if(!m_keepdata)
			m_data.ClearContents();
	}

	MWLOG(LEV_INFO, MOD_APL, L"LoadData: File : %ls - status : 0x%x", wsPath,m_status);

	return m_status;
}
コード例 #28
0
void CStreamSource::play()
{
	nlassert(!_Playing);
	bool play = false;
	CAudioMixerUser *mixer = CAudioMixerUser::instance();
	
	{
		CAutoMutex<CMutex> autoMutex(m_BufferMutex);
		
		//if ((mixer->getListenPosVector() - _Position).sqrnorm() > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance())
		if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance())
		{
			// Source is too far to play
			if (_Spawn)
			{
				if (_SpawnEndCb != NULL)
					_SpawnEndCb(this, _CbUserParam);
				delete this;
			}
			// nldebug("CStreamSource %p : play FAILED !", (CAudioMixerUser::IMixerEvent*)this);
			return;
		}
		
		CAudioMixerUser *mixer = CAudioMixerUser::instance();

		if (!hasPhysicalSource())
			initPhysicalSource();

		if (hasPhysicalSource())
		{
			ISource *pSource = getPhysicalSource();
			nlassert(pSource != NULL);
			
			for (uint i = 0; i < m_NextBuffer; ++i)
				pSource->submitStreamingBuffer(m_Buffers[i]);
			
			// pSource->setPos( _Position, false);
			pSource->setPos(getVirtualPos(), false);
			if (!m_Buffers[0]->isStereo())
			{
				pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false);
				setDirection(_Direction); // because there is a workaround inside
				pSource->setVelocity(_Velocity);
			}
			pSource->setGain(_Gain);
			pSource->setSourceRelativeMode(_RelativeMode);
			// pSource->setLooping(_Looping);
			pSource->setPitch(_Pitch);
			pSource->setAlpha(m_Alpha);
			
			// and play the sound
			play = pSource->play();
			// nldebug("CStreamSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this);
		}
		else
		{
			if (_Priority == HighestPri)
			{
				// This sound is not discardable, add it in waiting playlist
				mixer->addSourceWaitingForPlay(this);
				return;
			}
			else
			{
				// No source available, kill.
				if (_Spawn)
				{
					if (_SpawnEndCb != NULL)
						_SpawnEndCb(this, _CbUserParam);					
					delete this;
				}
				return;
			}
		}
		
		if (play)
			CSourceCommon::play();
	}

	nlassert(play);
}