bool ControllerFilestream::pre_fct( std::vector< GenericCamera *> & cams)
{

    bfs::path sandbox( get_sandbox() );
    if( bfs::is_directory(sandbox) )
    {
        std::vector<bfs::path> ls_path;
        copy(bfs::directory_iterator(sandbox), bfs::directory_iterator(), back_inserter(ls_path));
        for(std::vector< bfs::path >::const_iterator it = ls_path.begin(); it != ls_path.end(); ++it)
        {
            if( bfs::is_regular_file(*it) && bfs::extension(*it) == ".conf" )
            {
                CameraFilestream * cam = new CameraFilestream();
                cam->read_config_file( (*it).string().c_str() );
                if(cam->is_active())
                {
                    cam->init_camera();
                }
                cams.push_back(cam);
                _cams.push_back(cam);
            }
        }
    }
    return true;

}
示例#2
0
文件: utils.c 项目: shifter/firejail
// return NULL if error (such as path limit reached)
NsRule *find_or_create_rule(void) {
	struct task_struct *real_parent;

	// look for an exiting active namespace entry in the list
	NsRule *ptr = find_rule(current->nsproxy);
	if (ptr)
		return ptr;
	
	// find the sandbox task
	real_parent = get_sandbox();

	// reuse an inactive entry
	ptr = head.next;
	while (ptr) {
		if (ptr->active == 0)
			break;
		ptr = ptr->next;
	}
	if (ptr) { // found an inactive entry
		int i;
		
		// clean unix path
		for (i = 0; i < MAX_UNIX_PATH; i++) {
			ptr->unix_path_len[i] = 0;
			if (ptr->unix_path[i]) {
				char *tmp = ptr->unix_path[i];
				ptr->unix_path[i] = NULL;
				kfree(tmp);
			}
		}
		
		// set the rule
		ptr->nsproxy = current->nsproxy;
		ptr->sandbox_pid = real_parent->pid;
		ptr->active = 1;
		printk(KERN_INFO "firejail[%u]: setup sandbox.\n", ptr->sandbox_pid);
		return ptr;
	}
	
	// allocate a new rule
	ptr = kmalloc(sizeof(NsRule), GFP_KERNEL);
	memset(ptr, 0, sizeof(NsRule));
	ptr->nsproxy = current->nsproxy;
	ptr->sandbox_pid = real_parent->pid;

	// insert the new rule in the rule list
	ptr->next = head.next;
	head.next = ptr;
	ptr->active = 1;
	printk(KERN_INFO "firejail[%u]: setup sandbox.\n", ptr->sandbox_pid);
	return ptr;
}
bool XMLRPCServer::pre_fct()
{
    std::string filename = get_sandbox() + std::string("/xmlrpc-server.conf") ;

    try
    {
        read_config_file ( filename.c_str() );
    }
    catch( ... )
    {
        /* unexisting config file, assume default value */
    }

    m_server.bindAndListen(m_server_port);
    m_server_th = new boost::thread(boost::bind(&XMLRPCServer::WorkThread, this));

    whiteboard_write<XMLRPCServer *> ( "plugin_xmlrpc-server", this );

    return true;
}