The Samba-Bugzilla – Attachment 10955 Details for
Bug 11216
Samba calls SMB_VFS_STAT with an absolute path during TreeConnect processing but a relative path everywhere else
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
git-am fix for master.
bug-11216.patch (text/plain), 5.92 KB, created by
Jeremy Allison
on 2015-04-14 19:46:22 UTC
(
hide
)
Description:
git-am fix for master.
Filename:
MIME Type:
Creator:
Jeremy Allison
Created:
2015-04-14 19:46:22 UTC
Size:
5.92 KB
patch
obsolete
>From 62d3818959478dc4b305c22d8e89895f4782568a Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Tue, 14 Apr 2015 11:57:35 -0700 >Subject: [PATCH 1/2] smbd: VFS: Ensure all uses of SMB_VFS_STAT use relative > paths. > >Makes usage consistent for VFS developers. Do a CHDIR followed >by a STAT(".") as root in make_connection(), instead of a STAT >on an absolute path. Change in behavior is to ensure we chdir("/") >on exit of this function, but as we're guarenteed to exit as >root, this is the correct thing to do anyway. > >NB. This doesn't change behavior when re-exporting NFS shares, >as the STAT as root would have failed anyway, with the same >error as the CHDIR. > >Fixes bug #11216 - Samba calls SMB_VFS_STAT with an absolute path > during TreeConnect processing but a relative path > everywhere else. > >https://bugzilla.samba.org/show_bug.cgi?id=11216 > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > source3/smbd/service.c | 36 ++++++++++++++++++++++++++---------- > 1 file changed, 26 insertions(+), 10 deletions(-) > >diff --git a/source3/smbd/service.c b/source3/smbd/service.c >index ada2d07..5b42959 100644 >--- a/source3/smbd/service.c >+++ b/source3/smbd/service.c >@@ -773,7 +773,7 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > > /* > * we've finished with the user stuff - go back to root >- * so the SMB_VFS_STAT call will only fail on path errors, >+ * so the SMB_VFS_CHDIR call will only fail on path errors, > * not permission problems. > */ > change_to_root_user(); >@@ -808,22 +808,29 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > set_namearray( &conn->aio_write_behind_list, > lp_aio_write_behind(talloc_tos(), snum)); > } >- smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath, >+ smb_fname_cpath = synthetic_smb_fname(talloc_tos(), ".", > NULL, NULL); > if (smb_fname_cpath == NULL) { > status = NT_STATUS_NO_MEMORY; > goto err_root_exit; > } > >- /* win2000 does not check the permissions on the directory >- during the tree connect, instead relying on permission >- check during individual operations. To match this behaviour >- I have disabled this chdir check (tridge) */ >- /* the alternative is just to check the directory exists */ >+ /* >+ * We're running as root, so just try and SMB_VFS_CHDIR >+ * into the directory. This and realpath are the only >+ * VFS calls that should have to cope with absolute >+ * paths that might start outside the exported share >+ * directory. Then do a STAT on "." to get the share dev_t >+ * value. >+ */ >+ >+ ret = SMB_VFS_CHDIR(conn, conn->connectpath); >+ if (ret == 0) { >+ ret = SMB_VFS_STAT(conn, smb_fname_cpath); >+ } > >- if ((ret = SMB_VFS_STAT(conn, smb_fname_cpath)) != 0 || >- !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) { >- if (ret == 0 && !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) { >+ if (ret != 0) { >+ if (errno == ENOTDIR) { > DEBUG(0,("'%s' is not a directory, when connecting to " > "[%s]\n", conn->connectpath, > lp_servicename(talloc_tos(), snum))); >@@ -868,6 +875,11 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > dbgtext( "(pid %d)\n", (int)getpid() ); > } > >+ /* We're exiting as root - ensure we're in / */ >+ if (chdir("/") != 0) { >+ smb_panic("Failed to chdir(/)."); >+ } >+ > return status; > > err_root_exit: >@@ -881,6 +893,10 @@ static NTSTATUS make_connection_snum(struct smbXsrv_connection *xconn, > /* Call VFS disconnect hook */ > SMB_VFS_DISCONNECT(conn); > } >+ /* We're exiting as root - ensure we're in / */ >+ if (chdir("/") != 0) { >+ smb_panic("Failed to chdir(/)."); >+ } > return status; > } > >-- >2.2.0.rc0.207.ga3a616c > > >From 6955407d00ac76e5fe2c617b05667b69de52c6e2 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Tue, 14 Apr 2015 12:38:54 -0700 >Subject: [PATCH 2/2] smbd: VFS: Ensure all uses of SMB_VFS_STAT use relative > paths. > >Makes usage consistent for VFS developers. Fix use in capabilities >fetch. > >Fixes bug #11216 - Samba calls SMB_VFS_STAT with an absolute path > during TreeConnect processing but a relative path > everywhere else. > >https://bugzilla.samba.org/show_bug.cgi?id=11216 > >Signed-off-by: Jeremy Allison <jra@samba.org> >--- > source3/modules/vfs_default.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > >diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c >index dbcd601..34ce479 100644 >--- a/source3/modules/vfs_default.c >+++ b/source3/modules/vfs_default.c >@@ -116,6 +116,18 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, > struct smb_filename *smb_fname_cpath = NULL; > struct vfs_statvfs_struct statbuf; > int ret; >+ char *saved_dir = vfs_GetWd(talloc_tos(), conn); >+ >+ if (saved_dir == NULL) { >+ return caps; >+ } >+ >+ if (vfs_ChDir(conn,conn->connectpath) != 0) { >+ DEBUG(3,("Can't ChDir to path %s. " >+ "Error was %s\n", >+ conn->connectpath, strerror(errno) )); >+ goto out; >+ } > > ZERO_STRUCT(statbuf); > ret = sys_statvfs(conn->connectpath, &statbuf); >@@ -128,16 +140,15 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, > /* Work out what timestamp resolution we can > * use when setting a timestamp. */ > >- smb_fname_cpath = synthetic_smb_fname(talloc_tos(), conn->connectpath, >+ smb_fname_cpath = synthetic_smb_fname(talloc_tos(), ".", > NULL, NULL); > if (smb_fname_cpath == NULL) { >- return caps; >+ goto out; > } > > ret = SMB_VFS_STAT(conn, smb_fname_cpath); > if (ret == -1) { >- TALLOC_FREE(smb_fname_cpath); >- return caps; >+ goto out; > } > > if (smb_fname_cpath->st.st_ex_mtime.tv_nsec || >@@ -165,6 +176,13 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, > lp_servicename(talloc_tos(), conn->params->service), > conn->connectpath )); > } >+ >+ out: >+ >+ if (vfs_ChDir(conn,saved_dir) != 0) { >+ smb_panic("can't return to original directory"); >+ } >+ TALLOC_FREE(saved_dir); > TALLOC_FREE(smb_fname_cpath); > return caps; > } >-- >2.2.0.rc0.207.ga3a616c >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
jra
:
review?
Actions:
View
Attachments on
bug 11216
:
10954
| 10955