s3: smbd: Fix "follow symlink = no" regression part 2.
authorJeremy Allison <jra@samba.org>
Tue, 28 Mar 2017 00:04:58 +0000 (17:04 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 28 Mar 2017 11:20:26 +0000 (13:20 +0200)
Add an extra paramter to cwd_name to check_reduced_name().

If cwd_name == NULL then fname is a client given path relative
to the root path of the share.

If cwd_name != NULL then fname is a client given path relative
to cwd_name. cwd_name is relative to the root path of the share.

Not yet used, logic added in the next commit.

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/filename.c
source3/smbd/open.c
source3/smbd/proto.h
source3/smbd/vfs.c

index efe52a0432877d5052645a5e24322e4e5c73019e..2d85e8de0b550df4483bee384eabd20d0aa49aad 100644 (file)
@@ -1242,7 +1242,7 @@ NTSTATUS check_name(connection_struct *conn, const char *name)
        }
 
        if (!lp_widelinks(SNUM(conn)) || !lp_follow_symlinks(SNUM(conn))) {
-               status = check_reduced_name(conn,name);
+               status = check_reduced_name(conn, NULL, name);
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(5,("check_name: name %s failed with %s\n",name,
                                                nt_errstr(status)));
index a6e61e70f7fba2e3b50b33ea9092ca60d34413a8..50f8a5ea216620d6b6cb838b6791f22c5c09fc76 100644 (file)
@@ -558,7 +558,7 @@ static int non_widelink_open(struct connection_struct *conn,
        }
 
        /* Ensure the relative path is below the share. */
-       status = check_reduced_name(conn, final_component);
+       status = check_reduced_name(conn, parent_dir, final_component);
        if (!NT_STATUS_IS_OK(status)) {
                saved_errno = map_errno_from_nt_status(status);
                goto out;
index 2e8df297782775ed0c5a3fc90a61623fe23f0b9f..841a095f56104c49d22bd868ca85703c1ee840bb 100644 (file)
@@ -1226,7 +1226,9 @@ const char *vfs_readdirname(connection_struct *conn, void *p,
                            SMB_STRUCT_STAT *sbuf, char **talloced);
 int vfs_ChDir(connection_struct *conn, const char *path);
 char *vfs_GetWd(TALLOC_CTX *ctx, connection_struct *conn);
-NTSTATUS check_reduced_name(connection_struct *conn, const char *fname);
+NTSTATUS check_reduced_name(connection_struct *conn,
+                       const char *cwd_name,
+                       const char *fname);
 NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
                        const char *fname,
                        struct smb_request *smbreq);
index 5133fe5c2fd697de3f8f2c40619f304be0a9390c..95a8fc1ba62ff534af7cbf2eb4c71e7b974d39a0 100644 (file)
@@ -1179,9 +1179,17 @@ NTSTATUS check_reduced_name_with_privilege(connection_struct *conn,
 /*******************************************************************
  Reduce a file name, removing .. elements and checking that
  it is below dir in the heirachy. This uses realpath.
+
+ If cwd_name == NULL then fname is a client given path relative
+ to the root path of the share.
+
+ If cwd_name != NULL then fname is a client given path relative
+ to cwd_name. cwd_name is relative to the root path of the share.
 ********************************************************************/
 
-NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
+NTSTATUS check_reduced_name(connection_struct *conn,
+                               const char *cwd_name,
+                               const char *fname)
 {
        char *resolved_name = NULL;
        bool allow_symlinks = true;