s3: smbd: filenames - ensure we replace the missing '/' if we error in an intermediat...
authorJeremy Allison <jra@samba.org>
Sun, 24 Feb 2019 16:15:23 +0000 (08:15 -0800)
committerKarolin Seeger <kseeger@samba.org>
Tue, 5 Mar 2019 07:39:29 +0000 (07:39 +0000)
Previous regression test ensures we still return the correct
error code for POSIX pathname operations.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Feb 25 09:33:27 CET 2019 on sn-devel-144

(cherry picked from commit 3f1a13a94a753c5cb3b9f2cf795df5adb0f74205)

selftest/knownfail
source3/smbd/filename.c

index f4427fb4ab4d4b1b7e7207599f4cb5d82c09e6ef..84776d4f35d0a6642edd54da587b76ee8f156b38 100644 (file)
@@ -9,7 +9,6 @@
  ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-REAUTH # expected to give ACCESS_DENIED SMB2.1 doesn't have encryption
 ^samba3.smbtorture_s3.crypt_server\(nt4_dc\).SMB2-SESSION-RECONNECT # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.smbtorture_s3.*ad_dc_ntvfs.*SMB2-DIR-FSYNC.*
-^samba3.smbtorture_s3.*.POSIX-MKDIR
 ^samba3.smb2.session enc.reconnect # expected to give CONNECTION_DISCONNECTED, we need to fix the test
 ^samba3.raw.session enc # expected to give ACCESS_DENIED as SMB1 encryption isn't used
 ^samba3.smbtorture_s3.crypt_server # expected to give ACCESS_DENIED as SMB1 encryption isn't used
index 4c8c5ea19bc8b008f28ff6c0a6ea5c16ccc36c30..8a00fbb06e7850ebab999b182e3fbbd3889df85e 100644 (file)
@@ -917,6 +917,24 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                                 *
                                 * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
                                 */
+                               if (end != NULL) {
+                                       const char *morepath = NULL;
+                                       /*
+                                        * If this is intermediate we must
+                                        * restore the full path.
+                                        */
+                                       *end = '/';
+                                       /*
+                                        * If there are any more components
+                                        * after the failed LSTAT we cannot
+                                        * continue.
+                                        */
+                                       morepath = strchr(end + 1, '/');
+                                       if (morepath != NULL) {
+                                               status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+                                               goto fail;
+                                       }
+                               }
                                if (errno == ENOENT) {
                                        /* New file or directory. */
                                        goto done;