mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
smbd: Pass vfs_open_how through non_widelink_open
process_symlink_open goes with it Pair-programmed-with: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
5fc016f268
commit
ccc26364a9
@ -493,8 +493,7 @@ static NTSTATUS link_errno_convert(int err)
|
|||||||
static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
||||||
files_struct *fsp,
|
files_struct *fsp,
|
||||||
struct smb_filename *smb_fname,
|
struct smb_filename *smb_fname,
|
||||||
int flags,
|
const struct vfs_open_how *how,
|
||||||
mode_t mode,
|
|
||||||
unsigned int link_depth);
|
unsigned int link_depth);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -504,8 +503,7 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
|||||||
static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
|
static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
|
||||||
files_struct *fsp,
|
files_struct *fsp,
|
||||||
struct smb_filename *smb_fname,
|
struct smb_filename *smb_fname,
|
||||||
int flags,
|
const struct vfs_open_how *how,
|
||||||
mode_t mode,
|
|
||||||
unsigned int link_depth)
|
unsigned int link_depth)
|
||||||
{
|
{
|
||||||
struct connection_struct *conn = dirfsp->conn;
|
struct connection_struct *conn = dirfsp->conn;
|
||||||
@ -645,8 +643,7 @@ static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
|
|||||||
status = non_widelink_open(conn->cwd_fsp,
|
status = non_widelink_open(conn->cwd_fsp,
|
||||||
fsp,
|
fsp,
|
||||||
smb_fname,
|
smb_fname,
|
||||||
flags,
|
how,
|
||||||
mode,
|
|
||||||
link_depth);
|
link_depth);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
@ -672,8 +669,7 @@ static NTSTATUS process_symlink_open(const struct files_struct *dirfsp,
|
|||||||
static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
||||||
files_struct *fsp,
|
files_struct *fsp,
|
||||||
struct smb_filename *smb_fname,
|
struct smb_filename *smb_fname,
|
||||||
int flags,
|
const struct vfs_open_how *_how,
|
||||||
mode_t mode,
|
|
||||||
unsigned int link_depth)
|
unsigned int link_depth)
|
||||||
{
|
{
|
||||||
struct connection_struct *conn = fsp->conn;
|
struct connection_struct *conn = fsp->conn;
|
||||||
@ -686,7 +682,7 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
|||||||
struct smb_filename *parent_dir_fname = NULL;
|
struct smb_filename *parent_dir_fname = NULL;
|
||||||
bool have_opath = false;
|
bool have_opath = false;
|
||||||
bool is_share_root = false;
|
bool is_share_root = false;
|
||||||
struct vfs_open_how how = { .flags = flags, .mode = mode };
|
struct vfs_open_how how = *_how;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef O_PATH
|
#ifdef O_PATH
|
||||||
@ -860,8 +856,7 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
|||||||
status = process_symlink_open(dirfsp,
|
status = process_symlink_open(dirfsp,
|
||||||
fsp,
|
fsp,
|
||||||
smb_fname_rel,
|
smb_fname_rel,
|
||||||
flags,
|
&how,
|
||||||
mode,
|
|
||||||
link_depth);
|
link_depth);
|
||||||
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
|
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
|
||||||
NT_STATUS_EQUAL(saved_status, NT_STATUS_NOT_A_DIRECTORY))
|
NT_STATUS_EQUAL(saved_status, NT_STATUS_NOT_A_DIRECTORY))
|
||||||
@ -892,9 +887,10 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp,
|
|||||||
NTSTATUS fd_openat(const struct files_struct *dirfsp,
|
NTSTATUS fd_openat(const struct files_struct *dirfsp,
|
||||||
struct smb_filename *smb_fname,
|
struct smb_filename *smb_fname,
|
||||||
files_struct *fsp,
|
files_struct *fsp,
|
||||||
int flags,
|
int _flags,
|
||||||
mode_t mode)
|
mode_t _mode)
|
||||||
{
|
{
|
||||||
|
struct vfs_open_how how = { .flags = _flags, .mode = _mode, };
|
||||||
struct connection_struct *conn = fsp->conn;
|
struct connection_struct *conn = fsp->conn;
|
||||||
NTSTATUS status = NT_STATUS_OK;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
bool fsp_is_stream = fsp_is_alternate_stream(fsp);
|
bool fsp_is_stream = fsp_is_alternate_stream(fsp);
|
||||||
@ -908,11 +904,10 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) || !lp_follow_symlinks(SNUM(conn))) {
|
if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) || !lp_follow_symlinks(SNUM(conn))) {
|
||||||
flags |= O_NOFOLLOW;
|
how.flags |= O_NOFOLLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsp_is_stream) {
|
if (fsp_is_stream) {
|
||||||
struct vfs_open_how how = { .flags = flags, .mode = mode, };
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = SMB_VFS_OPENAT(
|
fd = SMB_VFS_OPENAT(
|
||||||
@ -942,7 +937,7 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
|
|||||||
* Only follow symlinks within a share
|
* Only follow symlinks within a share
|
||||||
* definition.
|
* definition.
|
||||||
*/
|
*/
|
||||||
status = non_widelink_open(dirfsp, fsp, smb_fname, flags, mode, 0);
|
status = non_widelink_open(dirfsp, fsp, smb_fname, &how, 0);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
if (NT_STATUS_EQUAL(status, NT_STATUS_TOO_MANY_OPENED_FILES)) {
|
if (NT_STATUS_EQUAL(status, NT_STATUS_TOO_MANY_OPENED_FILES)) {
|
||||||
static time_t last_warned = 0L;
|
static time_t last_warned = 0L;
|
||||||
@ -957,13 +952,18 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d. %s\n",
|
DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d. %s\n",
|
||||||
smb_fname_str_dbg(smb_fname), flags, (int)mode,
|
smb_fname_str_dbg(smb_fname),
|
||||||
fsp_get_pathref_fd(fsp), nt_errstr(status));
|
how.flags,
|
||||||
|
(int)how.mode,
|
||||||
|
fsp_get_pathref_fd(fsp),
|
||||||
|
nt_errstr(status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d\n",
|
DBG_DEBUG("name %s, flags = 0%o mode = 0%o, fd = %d\n",
|
||||||
smb_fname_str_dbg(smb_fname), flags, (int)mode,
|
smb_fname_str_dbg(smb_fname),
|
||||||
|
how.flags,
|
||||||
|
(int)how.mode,
|
||||||
fsp_get_pathref_fd(fsp));
|
fsp_get_pathref_fd(fsp));
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
Loading…
Reference in New Issue
Block a user