VFS_EXPAND_MSDFS_OBJ = modules/vfs_expand_msdfs.o
VFS_SHADOW_COPY_OBJ = modules/vfs_shadow_copy.o
VFS_SHADOW_COPY2_OBJ = modules/vfs_shadow_copy2.o
+VFS_GMT_TOKEN_OBJ = modules/vfs_gmt_token.o
VFS_AFSACL_OBJ = modules/vfs_afsacl.o
VFS_XATTR_TDB_OBJ = modules/vfs_xattr_tdb.o lib/xattr_tdb.o
VFS_POSIXACL_OBJ = modules/vfs_posixacl.o
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_SHADOW_COPY2_OBJ)
+bin/gmt_token.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_GMT_TOKEN_OBJ)
+ @echo "Building plugin $@"
+ @$(SHLD_MODULE) $(VFS_GMT_TOKEN_OBJ)
+
bin/syncops.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_SYNCOPS_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(VFS_SYNCOPS_OBJ)
default_shared_modules="$default_shared_modules vfs_expand_msdfs"
default_shared_modules="$default_shared_modules vfs_shadow_copy"
default_shared_modules="$default_shared_modules vfs_shadow_copy2"
+default_shared_modules="$default_shared_modules vfs_gmt_token"
default_shared_modules="$default_shared_modules auth_script"
default_shared_modules="$default_shared_modules vfs_readahead"
default_shared_modules="$default_shared_modules vfs_xattr_tdb"
SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_gmt_token, \$(VFS_SHADOW_COPY2_OBJ), "bin/gmt_token.$SHLIBEXT", VFS)
SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
NTSTATUS (*snap_delete_recv_fn)(struct vfs_handle_struct *handle,
struct tevent_req *req);
+ NTSTATUS (*snap_dir_expand_fn)(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ time_t tstamp,
+ char **snap_dir_out);
+
NTSTATUS (*streaminfo_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
char *snap_path);
NTSTATUS smb_vfs_call_snap_delete_recv(struct vfs_handle_struct *handle,
struct tevent_req *req);
+NTSTATUS smb_vfs_call_snap_dir_expand(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ time_t tstamp,
+ char **snap_dir_out);
NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32 security_info,
#define SMB_VFS_NEXT_SNAP_DELETE_RECV(handle, req) \
smb_vfs_call_snap_delete_recv((handle)->next, (req))
-#define SMB_VFS_FGET_NT_ACL(fsp, security_info, mem_ctx, ppdesc) \
- smb_vfs_call_fget_nt_acl((fsp)->conn->vfs_handles, (fsp), (security_info), (mem_ctx), (ppdesc))
+#define SMB_VFS_SNAP_DIR_EXPAND(conn, mem_ctx, tstamp, snap_dir_out) \
+ smb_vfs_call_snap_dir_expand((conn)->vfs_handles, (mem_ctx), (tstamp), (snap_dir_out))
+#define SMB_VFS_NEXT_SNAP_DIR_EXPAND(handle, mem_ctx, tstamp, snap_dir_out) \
+ smb_vfs_call_snap_dir_expand((handle)->next, (mem_ctx), (tstamp), (snap_dir_out))
+
+#define SMB_VFS_FGET_NT_ACL(fsp, security_info, mem_ctx, ppdesc) \
+ smb_vfs_call_fget_nt_acl((fsp)->conn->vfs_handles, (fsp), (security_info), (mem_ctx), (ppdesc))
#define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, mem_ctx, ppdesc) \
smb_vfs_call_fget_nt_acl((handle)->next, (fsp), (security_info), (mem_ctx), (ppdesc))
return NT_STATUS_NOT_SUPPORTED;
}
+static NTSTATUS vfswrap_snap_dir_expand(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ time_t tstamp,
+ char **snap_dir_out)
+{
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
/* Directory operations */
static DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
.snap_create_recv_fn = vfswrap_snap_create_recv,
.snap_delete_send_fn = vfswrap_snap_delete_send,
.snap_delete_recv_fn = vfswrap_snap_delete_recv,
+ .snap_dir_expand_fn = vfswrap_snap_dir_expand,
/* Directory operations */
#define GMT_NAME_LEN 24 /* length of a @GMT- name */
#define GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
-/*
- * callout provided by parent module
- */
-static char *gmt_tok_insert_string(TALLOC_CTX *mem_ctx,
- vfs_handle_struct *handle,
- time_t timestamp);
-
static bool gmt_tok_strip_snapshot(TALLOC_CTX *mem_ctx,
struct vfs_handle_struct *handle,
const char *name,
if (lp_parm_bool(SNUM(handle->conn), "shadow", "snapdirseverywhere",
false)) {
+ NTSTATUS status;
char *insert;
bool have_insert;
- insert = gmt_tok_insert_string(talloc_tos(), handle,
- timestamp);
- if (insert == NULL) {
- errno = ENOMEM;
+ status = SMB_VFS_SNAP_DIR_EXPAND(handle->conn, talloc_tos(),
+ timestamp, &insert);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
return false;
}
size_t insertlen;
int i, saved_errno;
size_t min_offset;
+ NTSTATUS status;
path = talloc_asprintf(mem_ctx, "%s/%s", handle->conn->connectpath,
name);
&slashes, &num_slashes)) {
goto fail;
}
- insert = gmt_tok_insert_string(talloc_tos(), handle, timestamp);
- if (insert == NULL) {
+ status = SMB_VFS_SNAP_DIR_EXPAND(handle->conn, talloc_tos(), timestamp,
+ &insert);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto fail;
}
insertlen = talloc_get_size(insert)-1;
char *inserted = NULL;
char *inserted_to, *inserted_end;
int saved_errno;
+ NTSTATUS status;
if (!gmt_tok_strip_snapshot(talloc_tos(), handle, fname,
×tamp, &stripped)) {
* Take away what we've inserted. This removes the @GMT token
* completely, but will give a path under the share root.
*/
- inserted = gmt_tok_insert_string(talloc_tos(), handle, timestamp);
- if (inserted == NULL) {
+ status = SMB_VFS_SNAP_DIR_EXPAND(handle->conn, talloc_tos(), timestamp,
+ &inserted);
+ if (!NT_STATUS_IS_OK(status)) {
+ errno = map_errno_from_nt_status(status);
goto done;
}
inserted_to = strstr_m(result, inserted);
errno = saved_errno;
return ret;
}
+
+static struct vfs_fn_pointers vfs_gmt_token_fns = {
+ .opendir_fn = gmt_tok_opendir,
+ .rename_fn = gmt_tok_rename,
+ .link_fn = gmt_tok_link,
+ .symlink_fn = gmt_tok_symlink,
+ .stat_fn = gmt_tok_stat,
+ .lstat_fn = gmt_tok_lstat,
+ .fstat_fn = gmt_tok_fstat,
+ .open_fn = gmt_tok_open,
+ .unlink_fn = gmt_tok_unlink,
+ .chmod_fn = gmt_tok_chmod,
+ .chown_fn = gmt_tok_chown,
+ .chdir_fn = gmt_tok_chdir,
+ .ntimes_fn = gmt_tok_ntimes,
+ .readlink_fn = gmt_tok_readlink,
+ .mknod_fn = gmt_tok_mknod,
+ .realpath_fn = gmt_tok_realpath,
+ .get_nt_acl_fn = gmt_tok_get_nt_acl,
+ .fget_nt_acl_fn = gmt_tok_fget_nt_acl,
+ .mkdir_fn = gmt_tok_mkdir,
+ .rmdir_fn = gmt_tok_rmdir,
+ .getxattr_fn = gmt_tok_getxattr,
+ .listxattr_fn = gmt_tok_listxattr,
+ .removexattr_fn = gmt_tok_removexattr,
+ .setxattr_fn = gmt_tok_setxattr,
+ .chmod_acl_fn = gmt_tok_chmod_acl,
+ .chflags_fn = gmt_tok_chflags,
+ .get_real_filename_fn = gmt_tok_get_real_filename,
+};
+
+NTSTATUS vfs_gmt_token_init(void);
+NTSTATUS vfs_gmt_token_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
+ "gmt_token", &vfs_gmt_token_fns);
+}
#include "system/filesys.h"
#include "include/ntioctl.h"
-/* include common @GMT token filter code */
-#include "vfs_gmt_tok_common.c"
-
-static char *gmt_tok_insert_string(TALLOC_CTX *mem_ctx,
- struct vfs_handle_struct *handle,
- time_t snapshot)
-{
- const char *fmt;
- struct tm snap_tm;
- fstring snaptime_string;
- size_t snaptime_len;
-
- fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
- "format", GMT_FORMAT);
-
- if (lp_parm_bool(SNUM(handle->conn), "shadow", "sscanf", false)) {
- snaptime_len = snprintf(snaptime_string, sizeof(snaptime_string), fmt,
- (unsigned long)snapshot);
- if (snaptime_len <= 0) {
- DEBUG(10, ("snprintf failed\n"));
- return NULL;
- }
- } else {
- if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", false)) {
- if (localtime_r(&snapshot, &snap_tm) == 0) {
- DEBUG(10, ("gmtime_r failed\n"));
- return NULL;
- }
- } else {
- if (gmtime_r(&snapshot, &snap_tm) == 0) {
- DEBUG(10, ("gmtime_r failed\n"));
- return NULL;
- }
- }
- snaptime_len = strftime(snaptime_string, sizeof(snaptime_string), fmt,
- &snap_tm);
- if (snaptime_len == 0) {
- DEBUG(10, ("strftime failed\n"));
- return NULL;
- }
- }
- return talloc_asprintf(mem_ctx, "/%s/%s",
- lp_parm_const_string(
- SNUM(handle->conn), "shadow", "snapdir",
- ".snapshots"),
- snaptime_string);
-}
+#define GMT_NAME_LEN 24 /* length of a @GMT- name */
+#define GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S"
static char *have_snapdir(struct vfs_handle_struct *handle,
const char *path)
return 0;
}
+static NTSTATUS shadow_copy2_snap_dir_expand(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ time_t tstamp,
+ char **snap_dir_out)
+{
+ const char *fmt;
+ struct tm snap_tm;
+ fstring snaptime_string;
+ size_t snaptime_len;
+ char *snap_dir;
+
+ fmt = lp_parm_const_string(SNUM(handle->conn), "shadow",
+ "format", GMT_FORMAT);
+
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "sscanf", false)) {
+ snaptime_len = snprintf(snaptime_string, sizeof(snaptime_string), fmt,
+ (unsigned long)tstamp);
+ if (snaptime_len <= 0) {
+ DEBUG(10, ("snprintf failed\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ } else {
+ if (lp_parm_bool(SNUM(handle->conn), "shadow", "localtime", false)) {
+ if (localtime_r(&tstamp, &snap_tm) == 0) {
+ DEBUG(10, ("gmtime_r failed\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ } else {
+ if (gmtime_r(&tstamp, &snap_tm) == 0) {
+ DEBUG(10, ("gmtime_r failed\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+ snaptime_len = strftime(snaptime_string, sizeof(snaptime_string), fmt,
+ &snap_tm);
+ if (snaptime_len == 0) {
+ DEBUG(10, ("strftime failed\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+ snap_dir = talloc_asprintf(mem_ctx, "/%s/%s",
+ lp_parm_const_string(SNUM(handle->conn),
+ "shadow", "snapdir",
+ ".snapshots"),
+ snaptime_string);
+ if (snap_dir == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ *snap_dir_out = snap_dir;
+
+ return NT_STATUS_OK;
+}
+
static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
.get_shadow_copy_data_fn = shadow_copy2_get_shadow_copy_data,
- .opendir_fn = gmt_tok_opendir,
- .rename_fn = gmt_tok_rename,
- .link_fn = gmt_tok_link,
- .symlink_fn = gmt_tok_symlink,
- .stat_fn = gmt_tok_stat,
- .lstat_fn = gmt_tok_lstat,
- .fstat_fn = gmt_tok_fstat,
- .open_fn = gmt_tok_open,
- .unlink_fn = gmt_tok_unlink,
- .chmod_fn = gmt_tok_chmod,
- .chown_fn = gmt_tok_chown,
- .chdir_fn = gmt_tok_chdir,
- .ntimes_fn = gmt_tok_ntimes,
- .readlink_fn = gmt_tok_readlink,
- .mknod_fn = gmt_tok_mknod,
- .realpath_fn = gmt_tok_realpath,
- .get_nt_acl_fn = gmt_tok_get_nt_acl,
- .fget_nt_acl_fn = gmt_tok_fget_nt_acl,
- .mkdir_fn = gmt_tok_mkdir,
- .rmdir_fn = gmt_tok_rmdir,
- .getxattr_fn = gmt_tok_getxattr,
- .listxattr_fn = gmt_tok_listxattr,
- .removexattr_fn = gmt_tok_removexattr,
- .setxattr_fn = gmt_tok_setxattr,
- .chmod_acl_fn = gmt_tok_chmod_acl,
- .chflags_fn = gmt_tok_chflags,
- .get_real_filename_fn = gmt_tok_get_real_filename,
+ .snap_dir_expand_fn = shadow_copy2_snap_dir_expand,
};
NTSTATUS vfs_shadow_copy2_init(void);
return handle->fns->snap_delete_recv_fn(handle, req);
}
+NTSTATUS smb_vfs_call_snap_dir_expand(struct vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ time_t tstamp,
+ char **snap_dir_out)
+{
+ VFS_FIND(snap_dir_expand);
+ return handle->fns->snap_dir_expand_fn(handle, mem_ctx, tstamp,
+ snap_dir_out);
+}
+
NTSTATUS smb_vfs_call_fget_nt_acl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32 security_info,
default_shared_modules.extend(TO_LIST('''vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk
vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap
- vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2
+ vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 vfs_gmt_token
auth_script vfs_readahead vfs_xattr_tdb vfs_posix_eadb
vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb
vfs_smb_traffic_analyzer vfs_preopen vfs_catia vfs_scannedonly