static int atalk_rename(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *oldname, const char *newname) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname); if (!conn || !oldname) return ret; if (!(ctx = talloc_init("rename_file"))) return ret; if (atalk_build_paths(ctx, conn->origpath, oldname, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) return ret; if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); goto exit_rename; } atalk_unlink_file(adbl_path); exit_rename: talloc_destroy(ctx); return ret; }
static int atalk_chown(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, uid_t uid, gid_t gid) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_CHOWN(handle, conn, path, uid, gid); if (!conn || !path) return ret; if (!(ctx = talloc_init("chown_file"))) return ret; if (atalk_build_paths(ctx, conn->origpath, path, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) return ret; if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", orig_path)); goto exit_chown; } chown(adbl_path, uid, gid); exit_chown: talloc_destroy(ctx); return ret; }
static int atalk_lchown(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, uid_t uid, gid_t gid) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid); if (!(ctx = talloc_init("lchown_file"))) return ret; if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) goto exit_lchown; if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", orig_path)); goto exit_lchown; } if (lchown(adbl_path, uid, gid) == -1) { DEBUG(3, ("ATALK: lchown error %s\n", strerror(errno))); } exit_lchown: talloc_destroy(ctx); return ret; }
static int atalk_unlink(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { int ret = 0, i; char *path = NULL; char *adbl_path = NULL; char *orig_path = NULL; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; NTSTATUS status; ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname); status = get_full_smb_filename(talloc_tos(), smb_fname, &path); if (!NT_STATUS_IS_OK(status)) { return ret; } /* no .AppleDouble sync if veto or hide list is empty, * otherwise "Cannot find the specified file" error will be caused */ if (!handle->conn->veto_list) return ret; if (!handle->conn->hide_list) return ret; for (i = 0; handle->conn->veto_list[i].name; i ++) { if (strstr_m(handle->conn->veto_list[i].name, APPLEDOUBLE)) break; } if (!handle->conn->veto_list[i].name) { for (i = 0; handle->conn->hide_list[i].name; i ++) { if (strstr_m(handle->conn->hide_list[i].name, APPLEDOUBLE)) break; else { DEBUG(3, ("ATALK: %s is not hidden, skipped..\n", APPLEDOUBLE)); goto exit_unlink; } } } if (atalk_build_paths(talloc_tos(), handle->conn->cwd, path, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) goto exit_unlink; if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); goto exit_unlink; } atalk_unlink_file(adbl_path); exit_unlink: TALLOC_FREE(path); TALLOC_FREE(adbl_path); TALLOC_FREE(orig_path); return ret; }
static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_t mode) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_CHMOD(handle, path, mode); if (!path) return ret; if (!(ctx = talloc_init("chmod_file"))) return ret; if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path, &orig_path, &adbl_info, &orig_info, false) != 0) goto exit_chmod; if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", orig_path)); goto exit_chmod; } chmod(adbl_path, ADOUBLEMODE); exit_chmod: talloc_destroy(ctx); return ret; }
static int atalk_unlink(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) { int ret = 0, i; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_UNLINK(handle, conn, path); if (!conn || !path) return ret; /* no .AppleDouble sync if veto or hide list is empty, * otherwise "Cannot find the specified file" error will be caused */ if (!conn->veto_list) return ret; if (!conn->hide_list) return ret; for (i = 0; conn->veto_list[i].name; i ++) { if (strstr(conn->veto_list[i].name, APPLEDOUBLE)) break; } if (!conn->veto_list[i].name) { for (i = 0; conn->hide_list[i].name; i ++) { if (strstr(conn->hide_list[i].name, APPLEDOUBLE)) break; else { DEBUG(3, ("ATALK: %s is not hidden, skipped..\n", APPLEDOUBLE)); return ret; } } } if (!(ctx = talloc_init("unlink_file"))) return ret; if (atalk_build_paths(ctx, conn->origpath, path, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) return ret; if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); goto exit_unlink; } atalk_unlink_file(adbl_path); exit_unlink: talloc_destroy(ctx); return ret; }
static int atalk_rename(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_dst) { int ret = 0; char *oldname = NULL; char *adbl_path = NULL; char *orig_path = NULL; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; NTSTATUS status; ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); status = get_full_smb_filename(talloc_tos(), smb_fname_src, &oldname); if (!NT_STATUS_IS_OK(status)) { return ret; } if (atalk_build_paths(talloc_tos(), handle->conn->cwd, oldname, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) goto exit_rename; if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); goto exit_rename; } atalk_unlink_file(adbl_path); exit_rename: TALLOC_FREE(oldname); TALLOC_FREE(adbl_path); TALLOC_FREE(orig_path); return ret; }