return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS skel_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
.set_compression_fn = skel_set_compression,
.fstreaminfo_fn = skel_fstreaminfo,
- .get_real_filename_fn = skel_get_real_filename,
.get_real_filename_at_fn = skel_get_real_filename_at,
.connectpath_fn = skel_connectpath,
.brl_lock_windows_fn = skel_brl_lock_windows,
streams);
}
-static NTSTATUS skel_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle,
- path, name, mem_ctx, found_name);
-}
-
static NTSTATUS skel_get_real_filename_at(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
.set_compression_fn = skel_set_compression,
.fstreaminfo_fn = skel_fstreaminfo,
- .get_real_filename_fn = skel_get_real_filename,
.get_real_filename_at_fn = skel_get_real_filename_at,
.connectpath_fn = skel_connectpath,
.brl_lock_windows_fn = skel_brl_lock_windows,
* Version 47 - remove (unused) struct lock_struct last_lock_failure
from files_struct.
* Version 47 - Add SMB_VFS_GET_REAL_FILENAME_AT
+ * Version 47 - Replace SMB_VFS_GET_REAL_FILENAME with SMB_VFS_GET_REAL_FILENAME_AT
*/
#define SMB_VFS_INTERFACE_VERSION 47
unsigned int *num_streams,
struct stream_struct **streams);
- NTSTATUS (*get_real_filename_fn)(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name);
-
NTSTATUS (*get_real_filename_at_fn)(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);
-NTSTATUS smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name);
NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
#define SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx, num_streams, streams) \
smb_vfs_call_fstreaminfo(handle->next, (fsp), (mem_ctx), (num_streams), (streams))
-#define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) \
- smb_vfs_call_get_real_filename((conn)->vfs_handles, (path), (name), (mem_ctx), (found_name))
-#define SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx, found_name) \
- smb_vfs_call_get_real_filename((handle)->next, (path), (name), (mem_ctx), (found_name))
-
#define SMB_VFS_GET_REAL_FILENAME_AT(conn, dirfsp, name, mem_ctx, found_name) \
smb_vfs_call_get_real_filename_at( \
(conn)->vfs_handles, \
return -1;
}
-static NTSTATUS cephwrap_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- /*
- * Don't fall back to get_real_filename so callers can differentiate
- * between a full directory scan and an actual case-insensitive stat.
- */
- return NT_STATUS_NOT_SUPPORTED;
-}
-
static NTSTATUS cephwrap_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.mknodat_fn = cephwrap_mknodat,
.realpath_fn = cephwrap_realpath,
.fchflags_fn = cephwrap_fchflags,
- .get_real_filename_fn = cephwrap_get_real_filename,
.get_real_filename_at_fn = cephwrap_get_real_filename_at,
.connectpath_fn = cephwrap_connectpath,
aname, value, size, flags);
}
-static NTSTATUS ceph_snap_gmt_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- time_t timestamp = 0;
- char stripped[PATH_MAX + 1];
- char conv[PATH_MAX + 1];
- struct smb_filename conv_fname;
- int ret;
- NTSTATUS status;
-
- ret = ceph_snap_gmt_strip_snapshot(handle, path,
- ×tamp, stripped, sizeof(stripped));
- if (ret < 0) {
- return map_nt_error_from_unix(-ret);
- }
- if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
- mem_ctx, found_name);
- }
- ret = ceph_snap_gmt_convert_dir(handle, stripped,
- timestamp, conv, sizeof(conv));
- if (ret < 0) {
- return map_nt_error_from_unix(-ret);
- }
-
- conv_fname = (struct smb_filename) {
- .base_name = conv,
- };
-
- status = SMB_VFS_NEXT_GET_REAL_FILENAME(
- handle, &conv_fname, name, mem_ctx, found_name);
- return status;
-}
-
static NTSTATUS ceph_snap_gmt_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
.fsetxattr_fn = ceph_snap_gmt_fsetxattr,
.fchflags_fn = ceph_snap_gmt_fchflags,
- .get_real_filename_fn = ceph_snap_gmt_get_real_filename,
.get_real_filename_at_fn = ceph_snap_gmt_get_real_filename_at,
};
return NT_STATUS_OK;
}
-static NTSTATUS vfswrap_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- /*
- * Don't fall back to get_real_filename so callers can differentiate
- * between a full directory scan and an actual case-insensitive stat.
- */
- return NT_STATUS_NOT_SUPPORTED;
-}
-
static NTSTATUS vfswrap_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.file_id_create_fn = vfswrap_file_id_create,
.fs_file_id_fn = vfswrap_fs_file_id,
.fstreaminfo_fn = vfswrap_fstreaminfo,
- .get_real_filename_fn = vfswrap_get_real_filename,
.get_real_filename_at_fn = vfswrap_get_real_filename_at,
.connectpath_fn = vfswrap_connectpath,
.brl_lock_windows_fn = vfswrap_brl_lock_windows,
return result;
}
-static NTSTATUS smb_full_audit_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- NTSTATUS result;
-
- result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
- found_name);
-
- do_log(SMB_VFS_OP_GET_REAL_FILENAME,
- NT_STATUS_IS_OK(result),
- handle,
- "%s/%s->%s",
- path->base_name,
- name,
- NT_STATUS_IS_OK(result) ? *found_name : "");
-
- return result;
-}
-
static NTSTATUS smb_full_audit_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.snap_create_fn = smb_full_audit_snap_create,
.snap_delete_fn = smb_full_audit_snap_delete,
.fstreaminfo_fn = smb_full_audit_fstreaminfo,
- .get_real_filename_fn = smb_full_audit_get_real_filename,
.get_real_filename_at_fn = smb_full_audit_get_real_filename_at,
.connectpath_fn = smb_full_audit_connectpath,
.brl_lock_windows_fn = smb_full_audit_brl_lock_windows,
return -1;
}
-static NTSTATUS vfs_gluster_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- int ret;
- char key_buf[GLUSTER_NAME_MAX + 64];
- char val_buf[GLUSTER_NAME_MAX + 1];
-
- if (strlen(name) >= GLUSTER_NAME_MAX) {
- return NT_STATUS_OBJECT_NAME_INVALID;
- }
-
- snprintf(key_buf, GLUSTER_NAME_MAX + 64,
- "glusterfs.get_real_filename:%s", name);
-
- ret = glfs_getxattr(handle->data, path->base_name, key_buf, val_buf,
- GLUSTER_NAME_MAX + 1);
- if (ret == -1) {
- if (errno == ENOATTR) {
- errno = ENOENT;
- }
- return map_nt_error_from_unix(errno);
- }
-
- *found_name = talloc_strdup(mem_ctx, val_buf);
- if (found_name[0] == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
-}
-
static NTSTATUS vfs_gluster_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.fchflags_fn = vfs_gluster_fchflags,
.file_id_create_fn = NULL,
.fstreaminfo_fn = NULL,
- .get_real_filename_fn = vfs_gluster_get_real_filename,
.get_real_filename_at_fn = vfs_gluster_get_real_filename_at,
.connectpath_fn = vfs_gluster_connectpath,
.create_dfs_pathat_fn = vfs_gluster_create_dfs_pathat,
#define GLUSTER_NAME_MAX 255
-static NTSTATUS vfs_gluster_fuse_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **_found_name)
-{
- int ret;
- char key_buf[GLUSTER_NAME_MAX + 64];
- char val_buf[GLUSTER_NAME_MAX + 1];
- char *found_name = NULL;
-
- if (strlen(name) >= GLUSTER_NAME_MAX) {
- return NT_STATUS_OBJECT_NAME_INVALID;
- }
-
- snprintf(key_buf, GLUSTER_NAME_MAX + 64,
- "glusterfs.get_real_filename:%s", name);
-
- ret = getxattr(path->base_name, key_buf, val_buf, GLUSTER_NAME_MAX + 1);
- if (ret == -1) {
- if (errno == ENOATTR) {
- errno = ENOENT;
- }
- return map_nt_error_from_unix(errno);
- }
-
- found_name = talloc_strdup(mem_ctx, val_buf);
- if (found_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- *_found_name = found_name;
- return NT_STATUS_OK;
-}
-
static NTSTATUS vfs_gluster_fuse_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
struct vfs_fn_pointers glusterfs_fuse_fns = {
.connect_fn = vfs_glusterfs_fuse_connect,
- .get_real_filename_fn = vfs_gluster_fuse_get_real_filename,
.get_real_filename_at_fn = vfs_gluster_fuse_get_real_filename_at,
.file_id_create_fn = vfs_glusterfs_fuse_file_id_create,
};
}
#endif /* HAVE_KERNEL_OPLOCKS_LINUX */
-static NTSTATUS vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- int result;
- char *full_path = NULL;
- char *to_free = NULL;
- char real_pathname[PATH_MAX+1], tmpbuf[PATH_MAX];
- size_t full_path_len;
- int buflen;
- bool mangled;
- struct gpfs_config_data *config;
-
- SMB_VFS_HANDLE_GET_DATA(handle, config,
- struct gpfs_config_data,
- return NT_STATUS_INTERNAL_ERROR);
-
- if (!config->getrealfilename) {
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
- mem_ctx, found_name);
- }
-
- mangled = mangle_is_mangled(name, handle->conn->params);
- if (mangled) {
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
- mem_ctx, found_name);
- }
-
- full_path_len = full_path_tos(path->base_name, name,
- tmpbuf, sizeof(tmpbuf),
- &full_path, &to_free);
- if (full_path_len == -1) {
- return NT_STATUS_NO_MEMORY;
- }
-
- buflen = sizeof(real_pathname) - 1;
-
- result = gpfswrap_get_realfilename_path(full_path, real_pathname,
- &buflen);
-
- TALLOC_FREE(to_free);
-
- if ((result == -1) && (errno == ENOSYS)) {
- return SMB_VFS_NEXT_GET_REAL_FILENAME(
- handle, path, name, mem_ctx, found_name);
- }
-
- if (result == -1) {
- DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
- strerror(errno)));
- return map_nt_error_from_unix(errno);
- }
-
- /*
- * GPFS does not necessarily null-terminate the returned path
- * but instead returns the buffer length in buflen.
- */
-
- if (buflen < sizeof(real_pathname)) {
- real_pathname[buflen] = '\0';
- } else {
- real_pathname[sizeof(real_pathname)-1] = '\0';
- }
-
- DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
- path->base_name, name, real_pathname));
-
- name = strrchr_m(real_pathname, '/');
- if (name == NULL) {
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- }
-
- *found_name = talloc_strdup(mem_ctx, name+1);
- if (*found_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- return NT_STATUS_OK;
-}
-
static NTSTATUS vfs_gpfs_get_real_filename_at(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,
.fs_capabilities_fn = vfs_gpfs_capabilities,
.filesystem_sharemode_fn = vfs_gpfs_filesystem_sharemode,
.linux_setlease_fn = vfs_gpfs_setlease,
- .get_real_filename_fn = vfs_gpfs_get_real_filename,
.get_real_filename_at_fn = vfs_gpfs_get_real_filename_at,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
return NT_STATUS_NOT_IMPLEMENTED;
}
-_PUBLIC_
-NTSTATUS vfs_not_implemented_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- return NT_STATUS_NOT_IMPLEMENTED;
-}
-
_PUBLIC_
NTSTATUS vfs_not_implemented_get_real_filename_at(
struct vfs_handle_struct *handle,
.set_compression_fn = vfs_not_implemented_set_compression,
.fstreaminfo_fn = vfs_not_implemented_fstreaminfo,
- .get_real_filename_fn = vfs_not_implemented_get_real_filename,
.get_real_filename_at_fn = vfs_not_implemented_get_real_filename_at,
.connectpath_fn = vfs_not_implemented_connectpath,
.brl_lock_windows_fn = vfs_not_implemented_brl_lock_windows,
return status;
}
-static NTSTATUS shadow_copy2_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *fname,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- struct shadow_copy2_private *priv = NULL;
- struct shadow_copy2_config *config = NULL;
- time_t timestamp = 0;
- char *stripped = NULL;
- char *conv;
- struct smb_filename conv_fname;
- NTSTATUS status;
-
- SMB_VFS_HANDLE_GET_DATA(handle, priv, struct shadow_copy2_private,
- return NT_STATUS_INTERNAL_ERROR);
- config = priv->config;
-
- DBG_DEBUG("Path=[%s] name=[%s]\n", smb_fname_str_dbg(fname), name);
-
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- ×tamp, &stripped)) {
- status = map_nt_error_from_unix(errno);
- DEBUG(10, ("shadow_copy2_strip_snapshot failed\n"));
- return status;
- }
- if (timestamp == 0) {
- DEBUG(10, ("timestamp == 0\n"));
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, fname, name,
- mem_ctx, found_name);
- }
-
- /*
- * Note that stripped may be an empty string "" if path was ".". As
- * shadow_copy2_convert() combines "" with the shadow-copy tree connect
- * root fullpath and get_real_filename_full_scan() has an explicit check
- * for "" this works.
- */
- DBG_DEBUG("stripped [%s]\n", stripped);
-
- conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
- if (conv == NULL) {
- status = map_nt_error_from_unix(errno);
-
- if (!config->snapdirseverywhere) {
- DBG_DEBUG("shadow_copy2_convert [%s] failed\n", stripped);
- return status;
- }
-
- /*
- * We're called in the path traversal loop in unix_convert()
- * walking down the directory hierarchy. shadow_copy2_convert()
- * will fail if the snapshot directory is futher down in the
- * hierachy. Set conv to the original stripped path and try to
- * look it up in the filesystem with
- * SMB_VFS_NEXT_GET_REAL_FILENAME() or
- * get_real_filename_full_scan().
- */
- DBG_DEBUG("Use stripped [%s] as conv\n", stripped);
- conv = talloc_strdup(talloc_tos(), stripped);
- if (conv == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- }
-
- conv_fname = (struct smb_filename) {
- .base_name = conv,
- };
-
- DEBUG(10, ("Calling NEXT_GET_REAL_FILE_NAME for conv=[%s], "
- "name=[%s]\n", conv, name));
- status = SMB_VFS_NEXT_GET_REAL_FILENAME(
- handle, &conv_fname, name, mem_ctx, found_name);
- DEBUG(10, ("NEXT_REAL_FILE_NAME returned %s\n", nt_errstr(status)));
- if (NT_STATUS_IS_OK(status)) {
- return NT_STATUS_OK;
- }
- if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- TALLOC_FREE(conv);
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- status = get_real_filename_full_scan(handle->conn,
- conv,
- name,
- false,
- mem_ctx,
- found_name);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("Scan [%s] for [%s] failed\n",
- conv, name);
- return status;
- }
-
- DBG_DEBUG("Scan [%s] for [%s] returned [%s]\n",
- conv, name, *found_name);
-
- TALLOC_FREE(conv);
- return NT_STATUS_OK;
-}
-
static NTSTATUS shadow_copy2_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.mkdirat_fn = shadow_copy2_mkdirat,
.fsetxattr_fn = shadow_copy2_fsetxattr,
.fchflags_fn = shadow_copy2_fchflags,
- .get_real_filename_fn = shadow_copy2_get_real_filename,
.get_real_filename_at_fn = shadow_copy2_get_real_filename_at,
.pwrite_fn = shadow_copy2_pwrite,
.pwrite_send_fn = shadow_copy2_pwrite_send,
aname, value, size, flags);
}
-static NTSTATUS snapper_gmt_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *fpath,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- time_t timestamp;
- char *stripped;
- char *conv;
- struct smb_filename conv_fname;
- NTSTATUS status;
-
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fpath,
- ×tamp, &stripped)) {
- return NT_STATUS_NO_MEMORY;
- }
- if (timestamp == 0) {
- return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, fpath, name,
- mem_ctx, found_name);
- }
- if (stripped[0] == '\0') {
- *found_name = talloc_strdup(mem_ctx, name);
- if (*found_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
- }
- conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
- TALLOC_FREE(stripped);
- if (conv == NULL) {
- return map_nt_error_from_unix(errno);
- }
-
- conv_fname = (struct smb_filename) {
- .base_name = conv,
- };
-
- status = SMB_VFS_NEXT_GET_REAL_FILENAME(
- handle, &conv_fname, name, mem_ctx, found_name);
- TALLOC_FREE(conv);
- return status;
-}
-
static NTSTATUS snapper_gmt_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
.fsetxattr_fn = snapper_gmt_fsetxattr,
.fchflags_fn = snapper_gmt_fchflags,
- .get_real_filename_fn = snapper_gmt_get_real_filename,
.get_real_filename_at_fn = snapper_gmt_get_real_filename_at,
};
return result;
}
-static NTSTATUS smb_time_audit_get_real_filename(
- struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- NTSTATUS result;
- struct timespec ts1,ts2;
- double timediff;
-
- clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
- found_name);
- clock_gettime_mono(&ts2);
- timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
- if (timediff > audit_timeout) {
- smb_time_audit_log_fname("get_real_filename",
- timediff, path->base_name);
- }
-
- return result;
-}
-
static NTSTATUS smb_time_audit_get_real_filename_at(
struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
.snap_create_fn = smb_time_audit_snap_create,
.snap_delete_fn = smb_time_audit_snap_delete,
.fstreaminfo_fn = smb_time_audit_fstreaminfo,
- .get_real_filename_fn = smb_time_audit_get_real_filename,
.get_real_filename_at_fn = smb_time_audit_get_real_filename_at,
.connectpath_fn = smb_time_audit_connectpath,
.brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
num_streams, streams);
}
-NTSTATUS smb_vfs_call_get_real_filename(struct vfs_handle_struct *handle,
- const struct smb_filename *path,
- const char *name,
- TALLOC_CTX *mem_ctx,
- char **found_name)
-{
- VFS_FIND(get_real_filename);
- return handle->fns->get_real_filename_fn(handle, path, name, mem_ctx,
- found_name);
-}
-
NTSTATUS smb_vfs_call_get_real_filename_at(struct vfs_handle_struct *handle,
struct files_struct *dirfsp,
const char *name,