The Samba-Bugzilla – Attachment 15864 Details for
Bug 14256
smbd does a chdir() twice per request
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.11 backported from master
bug14256-v411.patch (text/plain), 2.32 KB, created by
Ralph Böhme
on 2020-03-16 13:31:17 UTC
(
hide
)
Description:
Patch for 4.11 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2020-03-16 13:31:17 UTC
Size:
2.32 KB
patch
obsolete
>From 061f0b07a20159363b5c6e2aac7ee73ee5119338 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Wed, 22 Jan 2020 10:52:39 +0100 >Subject: [PATCH] smbd: avoid double chdir() in chdir_current_service() > >Since 8e81090789e4cc3ba9e5aa792d4e52971909c894 we're doing chdir() twice, first >into conn->connectpath, then into conn->origpath. > >Before commit 8e81090789e4cc3ba9e5aa792d4e52971909c894 if >chdir(conn->connectpath) succeeded, we wouldn't do the second chdir(). > >While at it, simplify the logging logic: if chdir() fails in this core function, >just always log is as error including the unix token. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14256 >RN: smbd does a chdir() twice per request > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> >Autobuild-Date(master): Thu Feb 6 11:44:07 UTC 2020 on sn-devel-184 > >(backported from commit f705629a171c1411131164f3adff36175154c093) >--- > source3/smbd/service.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > >diff --git a/source3/smbd/service.c b/source3/smbd/service.c >index fd23d1a2d60..a4f7f898526 100644 >--- a/source3/smbd/service.c >+++ b/source3/smbd/service.c >@@ -146,27 +146,30 @@ bool chdir_current_service(connection_struct *conn) > const struct smb_filename origpath_fname = { > .base_name = conn->origpath, > }; >+ int saved_errno = 0; > int ret; > > conn->lastused_count++; > > ret = vfs_ChDir(conn, &connectpath_fname); >- if (ret != 0) { >- DEBUG(((errno!=EACCES)?0:3), >- ("chdir (%s) failed, reason: %s\n", >- conn->connectpath, strerror(errno))); >- return false; >+ if (ret == 0) { >+ return true; > } >+ saved_errno = errno; >+ DEBUG(((errno!=EACCES)?0:3), >+ ("chdir (%s) failed, reason: %s\n", >+ conn->connectpath, strerror(errno))); > > ret = vfs_ChDir(conn, &origpath_fname); >- if (ret != 0) { >- DEBUG(((errno!=EACCES)?0:3), >- ("chdir (%s) failed, reason: %s\n", >- conn->origpath, strerror(errno))); >- return false; >+ if (ret == 0) { >+ return true; > } >+ DEBUG(((errno!=EACCES)?0:3), >+ ("chdir (%s) failed, reason: %s\n", >+ conn->origpath, strerror(errno))); > >- return true; >+ errno = saved_errno; >+ return false; > } > > /**************************************************************************** >-- >2.24.1 >
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 14256
:
15864
|
15865
|
15868