s3: smbd: Always use ucf_flags_from_smb_request() in place of checking by hand (in...
authorJeremy Allison <jra@samba.org>
Thu, 18 May 2017 19:08:00 +0000 (12:08 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 22 May 2017 16:41:15 +0000 (18:41 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/reply.c
source3/smbd/trans2.c

index a5fc62536e796843819a2b1b165e1d00c363c13d..55e08146a57ba70826326644765bf434766880bb 100644 (file)
@@ -1573,8 +1573,8 @@ void reply_ntrename(struct smb_request *req)
        bool src_has_wcard = False;
        bool dest_has_wcard = False;
        uint32_t attrs;
-       uint32_t ucf_flags_src = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
-       uint32_t ucf_flags_dst = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags_src = ucf_flags_from_smb_request(req);
+       uint32_t ucf_flags_dst = ucf_flags_from_smb_request(req);
        uint16_t rename_type;
        TALLOC_CTX *ctx = talloc_tos();
        bool stream_rename = false;
index 50f8a5ea216620d6b6cb838b6791f22c5c09fc76..c484f5177f7bc0b7783980f09d772a91f97b4ed2 100644 (file)
@@ -5366,8 +5366,7 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn,
        files_struct *dir_fsp;
        char *parent_fname = NULL;
        char *new_base_name = NULL;
-       uint32_t ucf_flags = ((req != NULL && req->posix_pathnames) ?
-                       UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        NTSTATUS status;
 
        if (root_dir_fid == 0 || !smb_fname) {
index 030f011157602bdbc8e7f21dc59d3be6fa17813b..c6b5b6201792624b98cc7cb3b0ea7535ffc41928 100644 (file)
@@ -1278,7 +1278,7 @@ void reply_checkpath(struct smb_request *req)
        struct smb_filename *smb_fname = NULL;
        char *name = NULL;
        NTSTATUS status;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBcheckpath);
@@ -1393,8 +1393,7 @@ void reply_getatr(struct smb_request *req)
                size = 0;
                mtime = 0;
        } else {
-               uint32_t ucf_flags = (req->posix_pathnames ?
-                               UCF_POSIX_PATHNAMES : 0);
+               uint32_t ucf_flags = ucf_flags_from_smb_request(req);
                status = filename_convert(ctx,
                                conn,
                                req->flags2 & FLAGS2_DFS_PATHNAMES,
@@ -1480,7 +1479,7 @@ void reply_setatr(struct smb_request *req)
        time_t mtime;
        const char *p;
        NTSTATUS status;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBsetatr);
@@ -1798,7 +1797,7 @@ void reply_search(struct smb_request *req)
        if (status_len == 0) {
                struct smb_filename *smb_dname = NULL;
                uint32_t ucf_flags = UCF_ALWAYS_ALLOW_WCARD_LCOMP |
-                       (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+                       ucf_flags_from_smb_request(req);
                nt_status = filename_convert(ctx, conn,
                                             req->flags2 & FLAGS2_DFS_PATHNAMES,
                                             path,
@@ -3220,7 +3219,7 @@ void reply_unlink(struct smb_request *req)
        NTSTATUS status;
        bool path_contains_wcard = False;
        uint32_t ucf_flags = UCF_COND_ALLOW_WCARD_LCOMP |
-                       (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+                       ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBunlink);
@@ -6210,7 +6209,7 @@ void reply_rmdir(struct smb_request *req)
        TALLOC_CTX *ctx = talloc_tos();
        files_struct *fsp = NULL;
        int info = 0;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        struct smbd_server_connection *sconn = req->sconn;
 
        START_PROFILE(SMBrmdir);
@@ -7294,12 +7293,15 @@ void reply_mv(struct smb_request *req)
        TALLOC_CTX *ctx = talloc_tos();
        struct smb_filename *smb_fname_src = NULL;
        struct smb_filename *smb_fname_dst = NULL;
-       uint32_t src_ucf_flags = (req->posix_pathnames ?
-               (UCF_UNIX_NAME_LOOKUP|UCF_POSIX_PATHNAMES) :
-               UCF_COND_ALLOW_WCARD_LCOMP);
-       uint32_t dst_ucf_flags = UCF_SAVE_LCOMP |
-               (req->posix_pathnames ? UCF_POSIX_PATHNAMES :
-                UCF_COND_ALLOW_WCARD_LCOMP);
+       uint32_t src_ucf_flags = ucf_flags_from_smb_request(req) |
+               (req->posix_pathnames ?
+                       UCF_UNIX_NAME_LOOKUP :
+                       UCF_COND_ALLOW_WCARD_LCOMP);
+       uint32_t dst_ucf_flags = ucf_flags_from_smb_request(req) |
+               UCF_SAVE_LCOMP |
+               (req->posix_pathnames ?
+                       0 :
+                       UCF_COND_ALLOW_WCARD_LCOMP);
        bool stream_rename = false;
 
        START_PROFILE(SMBmv);
@@ -7612,9 +7614,9 @@ void reply_copy(struct smb_request *req)
        bool dest_has_wild = False;
        NTSTATUS status;
        uint32_t ucf_flags_src = UCF_COND_ALLOW_WCARD_LCOMP |
-               (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+               ucf_flags_from_smb_request(req);
        uint32_t ucf_flags_dst = UCF_COND_ALLOW_WCARD_LCOMP |
-               (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+               ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBcopy);
index 14f605210999f3886850abfd788db4db4bcc91e6..9f8689290c1cb167cc1717ae3850ad46f9860838 100644 (file)
@@ -1225,7 +1225,7 @@ static void call_trans2open(connection_struct *conn,
        uint32_t create_disposition;
        uint32_t create_options = 0;
        uint32_t private_flags = 0;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        /*
@@ -2637,7 +2637,7 @@ static void call_trans2findfirst(connection_struct *conn,
        struct dptr_struct *dirptr = NULL;
        struct smbd_server_connection *sconn = req->sconn;
        uint32_t ucf_flags = UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP |
-                       (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+                       ucf_flags_from_smb_request(req);
        bool backup_priv = false;
        bool as_root = false;
 
@@ -5800,8 +5800,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
        } else {
                uint32_t name_hash;
                char *fname = NULL;
-               uint32_t ucf_flags = (req->posix_pathnames ?
-                               UCF_POSIX_PATHNAMES : 0);
+               uint32_t ucf_flags = ucf_flags_from_smb_request(req);
 
                /* qpathinfo */
                if (total_params < 7) {
@@ -6654,7 +6653,7 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
 {
        char *oldname = NULL;
        struct smb_filename *smb_fname_old = NULL;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
        NTSTATUS status = NT_STATUS_OK;
 
@@ -6720,7 +6719,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        char *newname = NULL;
        struct smb_filename *smb_fname_dst = NULL;
        uint32_t ucf_flags = UCF_SAVE_LCOMP |
-               (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+               ucf_flags_from_smb_request(req);
        NTSTATUS status = NT_STATUS_OK;
        TALLOC_CTX *ctx = talloc_tos();
 
@@ -6832,7 +6831,7 @@ static NTSTATUS smb_file_link_information(connection_struct *conn,
        struct smb_filename *smb_fname_dst = NULL;
        NTSTATUS status = NT_STATUS_OK;
        uint32_t ucf_flags = UCF_SAVE_LCOMP |
-               (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+               ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (!fsp) {
@@ -8790,8 +8789,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                }
        } else {
                char *fname = NULL;
-               uint32_t ucf_flags = (req->posix_pathnames ?
-                       UCF_POSIX_PATHNAMES : 0);
+               uint32_t ucf_flags = ucf_flags_from_smb_request(req);
 
                /* set path info */
                if (total_params < 7) {
@@ -8941,7 +8939,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
        char *directory = NULL;
        NTSTATUS status = NT_STATUS_OK;
        struct ea_list *ea_list = NULL;
-       uint32_t ucf_flags = (req->posix_pathnames ? UCF_POSIX_PATHNAMES : 0);
+       uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        TALLOC_CTX *ctx = talloc_tos();
 
        if (!CAN_WRITE(conn)) {