diff options
author | Jeremy Allison <jra@samba.org> | 2019-10-08 13:46:02 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-10-15 18:46:37 +0000 |
commit | 99bfdb6e81925760af2a6e89fc6ac55768c88b78 (patch) | |
tree | eb36a448383e37cf6ee5103314beef86c87d2f08 /source3/smbd | |
parent | 2dbc68e2c0212e3e14f304e359d4d0b1ab514ce2 (diff) | |
download | samba-99bfdb6e81925760af2a6e89fc6ac55768c88b78.tar.gz |
s3: smbd: Remove vfs_chown_fsp().
No longer used. This gets rid of another case
where we were playing directory changing games
that are eliminated by just using a file handle.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/proto.h | 1 | ||||
-rw-r--r-- | source3/smbd/vfs.c | 121 |
2 files changed, 0 insertions, 122 deletions
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index e9d04474df6..dd6993a60f0 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1247,7 +1247,6 @@ int vfs_stat_smb_basename(struct connection_struct *conn, const struct smb_filename *smb_fname_in, SMB_STRUCT_STAT *psbuf); NTSTATUS vfs_stat_fsp(files_struct *fsp); -NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid); NTSTATUS vfs_streaminfo(connection_struct *conn, struct files_struct *fsp, const struct smb_filename *smb_fname, diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 34923b62ab4..588580314e8 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -2050,127 +2050,6 @@ int smb_vfs_call_lchown(struct vfs_handle_struct *handle, return handle->fns->lchown_fn(handle, smb_fname, uid, gid); } -NTSTATUS vfs_chown_fsp(files_struct *fsp, uid_t uid, gid_t gid) -{ - int ret; - bool as_root = false; - NTSTATUS status; - - if (fsp->fh->fd != -1) { - /* Try fchown. */ - ret = SMB_VFS_FCHOWN(fsp, uid, gid); - if (ret == 0) { - return NT_STATUS_OK; - } - if (ret == -1 && errno != ENOSYS) { - return map_nt_error_from_unix(errno); - } - } - - as_root = (geteuid() == 0); - - if (as_root) { - /* - * We are being asked to chown as root. Make - * sure we chdir() into the path to pin it, - * and always act using lchown to ensure we - * don't deref any symbolic links. - */ - char *parent_dir = NULL; - const char *final_component = NULL; - struct smb_filename *local_smb_fname = NULL; - struct smb_filename parent_dir_fname = {0}; - struct smb_filename *saved_dir_fname = NULL; - - saved_dir_fname = vfs_GetWd(talloc_tos(),fsp->conn); - if (!saved_dir_fname) { - status = map_nt_error_from_unix(errno); - DEBUG(0,("vfs_chown_fsp: failed to get " - "current working directory. Error was %s\n", - strerror(errno))); - return status; - } - - if (!parent_dirname(talloc_tos(), - fsp->fsp_name->base_name, - &parent_dir, - &final_component)) { - return NT_STATUS_NO_MEMORY; - } - - parent_dir_fname = (struct smb_filename) { - .base_name = parent_dir, - .flags = fsp->fsp_name->flags - }; - - /* cd into the parent dir to pin it. */ - ret = vfs_ChDir(fsp->conn, &parent_dir_fname); - if (ret == -1) { - return map_nt_error_from_unix(errno); - } - - local_smb_fname = synthetic_smb_fname(talloc_tos(), - final_component, - NULL, - NULL, - fsp->fsp_name->flags); - if (local_smb_fname == NULL) { - status = NT_STATUS_NO_MEMORY; - goto out; - } - - /* Must use lstat here. */ - ret = SMB_VFS_LSTAT(fsp->conn, local_smb_fname); - if (ret == -1) { - status = map_nt_error_from_unix(errno); - goto out; - } - - /* Ensure it matches the fsp stat. */ - if (!check_same_stat(&local_smb_fname->st, - &fsp->fsp_name->st)) { - status = NT_STATUS_ACCESS_DENIED; - goto out; - } - - ret = SMB_VFS_LCHOWN(fsp->conn, - local_smb_fname, - uid, gid); - - if (ret == 0) { - status = NT_STATUS_OK; - } else { - status = map_nt_error_from_unix(errno); - } - - out: - - vfs_ChDir(fsp->conn, saved_dir_fname); - TALLOC_FREE(local_smb_fname); - TALLOC_FREE(saved_dir_fname); - TALLOC_FREE(parent_dir); - - return status; - } - - if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) { - ret = SMB_VFS_LCHOWN(fsp->conn, - fsp->fsp_name, - uid, gid); - } else { - ret = SMB_VFS_CHOWN(fsp->conn, - fsp->fsp_name, - uid, gid); - } - - if (ret == 0) { - status = NT_STATUS_OK; - } else { - status = map_nt_error_from_unix(errno); - } - return status; -} - int smb_vfs_call_chdir(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { |