Пример #1
0
/**
 * Open a directory for enumeration.
 *
 * Create a state struct to track the state of this directory for the life
 * of this open.
 *
 * @param[in] handle vfs handle given in most VFS calls
 * @param[in] fname filename of the directory to open
 * @param[in] mask unused
 * @param[in] attr unused
 *
 * @return DIR pointer, NULL if directory does not exist, NULL on error
 */
SMB_STRUCT_DIR *
onefs_opendir(vfs_handle_struct *handle, const char *fname, const char *mask,
	      uint32 attr)
{
	int ret = 0;
	SMB_STRUCT_DIR *ret_dirp;

	/* Fallback to default system routines if readdirplus is disabled */
	if (!lp_parm_bool(SNUM(handle->conn), PARM_ONEFS_TYPE,
	    PARM_USE_READDIRPLUS, PARM_USE_READDIRPLUS_DEFAULT))
	{
		return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
	}

	/* Open the directory */
	ret_dirp = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
	if (!ret_dirp) {
		DEBUG(3, ("Unable to open directory: %s\n", fname));
		return NULL;
	}

	/* Create the dir_state struct and add it to the list */
	ret = onefs_rdp_add_dir_state(handle->conn, ret_dirp);
	if (ret) {
		DEBUG(0, ("Error adding dir_state to the list\n"));
		return NULL;
	}

	DEBUG(9, ("Opened handle on directory: \"%s\", DIR %p\n",
		 fname, ret_dirp));

	return ret_dirp;
}
Пример #2
0
static DIR *skel_opendir(vfs_handle_struct *handle,
			const struct smb_filename *smb_fname,
			const char *mask,
			uint32_t attr)
{
	return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
}
Пример #3
0
static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle,
				       const char *fname, const char *mask,
				       uint32 attr)
{
	struct dirsort_privates *data = NULL;

	/* set up our private data about this directory */
	data = (struct dirsort_privates *)SMB_MALLOC(
		sizeof(struct dirsort_privates));

	if (!data) {
		return NULL;
	}

	data->directory_list = NULL;
	data->pos = 0;

	/* Open the underlying directory and count the number of entries */
	data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
						      attr);

	data->fd = dirfd(data->source_directory);

	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
				struct dirsort_privates, return NULL);

	if (!open_and_sort_dir(handle)) {
		SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
		return NULL;
	}

	return data->source_directory;
}
Пример #4
0
static SMB_STRUCT_DIR *opendir_acl_common(vfs_handle_struct *handle,
			const char *fname, const char *mask, uint32 attr)
{
	NTSTATUS status = check_parent_acl_common(handle, fname,
					SEC_DIR_LIST, NULL);

	if (!NT_STATUS_IS_OK(status)) {
		errno = map_errno_from_nt_status(status);
		return NULL;
	}
	return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
}
Пример #5
0
static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
{
	SMB_STRUCT_DIR *result;
	
	result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);

	syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
	       fname,
	       (result == NULL) ? "failed: " : "",
	       (result == NULL) ? strerror(errno) : "");

	return result;
}
Пример #6
0
static DIR *vfsx_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
{
	// TODO: Is this the correct error value?
	DIR *result = NULL;
	int count;
	char buf[VFSX_MSG_OUT_SIZE];

	count = snprintf(buf, VFSX_MSG_OUT_SIZE, "opendir:%s:%s:%s", handle->conn->user, handle->conn->origpath, fname);
	if (vfsx_execute(buf, count) == VFSX_SUCCESS_TRANSPARENT) {
		result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
	}
	return result;
}
Пример #7
0
static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels)
{
	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn,fsp->conn->connectpath);

	shadow_copy_data->num_volumes = 0;
	shadow_copy_data->labels = NULL;

	if (!p) {
		DEBUG(0,("shadow_copy_get_shadow_copy_data: SMB_VFS_NEXT_OPENDIR() failed for [%s]\n",fsp->conn->connectpath));
		return -1;
	}

	while (True) {
		SHADOW_COPY_LABEL *tlabels;
		SMB_STRUCT_DIRENT *d;

		d = SMB_VFS_NEXT_READDIR(handle, fsp->conn, p);
		if (d == NULL) {
			break;
		}

		/* */
		if (!shadow_copy_match_name(d->d_name)) {
			DEBUG(10,("shadow_copy_get_shadow_copy_data: ignore [%s]\n",d->d_name));
			continue;
		}

		DEBUG(7,("shadow_copy_get_shadow_copy_data: not ignore [%s]\n",d->d_name));

		if (!labels) {
			shadow_copy_data->num_volumes++;
			continue;
		}

		tlabels = (SHADOW_COPY_LABEL *)TALLOC_REALLOC(shadow_copy_data->mem_ctx,
									shadow_copy_data->labels,
									(shadow_copy_data->num_volumes+1)*sizeof(SHADOW_COPY_LABEL));
		if (tlabels == NULL) {
			DEBUG(0,("shadow_copy_get_shadow_copy_data: Out of memory\n"));
			SMB_VFS_NEXT_CLOSEDIR(handle,fsp->conn,p);
			return -1;
		}

		snprintf(tlabels[shadow_copy_data->num_volumes++], sizeof(*tlabels), "%s",d->d_name);

		shadow_copy_data->labels = tlabels;
	}

	SMB_VFS_NEXT_CLOSEDIR(handle,fsp->conn,p);
	return 0;
}
Пример #8
0
static DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
{
	shadow_copy_Dir *dirp;
	DIR *p = SMB_VFS_NEXT_OPENDIR(handle,conn,fname);

	if (!p) {
		DEBUG(0,("shadow_copy_opendir: SMB_VFS_NEXT_OPENDIR() failed for [%s]\n",fname));
		return NULL;
	}

	dirp = SMB_MALLOC_P(shadow_copy_Dir);
	if (!dirp) {
		DEBUG(0,("shadow_copy_opendir: Out of memory\n"));
		SMB_VFS_NEXT_CLOSEDIR(handle,conn,p);
		return NULL;
	}

	ZERO_STRUCTP(dirp);

	while (True) {
		SMB_STRUCT_DIRENT *d;
		SMB_STRUCT_DIRENT *r;


		d = SMB_VFS_NEXT_READDIR(handle, conn, p);
		if (d == NULL) {
			break;
		}

		if (shadow_copy_match_name(d->d_name)) {
			DEBUG(8,("shadow_copy_opendir: hide [%s]\n",d->d_name));
			continue;
		}

		DEBUG(10,("shadow_copy_opendir: not hide [%s]\n",d->d_name));

		r = SMB_REALLOC_ARRAY(dirp->dirs,SMB_STRUCT_DIRENT, dirp->num+1);
		if (!r) {
			DEBUG(0,("shadow_copy_opendir: Out of memory\n"));
			break;
		}

		dirp->dirs = r;
		dirp->dirs[dirp->num++] = *d;
	}

	SMB_VFS_NEXT_CLOSEDIR(handle,conn,p);
	return((DIR *)dirp);
}
Пример #9
0
static DIR *audit_opendir(vfs_handle_struct *handle,
			const struct smb_filename *smb_fname,
			const char *mask,
			uint32_t attr)
{
	DIR *result;
	
	result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);

	syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
	       smb_fname->base_name,
	       (result == NULL) ? "failed: " : "",
	       (result == NULL) ? strerror(errno) : "");

	return result;
}
Пример #10
0
static DIR *dirsort_opendir(vfs_handle_struct *handle,
				       const char *fname, const char *mask,
				       uint32 attr)
{
	struct dirsort_privates *list_head = NULL;
	struct dirsort_privates *data = NULL;

	if (SMB_VFS_HANDLE_TEST_DATA(handle)) {
		/* Find the list head of all open directories. */
		SMB_VFS_HANDLE_GET_DATA(handle, list_head, struct dirsort_privates,
				return NULL);
	}

	/* set up our private data about this directory */
	data = talloc_zero(handle->conn, struct dirsort_privates);
	if (!data) {
		return NULL;
	}

	data->smb_fname = synthetic_smb_fname(data, fname, NULL, NULL);
	if (data->smb_fname == NULL) {
		TALLOC_FREE(data);
		return NULL;
	}

	/* Open the underlying directory and count the number of entries */
	data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
						      attr);

	if (data->source_directory == NULL) {
		TALLOC_FREE(data);
		return NULL;
	}

	if (!open_and_sort_dir(handle, data)) {
		SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
		TALLOC_FREE(data);
		return NULL;
	}

	/* Add to the private list of all open directories. */
	DLIST_ADD(list_head, data);
	SMB_VFS_HANDLE_SET_DATA(handle, list_head, NULL,
				struct dirsort_privates, return NULL);

	return data->source_directory;
}
Пример #11
0
static DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
{
	DIR *result;

	result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);

	if (lp_syslog() > 0) {
		syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
		       fname,
		       (result == NULL) ? "failed: " : "",
		       (result == NULL) ? strerror(errno) : "");
	}
	DEBUG(1, ("vfs_extd_audit: opendir %s %s %s\n",
	       fname,
	       (result == NULL) ? "failed: " : "",
	       (result == NULL) ? strerror(errno) : ""));

	return result;
}
Пример #12
0
static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle,
				       const char *fname, const char *mask,
				       uint32 attr)
{
	NTSTATUS status;
	struct dirsort_privates *data = NULL;

	/* set up our private data about this directory */
	data = talloc_zero(handle->conn, struct dirsort_privates);
	if (!data) {
		return NULL;
	}

	status = create_synthetic_smb_fname(data,
					fname,
					NULL,
					NULL,
					&data->smb_fname);
	if (!NT_STATUS_IS_OK(status)) {
		TALLOC_FREE(data);
		return NULL;
	}

	/* Open the underlying directory and count the number of entries */
	data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
						      attr);

	if (data->source_directory == NULL) {
		TALLOC_FREE(data);
		return NULL;
	}

	if (!open_and_sort_dir(handle, data)) {
		SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
		TALLOC_FREE(data);
		return NULL;
	}

	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
				struct dirsort_privates, return NULL);

	return data->source_directory;
}
Пример #13
0
SMB_STRUCT_DIR *atalk_opendir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attr)
{
	SMB_STRUCT_DIR *ret = 0;

	ret = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr);

	/*
	 * when we try to perform delete operation upon file which has fork
	 * in ./.AppleDouble and this directory wasn't hidden by Samba,
	 * MS Windows explorer causes the error: "Cannot find the specified file"
	 * There is some workaround to avoid this situation, i.e. if
	 * connection has not .AppleDouble entry in either veto or hide 
	 * list then it would be nice to add one.
	 */

	atalk_add_to_list(&conn->hide_list);
	atalk_add_to_list(&conn->veto_list);

	return ret;
}
Пример #14
0
static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle,  const char *fname, const char *mask, uint32 attr)
{
	return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
}
Пример #15
0
static DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname)
{
        pstring capname;
        capencode(capname, fname);
	return SMB_VFS_NEXT_OPENDIR(handle, conn, capname);
}
Пример #16
0
static SMB_STRUCT_DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr)
{
        pstring capname;
        capencode(capname, fname);
	return SMB_VFS_NEXT_OPENDIR(handle, conn, capname, mask, attr);
}