예제 #1
0
파일: registry.c 프로젝트: Arkhont/samba
static NTSTATUS registry_process_group_policy(ADS_STRUCT *ads,
					      TALLOC_CTX *mem_ctx,
					      uint32_t flags,
					      struct registry_key *root_key,
					      const struct security_token *token,
					      struct GROUP_POLICY_OBJECT *gpo,
					      const char *extension_guid,
					      const char *snapin_guid)
{
	NTSTATUS status;
	WERROR werr;
	struct gp_registry_entry *entries = NULL;
	size_t num_entries = 0;
	char *unix_path = NULL;

	debug_gpext_header(0, "registry_process_group_policy", flags, gpo,
			   extension_guid, snapin_guid);

	status = gpo_get_unix_path(mem_ctx, cache_path(GPO_CACHE_DIR), gpo, &unix_path);
	NT_STATUS_NOT_OK_RETURN(status);

	status = reg_parse_registry(mem_ctx,
				    flags,
				    unix_path,
				    &entries,
				    &num_entries);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0,("failed to parse registry: %s\n",
			nt_errstr(status)));
		return status;
	}

	dump_reg_entries(flags, "READ", entries, num_entries);

	werr = reg_apply_registry(mem_ctx, token, root_key, flags,
				  entries, num_entries);
	if (!W_ERROR_IS_OK(werr)) {
		DEBUG(0,("failed to apply registry: %s\n",
			win_errstr(werr)));
		return werror_to_ntstatus(werr);
	}

	return NT_STATUS_OK;
}
예제 #2
0
파일: scripts.c 프로젝트: samba-team/samba
static NTSTATUS scripts_process_group_policy(TALLOC_CTX *mem_ctx,
					     uint32_t flags,
					     struct registry_key *root_key,
					     const struct security_token *token,
					     const struct GROUP_POLICY_OBJECT *deleted_gpo_list,
					     const struct GROUP_POLICY_OBJECT *changed_gpo_list)
{
	NTSTATUS status;
	WERROR werr;
	int i = 0;
	char *unix_path = NULL;
	struct gp_inifile_context *ini_ctx = NULL;
	struct gp_registry_entry *entries = NULL;
	size_t num_entries = 0;
	const char *list[] = {
		GP_SCRIPTS_INI_STARTUP,
		GP_SCRIPTS_INI_SHUTDOWN,
		GP_SCRIPTS_INI_LOGON,
		GP_SCRIPTS_INI_LOGOFF
	};
	const struct GROUP_POLICY_OBJECT *gpo;
	char *gpo_cache_path = cache_path(GPO_CACHE_DIR);
	if (gpo_cache_path == NULL) {
		return NT_STATUS_NO_MEMORY;
	}

	/* implementation of the policy callback function, see
	 * http://msdn.microsoft.com/en-us/library/aa373494%28v=vs.85%29.aspx
	 * for details - gd */

	/* for now do not process the list of deleted group policies

	for (gpo = deleted_gpo_list; gpo; gpo = gpo->next) {
	}

	*/

	for (gpo = changed_gpo_list; gpo; gpo = gpo->next) {

		gpext_debug_header(0, "scripts_process_group_policy", flags,
				   gpo, GP_EXT_GUID_SCRIPTS, NULL);

		status = gpo_get_unix_path(mem_ctx, gpo_cache_path,
					   gpo, &unix_path);
		if (!NT_STATUS_IS_OK(status)) {
			goto err_cache_path_free;
		}

		status = gp_inifile_init_context(mem_ctx, flags, unix_path,
						 GP_SCRIPTS_INI, &ini_ctx);
		if (!NT_STATUS_IS_OK(status)) {
			goto err_cache_path_free;
		}

		for (i = 0; i < ARRAY_SIZE(list); i++) {

			TALLOC_FREE(entries);
			num_entries = 0;

			status = scripts_parse_ini_section(ini_ctx, flags, list[i],
							   &entries, &num_entries);
			if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
				continue;
			}

			if (!NT_STATUS_IS_OK(status)) {
				TALLOC_FREE(ini_ctx);
				goto err_cache_path_free;
			}

			dump_reg_entries(flags, "READ", entries, num_entries);

			werr = scripts_apply(ini_ctx->mem_ctx, token, root_key,
					     flags, list[i], gpo, entries, num_entries);
			if (!W_ERROR_IS_OK(werr)) {
				continue; /* FIXME: finally fix storing emtpy strings and REG_QWORD! */
			}
		}

		TALLOC_FREE(ini_ctx);
	}
	status = NT_STATUS_OK;

err_cache_path_free:
	talloc_free(gpo_cache_path);
	return status;
}
예제 #3
0
파일: scripts.c 프로젝트: berte/mediaplayer
static NTSTATUS scripts_process_group_policy(ADS_STRUCT *ads,
					     TALLOC_CTX *mem_ctx,
					     uint32_t flags,
					     struct registry_key *root_key,
					     const struct nt_user_token *token,
					     struct GROUP_POLICY_OBJECT *gpo,
					     const char *extension_guid,
					     const char *snapin_guid)
{
	NTSTATUS status;
	WERROR werr;
	int i = 0;
	char *unix_path = NULL;
	struct gp_inifile_context *ini_ctx = NULL;
	struct gp_registry_entry *entries = NULL;
	size_t num_entries = 0;
	const char *list[] = {
		GP_SCRIPTS_INI_STARTUP,
		GP_SCRIPTS_INI_SHUTDOWN,
		GP_SCRIPTS_INI_LOGON,
		GP_SCRIPTS_INI_LOGOFF
	};

	debug_gpext_header(0, "scripts_process_group_policy", flags, gpo,
			   extension_guid, snapin_guid);

	status = gpo_get_unix_path(mem_ctx, gpo, &unix_path);
	NT_STATUS_NOT_OK_RETURN(status);

	status = gp_inifile_init_context(mem_ctx, flags, unix_path,
					 GP_SCRIPTS_INI, &ini_ctx);
	NT_STATUS_NOT_OK_RETURN(status);

	for (i = 0; i < ARRAY_SIZE(list); i++) {

		TALLOC_FREE(entries);
		num_entries = 0;

		status = scripts_parse_ini_section(ini_ctx, flags, list[i],
						   &entries, &num_entries);
		if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
			continue;
		}

		if (!NT_STATUS_IS_OK(status)) {
			return status;
		}

		dump_reg_entries(flags, "READ", entries, num_entries);

		werr = scripts_apply(ini_ctx->mem_ctx, token, root_key,
				     flags, list[i], gpo, entries, num_entries);
		if (!W_ERROR_IS_OK(werr)) {
			continue; /* FIXME: finally fix storing emtpy strings and REG_QWORD! */
			TALLOC_FREE(ini_ctx);
			return werror_to_ntstatus(werr);
		}
	}

	TALLOC_FREE(ini_ctx);
	return NT_STATUS_OK;
}