Example #1
0
NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
			 struct cli_state *cli,
			 struct GROUP_POLICY_OBJECT *gpo)
{
	NTSTATUS result;
	char *server, *service, *nt_path, *unix_path;
	char *nt_ini_path, *unix_ini_path;

	result = gpo_explode_filesyspath(mem_ctx, gpo->file_sys_path,
					 &server, &service, &nt_path,
					 &unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	result = gpo_prepare_local_store(mem_ctx, unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	unix_ini_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
	nt_ini_path = talloc_asprintf(mem_ctx, "%s\\%s", nt_path, GPT_INI);
	NT_STATUS_HAVE_NO_MEMORY(unix_ini_path);
	NT_STATUS_HAVE_NO_MEMORY(nt_ini_path);

	result = gpo_copy_file(mem_ctx, cli, nt_ini_path, unix_ini_path);
	NT_STATUS_NOT_OK_RETURN(result);

	result = gpo_sync_directories(mem_ctx, cli, nt_path, unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	return NT_STATUS_OK;
}
Example #2
0
NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
                         ADS_STRUCT *ads,
                         const char *cache_dir,
			 const struct GROUP_POLICY_OBJECT *gpo)
{
	NTSTATUS result;
	char *server, *service, *nt_path, *unix_path;
	char *nt_ini_path, *unix_ini_path;
	struct cli_state *cli;


	result = gpo_explode_filesyspath(mem_ctx, cache_dir, gpo->file_sys_path,
					 &server, &service, &nt_path,
					 &unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	/* for now reuse the existing ds connection */

	result = gpo_connect_server(ads, ads->server.ldap_server, service, &cli);
	NT_STATUS_NOT_OK_RETURN(result);

	result = gpo_prepare_local_store(mem_ctx, cache_dir, unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	unix_ini_path = talloc_asprintf(mem_ctx, "%s/%s", unix_path, GPT_INI);
	nt_ini_path = talloc_asprintf(mem_ctx, "%s\\%s", nt_path, GPT_INI);
	NT_STATUS_HAVE_NO_MEMORY(unix_ini_path);
	NT_STATUS_HAVE_NO_MEMORY(nt_ini_path);

	result = gpo_copy_file(mem_ctx, cli, nt_ini_path, unix_ini_path);
	NT_STATUS_NOT_OK_RETURN(result);

	result = gpo_sync_directories(mem_ctx, cli, nt_path, unix_path);
	NT_STATUS_NOT_OK_RETURN(result);

	return NT_STATUS_OK;
}
Example #3
0
static void gpo_sync_func(const char *mnt,
			  file_info *info,
			  const char *mask,
			  void *state)
{
	NTSTATUS result;
	struct sync_context *ctx;
	fstring nt_filename, unix_filename;
	fstring nt_dir, unix_dir;
	char *old_nt_dir, *old_unix_dir;

	ctx = (struct sync_context *)state;

	if (strequal(info->name, ".") || strequal(info->name, "..")) {
		return;
	}

	DEBUG(5,("gpo_sync_func: got mask: [%s], name: [%s]\n", 
		mask, info->name));

	if (info->mode & aDIR) {

		DEBUG(3,("got dir: [%s]\n", info->name));

		fstrcpy(nt_dir, ctx->remote_path);
		fstrcat(nt_dir, "\\");
		fstrcat(nt_dir, info->name);

		fstrcpy(unix_dir, ctx->local_path);
		fstrcat(unix_dir, "/");
		fstrcat(unix_dir, info->name);

		result = gpo_copy_dir(unix_dir);
		if (!NT_STATUS_IS_OK(result)) {
			DEBUG(1,("failed to copy dir: %s\n", nt_errstr(result)));
		}

		old_nt_dir = ctx->remote_path;
		ctx->remote_path = nt_dir;
		
		old_unix_dir = ctx->local_path;
		ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);

		pstrcpy(ctx->mask, nt_dir);
		pstrcat(ctx->mask, "\\*");

		if (!gpo_sync_files(ctx)) {
			DEBUG(0,("could not sync files\n"));
		}

		ctx->remote_path = old_nt_dir;
		ctx->local_path = old_unix_dir;
		return;
	}

	DEBUG(3,("got file: [%s]\n", info->name));

	fstrcpy(nt_filename, ctx->remote_path);
	fstrcat(nt_filename, "\\");
	fstrcat(nt_filename, info->name);

	fstrcpy(unix_filename, ctx->local_path);
	fstrcat(unix_filename, "/");
	fstrcat(unix_filename, info->name);

	result = gpo_copy_file(ctx->mem_ctx, ctx->cli, nt_filename, unix_filename);
	if (!NT_STATUS_IS_OK(result)) {
		DEBUG(1,("failed to copy file: %s\n", nt_errstr(result)));
	}
}
Example #4
0
static NTSTATUS gpo_sync_func(const char *mnt,
			  struct file_info *info,
			  const char *mask,
			  void *state)
{
	NTSTATUS result;
	struct sync_context *ctx;
	fstring nt_filename, unix_filename;
	fstring nt_dir, unix_dir;
	char *old_nt_dir, *old_unix_dir;

	ctx = (struct sync_context *)state;

	if (strequal(info->name, ".") || strequal(info->name, "..")) {
		return NT_STATUS_OK;
	}

	DEBUG(5,("gpo_sync_func: got mask: [%s], name: [%s]\n",
		mask, info->name));

	if (info->mode & FILE_ATTRIBUTE_DIRECTORY) {

		DEBUG(3,("got dir: [%s]\n", info->name));

		fstrcpy(nt_dir, ctx->remote_path);
		fstrcat(nt_dir, "\\");
		fstrcat(nt_dir, info->name);

		fstrcpy(unix_dir, ctx->local_path);
		fstrcat(unix_dir, "/");
		fstrcat(unix_dir, info->name);

		result = gpo_copy_dir(unix_dir);
		if (!NT_STATUS_IS_OK(result)) {
			DEBUG(1,("failed to copy dir: %s\n",
				nt_errstr(result)));
			return result;
		}

		old_nt_dir = ctx->remote_path;
		ctx->remote_path = talloc_strdup(ctx->mem_ctx, nt_dir);

		old_unix_dir = ctx->local_path;
		ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);

		ctx->mask = talloc_asprintf(ctx->mem_ctx,
					"%s\\*",
					nt_dir);
		if (!ctx->local_path || !ctx->mask || !ctx->remote_path) {
			DEBUG(0,("gpo_sync_func: ENOMEM\n"));
			return NT_STATUS_NO_MEMORY;
		}
		result = gpo_sync_files(ctx);
		if (!NT_STATUS_IS_OK(result)) {
			DEBUG(0,("could not sync files\n"));
			return result;
		}

		ctx->remote_path = old_nt_dir;
		ctx->local_path = old_unix_dir;
		return NT_STATUS_OK;
	}

	DEBUG(3,("got file: [%s]\n", info->name));

	fstrcpy(nt_filename, ctx->remote_path);
	fstrcat(nt_filename, "\\");
	fstrcat(nt_filename, info->name);

	fstrcpy(unix_filename, ctx->local_path);
	fstrcat(unix_filename, "/");
	fstrcat(unix_filename, info->name);

	result = gpo_copy_file(ctx->mem_ctx, ctx->cli,
			       nt_filename, unix_filename);
	if (!NT_STATUS_IS_OK(result)) {
		DEBUG(1,("failed to copy file: %s\n",
			nt_errstr(result)));
	}
	return result;
}
Example #5
0
static void gpo_sync_func(struct clilist_file_info *info,
			  const char *mask,
			  void *state)
{
	NTSTATUS result;
	struct sync_context *ctx;
	char *nt_filename, *unix_filename;
	char *nt_dir, *unix_dir;
	char *old_nt_dir, *old_unix_dir;

	ctx = (struct sync_context *)state;

	if (strequal(info->name, ".") || strequal(info->name, "..")) {
		return;
	}

	DEBUG(5,("gpo_sync_func: got mask: [%s], name: [%s]\n",
		mask, info->name));

	if (info->attrib & FILE_ATTRIBUTE_DIRECTORY) {

		DEBUG(3,("got dir: [%s]\n", info->name));

		nt_dir = talloc_asprintf(ctx->mem_ctx, "%s\\%s",
				ctx->remote_path,
				info->name);

		unix_dir = talloc_asprintf(ctx->mem_ctx, "%s/%s",
				ctx->local_path,
				info->name);

		result = gpo_copy_dir(nt_dir, unix_dir);
		if (!NT_STATUS_IS_OK(result)) {
			DEBUG(1,("failed to copy dir: %s\n",
				nt_errstr(result)));
		}

		old_nt_dir = ctx->remote_path;
		ctx->remote_path = talloc_strdup(ctx->mem_ctx, nt_dir);

		old_unix_dir = ctx->local_path;
		ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);

		ctx->mask = talloc_asprintf(ctx->mem_ctx,
					"%s\\*",
					nt_dir);
		if (!ctx->local_path || !ctx->mask || !ctx->remote_path) {
			DEBUG(0,("gpo_sync_func: ENOMEM\n"));
			return;
		}
		if (!gpo_sync_files(ctx)) {
			DEBUG(0,("could not sync files\n"));
		}

		ctx->remote_path = old_nt_dir;
		ctx->local_path = old_unix_dir;
		return;
	}

	DEBUG(3,("got file: [%s]\n", info->name));

	nt_filename = talloc_asprintf(ctx->mem_ctx, "%s\\%s",
			ctx->remote_path,
			info->name);

	unix_filename = talloc_asprintf(ctx->mem_ctx, "%s/%s",
			ctx->local_path,
			info->name);

	result = gpo_copy_file(ctx->mem_ctx, ctx->cli,
			       nt_filename, unix_filename);
	if (!NT_STATUS_IS_OK(result)) {
		DEBUG(1,("failed to copy file: %s\n",
			nt_errstr(result)));
	}
}