コード例 #1
0
ファイル: data_manager.c プロジェクト: manjurajv/connman
int list_properties(DBusConnection *connection, char *function,
			char *service_name)
{
	DBusMessage *message;

	message = get_message(connection, function);
	if (message == NULL)
		return -ENOMEM;

	if (strcmp(function, "GetProperties") == 0)
		extract_manager_properties(message);

	else if (strcmp(function, "GetServices") == 0 && service_name != NULL)
		extract_services(message, service_name);

	else if (strcmp(function, "GetServices") == 0 && service_name == NULL)
		get_services(message);

	else if (strcmp(function, "GetTechnologies") == 0)
		extract_tech(message);

	dbus_message_unref(message);

	return 0;
}
コード例 #2
0
ファイル: k8s_state.cpp プロジェクト: mindscratch/sysdig
void k8s_state_t::update_cache(const k8s_component::component_map::key_type& component)
{
#ifdef K8S_DISABLE_THREAD

	switch (component)
	{
		case k8s_component::K8S_NAMESPACES:
		{
			const k8s_namespaces& nspaces = get_namespaces();
			k8s_state_t::namespace_map& ns_map = get_namespace_map();
			ns_map.clear();
			for(const auto& ns : nspaces)
			{
				std::string ns_name = ns.get_name();
				if(!is_component_cached(ns_map, ns_name, &ns))
				{
					cache_component(ns_map, ns_name, &ns);
				}
				else
				{
					g_logger.log("Attempt to cache already cached NAMESPACE: " + ns_name, sinsp_logger::SEV_ERROR);
				}
			}
		}
		break;

		case k8s_component::K8S_PODS:
		{
			const k8s_pods& pods = get_pods();
			k8s_state_t::container_pod_map& container_pod_map = get_container_pod_map();
			container_pod_map.clear();
			for(const auto& pod : pods)
			{
				const k8s_pod_t::container_id_list& c_ids = pod.get_container_ids();
				for(const auto& c_id : c_ids)
				{
					if(!is_component_cached(container_pod_map, c_id, &pod))
					{
						cache_pod(container_pod_map, c_id, &pod);
					}
					else
					{
						g_logger.log("Attempt to cache already cached POD: " + c_id, sinsp_logger::SEV_ERROR);
					}
				}
			}
		}
		break;

		case k8s_component::K8S_REPLICATIONCONTROLLERS:
		{
			const k8s_controllers& rcs = get_rcs();
			const k8s_pods& pods = get_pods();
			k8s_state_t::pod_rc_map& pod_ctrl_map = get_pod_rc_map();
			pod_ctrl_map.clear();
			for(const auto& rc : rcs)
			{
				std::vector<const k8s_pod_t*> pod_subset = rc.get_selected_pods(pods);
				for(auto& pod : pod_subset)
				{
					const std::string& pod_uid = pod->get_uid();
					if(!is_component_cached(pod_ctrl_map, pod_uid, &rc))
					{
						cache_component(pod_ctrl_map, pod_uid, &rc);
					}
					else
					{
						g_logger.log("Attempt to cache already cached REPLICATION CONTROLLER: " + pod_uid, sinsp_logger::SEV_ERROR);
					}
				}
			}
		}
		break;

		case k8s_component::K8S_SERVICES:
		{
			const k8s_services& services = get_services();
			const k8s_pods& pods = get_pods();
			k8s_state_t::pod_service_map& pod_svc_map = get_pod_service_map();
			pod_svc_map.clear();
			for(const auto& service : services)
			{
				std::vector<const k8s_pod_t*> pod_subset = service.get_selected_pods(pods);
				for(auto& pod : pod_subset)
				{
					const std::string& pod_uid = pod->get_uid();
					if(!is_component_cached(pod_svc_map, pod_uid, &service))
					{
						cache_component(pod_svc_map, pod_uid, &service);
					}
					else
					{
						g_logger.log("Attempt to cache already cached SERVICE: " + pod_uid, sinsp_logger::SEV_ERROR);
					}
				}
			}
		}
		break;

		default: return;
	}

#endif // K8S_DISABLE_THREAD
}
コード例 #3
0
ファイル: Services.cpp プロジェクト: security-geeks/al-khaser
BOOL VMDriverServices()
{
	const int KnownServiceCount = 13;
	const TCHAR* KnownVMServices[KnownServiceCount] = {
		L"VBoxWddm",
		L"VBoxSF", //VirtualBox Shared Folders
		L"VBoxMouse", //VirtualBox Guest Mouse
		L"VBoxGuest", //VirtualBox Guest Driver
		L"vmci", //VMWare VMCI Bus Driver
		L"vmhgfs", //VMWare Host Guest Control Redirector
		L"vmmouse",
		L"vmmemctl", //VMWare Guest Memory Controller Driver
		L"vmusb",
		L"vmusbmouse",
		L"vmx_svga",
		L"vmxnet",
		L"vmx86"
	};

	SC_HANDLE hSCM = OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE);
	if (hSCM != NULL)
	{
		ENUM_SERVICE_STATUS_PROCESS* services = NULL;
		DWORD serviceCount = 0;
		if (get_services(hSCM, SERVICE_DRIVER, &services, &serviceCount))
		{
			bool ok = true;

			for (DWORD i = 0; i < serviceCount; i++)
			{
				for (int s = 0; s < KnownServiceCount; s++)
				{
					if (StrCmpIW(services[i].lpServiceName, KnownVMServices[s]) == 0)
					{
						ok = false;
						break;
					}
				}
			}

			free(services);

			if (ok)
			{
				CloseServiceHandle(hSCM);
				return FALSE;
			}
			
		}
		else
		{
			printf("Failed to get services list.\n");
		}
		CloseServiceHandle(hSCM);
	}
	else
	{
		printf("Failed to get SCM handle.\n");
	}

	return TRUE;
}