From f7b4151a64d8c6851e62255a7139fd00a5fc63a3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 21 Nov 2009 19:26:25 +0100 Subject: [PATCH] s3: Make the implicit reference to Protocol in is_in_path() explicit --- source3/include/proto.h | 3 ++- source3/include/smb_macros.h | 3 --- source3/lib/util.c | 5 +++-- source3/modules/onefs_open.c | 3 ++- source3/modules/vfs_preopen.c | 3 ++- source3/smbd/dir.c | 3 ++- source3/smbd/dosmode.c | 6 ++++-- source3/smbd/filename.c | 3 ++- source3/smbd/open.c | 5 +++-- source3/smbd/reply.c | 3 ++- 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index fa0a69ea587..0efd8f0e353 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1158,7 +1158,8 @@ gid_t nametogid(const char *name); void smb_panic(const char *const why); void log_stack_trace(void); const char *readdirname(SMB_STRUCT_DIR *p); -bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive); +bool is_in_path(const char *name, name_compare_entry *namelist, + enum protocol_types proto, bool case_sensitive); void set_namearray(name_compare_entry **ppname_array, const char *namelist); void free_namearray(name_compare_entry *name_array); bool fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 10ee78b3943..95f427c1e73 100644 --- a/source3/include/smb_macros.h +++ b/source3/include/smb_macros.h @@ -79,9 +79,6 @@ #define MAP_HIDDEN(conn) ((conn) && lp_map_hidden(SNUM(conn))) #define MAP_SYSTEM(conn) ((conn) && lp_map_system(SNUM(conn))) #define MAP_ARCHIVE(conn) ((conn) && lp_map_archive(SNUM(conn))) -#define IS_HIDDEN_PATH(conn,path) ((conn) && is_in_path((path),(conn)->hide_list,(conn)->case_sensitive)) -#define IS_VETO_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_list,(conn)->case_sensitive)) -#define IS_VETO_OPLOCK_PATH(conn,path) ((conn) && is_in_path((path),(conn)->veto_oplock_list,(conn)->case_sensitive)) /* * Used by the stat cache code to check if a returned diff --git a/source3/lib/util.c b/source3/lib/util.c index 1ee1bdc35fd..933b7876977 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1666,7 +1666,8 @@ const char *readdirname(SMB_STRUCT_DIR *p) of a path matches a (possibly wildcarded) entry in a namelist. ********************************************************************/ -bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensitive) +bool is_in_path(const char *name, name_compare_entry *namelist, + enum protocol_types proto, bool case_sensitive) { const char *last_component; @@ -1688,7 +1689,7 @@ bool is_in_path(const char *name, name_compare_entry *namelist, bool case_sensit for(; namelist->name != NULL; namelist++) { if(namelist->is_wild) { if (mask_match(last_component, namelist->name, - get_Protocol(), case_sensitive)) { + proto, case_sensitive)) { DEBUG(8,("is_in_path: mask match succeeded\n")); return True; } diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c index fd12fff58ca..0d786f15566 100644 --- a/source3/modules/onefs_open.c +++ b/source3/modules/onefs_open.c @@ -603,7 +603,8 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn, /* Ignore oplock requests if oplocks are disabled. */ if (!lp_oplocks(SNUM(conn)) || global_client_failed_oplock_break || - IS_VETO_OPLOCK_PATH(conn, smb_fname->base_name)) { + is_in_path(smb_fname->base_name, conn->veto_oplock_list, + get_Protocol(), conn->case_sensitive)) { /* Mask off everything except the private Samba bits. */ oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK; } diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c index e545901035b..d91a0312271 100644 --- a/source3/modules/vfs_preopen.c +++ b/source3/modules/vfs_preopen.c @@ -395,7 +395,8 @@ static int preopen_open(vfs_handle_struct *handle, return res; } - if (!is_in_path(smb_fname->base_name, state->preopen_names, true)) { + if (!is_in_path(smb_fname->base_name, state->preopen_names, + get_Protocol(), true)) { DEBUG(10, ("%s does not match the preopen:names list\n", smb_fname_str_dbg(smb_fname))); return res; diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 5ce4a7b0994..137048d4d45 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1215,7 +1215,8 @@ bool is_visible_file(connection_struct *conn, const char *dir_path, } /* If it's a vetoed file, pretend it doesn't even exist */ - if (use_veto && IS_VETO_PATH(conn, name)) { + if (use_veto && is_in_path(name, conn->veto_list, get_Protocol(), + conn->case_sensitive)) { DEBUG(10,("is_visible_file: file %s is vetoed.\n", name )); return False; } diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 0f319736758..928d48c3513 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -455,7 +455,8 @@ uint32 dos_mode_msdfs(connection_struct *conn, /* Optimization : Only call is_hidden_path if it's not already hidden. */ if (!(result & aHIDDEN) && - IS_HIDDEN_PATH(conn, smb_fname->base_name)) { + is_in_path(smb_fname->base_name, conn->hide_list, get_Protocol(), + conn->case_sensitive)) { result |= aHIDDEN; } @@ -641,7 +642,8 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname) /* Optimization : Only call is_hidden_path if it's not already hidden. */ if (!(result & aHIDDEN) && - IS_HIDDEN_PATH(conn, smb_fname->base_name)) { + is_in_path(smb_fname->base_name, conn->hide_list, get_Protocol(), + conn->case_sensitive)) { result |= aHIDDEN; } diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 5d6661df2a1..719ab6a3955 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -780,7 +780,8 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx, NTSTATUS check_name(connection_struct *conn, const char *name) { - if (IS_VETO_PATH(conn, name)) { + if (is_in_path(name, conn->veto_list, get_Protocol(), + conn->case_sensitive)) { /* Is it not dot or dot dot. */ if (!((name[0] == '.') && (!name[1] || (name[1] == '.' && !name[2])))) { diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 98984b86951..91cfa22a05e 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -611,7 +611,7 @@ static NTSTATUS open_file(files_struct *fsp, fsp->is_directory = False; if (conn->aio_write_behind_list && is_in_path(smb_fname->base_name, conn->aio_write_behind_list, - conn->case_sensitive)) { + get_Protocol(), conn->case_sensitive)) { fsp->aio_write_behind = True; } status = fsp_set_smb_fname(fsp, smb_fname); @@ -1570,7 +1570,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, /* ignore any oplock requests if oplocks are disabled */ if (!lp_oplocks(SNUM(conn)) || global_client_failed_oplock_break || - IS_VETO_OPLOCK_PATH(conn, smb_fname->base_name)) { + is_in_path(smb_fname->base_name, conn->veto_oplock_list, + get_Protocol(), conn->case_sensitive)) { /* Mask off everything except the private Samba bits. */ oplock_request &= SAMBA_PRIVATE_OPLOCK_MASK; } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a113a9d9826..4d7166fe9fc 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5445,7 +5445,8 @@ NTSTATUS rmdir_internals(TALLOC_CTX *ctx, TALLOC_FREE(talloced); continue; } - if(!IS_VETO_PATH(conn, dname)) { + if(!is_in_path(dname, conn->veto_list, get_Protocol(), + conn->case_sensitive)) { TALLOC_FREE(dir_hnd); TALLOC_FREE(talloced); errno = ENOTEMPTY; -- 2.34.1