diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/dir.c | 2 | ||||
-rw-r--r-- | source3/smbd/filename.c | 10 | ||||
-rw-r--r-- | source3/smbd/mangle.c | 19 | ||||
-rw-r--r-- | source3/smbd/mangle_hash.c | 18 | ||||
-rw-r--r-- | source3/smbd/mangle_hash2.c | 15 | ||||
-rw-r--r-- | source3/smbd/reply.c | 9 | ||||
-rw-r--r-- | source3/smbd/service.c | 3 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 12 |
8 files changed, 45 insertions, 43 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 95a5903c14..d66d1601fb 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -784,7 +784,7 @@ BOOL get_dir_entry(connection_struct *conn,char *mask,int dirtype, pstring fname mask_match_search(filename,mask,False) || mangle_mask_match(conn,filename,mask)) { - if (!mangle_is_8_3(filename, False)) + if (!mangle_is_8_3(filename, False, SNUM(conn))) mangle_map(filename,True,False,SNUM(conn)); pstrcpy(fname,filename); diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 9ca2c0efae..5f3cdfb77e 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -150,7 +150,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen pstrcpy(saved_last_component, name); } - if (!conn->case_preserve || (mangle_is_8_3(name, False) && !conn->short_case_preserve)) + if (!conn->case_preserve || (mangle_is_8_3(name, False, SNUM(conn)) && !conn->short_case_preserve)) strnorm(name, lp_defaultcase(SNUM(conn))); start = name; @@ -179,7 +179,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen * sensitive then searching won't help. */ - if (conn->case_sensitive && !mangle_is_mangled(name) && !*lp_mangled_map(SNUM(conn))) + if (conn->case_sensitive && !mangle_is_mangled(name, SNUM(conn)) && !*lp_mangled_map(SNUM(conn))) return(False); name_has_wildcard = ms_has_wild(start); @@ -189,7 +189,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen * just a component. JRA. */ - if (mangle_is_mangled(start)) + if (mangle_is_mangled(start, SNUM(conn))) component_was_mangled = True; /* @@ -317,7 +317,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen * base of the filename. */ - if (mangle_is_mangled(start)) { + if (mangle_is_mangled(start, SNUM(conn))) { mangle_check_cache( start, sizeof(pstring) - 1 - (start - name) ); } @@ -433,7 +433,7 @@ static BOOL scan_directory(connection_struct *conn, const char *path, char *name BOOL mangled; long curpos; - mangled = mangle_is_mangled(name); + mangled = mangle_is_mangled(name, SNUM(conn)); /* handle null paths */ if (*path == 0) diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index 43becff69d..afc1ca12f0 100644 --- a/source3/smbd/mangle.c +++ b/source3/smbd/mangle.c @@ -67,29 +67,28 @@ static void mangle_init(void) void mangle_reset_cache(void) { mangle_init(); - mangle_fns->reset(); } /* see if a filename has come out of our mangling code */ -BOOL mangle_is_mangled(const char *s) +BOOL mangle_is_mangled(const char *s, int snum) { - return mangle_fns->is_mangled(s); + return mangle_fns->is_mangled(s, snum); } /* see if a filename matches the rules of a 8.3 filename */ -BOOL mangle_is_8_3(const char *fname, BOOL check_case) +BOOL mangle_is_8_3(const char *fname, BOOL check_case, int snum) { - return mangle_fns->is_8_3(fname, check_case, False); + return mangle_fns->is_8_3(fname, check_case, False, snum); } -BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case) +BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case, int snum) { - return mangle_fns->is_8_3(fname, check_case, True); + return mangle_fns->is_8_3(fname, check_case, True, snum); } /* @@ -98,9 +97,9 @@ BOOL mangle_is_8_3_wildcards(const char *fname, BOOL check_case) looking for a matching name if it doesn't. It should succeed most of the time or there will be a huge performance penalty */ -BOOL mangle_check_cache(char *s, size_t maxlen) +BOOL mangle_check_cache(char *s, size_t maxlen, int snum) { - return mangle_fns->check_cache(s, maxlen); + return mangle_fns->check_cache(s, maxlen, snum); } /* @@ -120,5 +119,5 @@ void mangle_map(pstring OutName, BOOL need83, BOOL cache83, int snum) /* invoke the inane "mangled map" code */ mangle_map_filename(OutName, snum); - mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(snum)); + mangle_fns->name_map(OutName, need83, cache83, lp_defaultcase(snum), snum); } diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c index 0067023e61..98ba775daf 100644 --- a/source3/smbd/mangle_hash.c +++ b/source3/smbd/mangle_hash.c @@ -276,13 +276,15 @@ done: return ret; } -static BOOL is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards) +static BOOL is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum) { const char *f; smb_ucs2_t *ucs2name; NTSTATUS ret = NT_STATUS_UNSUCCESSFUL; size_t size; + magic_char = lp_magicchar(snum); + if (!fname || !*fname) return False; if ((f = strrchr(fname, '/')) == NULL) @@ -362,10 +364,12 @@ static void init_chartest( void ) * * ************************************************************************** ** */ -static BOOL is_mangled(const char *s) +static BOOL is_mangled(const char *s, int snum) { char *magic; + magic_char = lp_magicchar(snum); + if( !ct_initialized ) init_chartest(); @@ -460,12 +464,14 @@ static void cache_mangled_name( const char mangled_name[13], char *raw_name ) * ************************************************************************** ** */ -static BOOL check_cache( char *s, size_t maxlen ) +static BOOL check_cache( char *s, size_t maxlen, int snum ) { TDB_DATA data_val; char *ext_start = NULL; char *saved_ext = NULL; + magic_char = lp_magicchar(snum); + /* If the cache isn't initialized, give up. */ if( !tdb_mangled_cache ) return( False ); @@ -604,9 +610,11 @@ static void to_8_3(char *s, int default_case) * **************************************************************************** */ -static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case) +static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum) { smb_ucs2_t *OutName_ucs2; + magic_char = lp_magicchar(snum); + DEBUG(5,("name_map( %s, need83 = %s, cache83 = %s)\n", OutName, need83 ? "True" : "False", cache83 ? "True" : "False")); @@ -643,9 +651,9 @@ static void name_map(char *OutName, BOOL need83, BOOL cache83, int default_case) to drop in an alternative mangling implementation */ static struct mangle_fns mangle_fns = { + mangle_reset, is_mangled, is_8_3, - mangle_reset, check_cache, name_map }; diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c index 4896cfb17b..6a8462ee3d 100644 --- a/source3/smbd/mangle_hash2.c +++ b/source3/smbd/mangle_hash2.c @@ -268,7 +268,7 @@ static BOOL is_mangled_component(const char *name, size_t len) directory separators. It should return true if any component is mangled */ -static BOOL is_mangled(const char *name) +static BOOL is_mangled(const char *name, int snum) { const char *p; const char *s; @@ -293,7 +293,7 @@ static BOOL is_mangled(const char *name) simplifies things greatly (it means that we know the string won't get larger when converted from UNIX to DOS formats) */ -static BOOL is_8_3(const char *name, BOOL check_case, BOOL allow_wildcards) +static BOOL is_8_3(const char *name, BOOL check_case, BOOL allow_wildcards, int snum) { int len, i; char *dot_p; @@ -370,7 +370,7 @@ static void mangle_reset(void) try to find a 8.3 name in the cache, and if found then replace the string with the original long name. */ -static BOOL check_cache(char *name, size_t maxlen) +static BOOL check_cache(char *name, size_t maxlen, int snum) { u32 hash, multiplier; unsigned int i; @@ -378,7 +378,7 @@ static BOOL check_cache(char *name, size_t maxlen) char extension[4]; /* make sure that this is a mangled name from this cache */ - if (!is_mangled(name)) { + if (!is_mangled(name, snum)) { M_DEBUG(10,("check_cache: %s -> not mangled\n", name)); return False; } @@ -506,7 +506,7 @@ static BOOL is_legal_name(const char *name) the name parameter must be able to hold 13 bytes */ -static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case) +static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case, int snum) { char *dot_p; char lead_chars[7]; @@ -520,7 +520,7 @@ static void name_map(fstring name, BOOL need83, BOOL cache83, int default_case) if (!is_reserved_name(name)) { /* if the name is already a valid 8.3 name then we don't need to do anything */ - if (is_8_3(name, False, False)) { + if (is_8_3(name, False, False, snum)) { return; } @@ -679,14 +679,13 @@ static void init_tables(void) } } - /* the following provides the abstraction layer to make it easier to drop in an alternative mangling implementation */ static struct mangle_fns mangle_fns = { + mangle_reset, is_mangled, is_8_3, - mangle_reset, check_cache, name_map }; diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index aa33e59b7e..d39b9a20d3 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -30,7 +30,6 @@ extern enum protocol_types Protocol; extern int max_send; extern int max_recv; -extern char magic_char; extern int global_oplock_break; unsigned int smb_echo_count = 0; extern uint32 global_client_caps; @@ -1753,7 +1752,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name) * Tine Smukavec <valentin.smukavec@hermes.si>. */ - if (!rc && mangle_is_mangled(mask)) + if (!rc && mangle_is_mangled(mask,SNUM(conn))) mangle_check_cache( mask, sizeof(pstring)-1 ); if (!has_wild) { @@ -4055,7 +4054,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, ui * Tine Smukavec <valentin.smukavec@hermes.si>. */ - if (!rc && mangle_is_mangled(mask)) + if (!rc && mangle_is_mangled(mask,SNUM(conn))) mangle_check_cache( mask, sizeof(pstring)-1 ); has_wild = ms_has_wild(mask); @@ -4064,7 +4063,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, ui /* * No wildcards - just process the one file. */ - BOOL is_short_name = mangle_is_8_3(name, True); + BOOL is_short_name = mangle_is_8_3(name, True, SNUM(conn)); /* Add a terminating '/' to the directory name. */ pstrcat(directory,"/"); @@ -4536,7 +4535,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, * Tine Smukavec <valentin.smukavec@hermes.si>. */ - if (!rc && mangle_is_mangled(mask)) + if (!rc && mangle_is_mangled(mask, SNUM(conn))) mangle_check_cache( mask, sizeof(pstring)-1 ); has_wild = ms_has_wild(mask); diff --git a/source3/smbd/service.c b/source3/smbd/service.c index d4d6274dff..1708c51ff9 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -20,11 +20,9 @@ #include "includes.h" -extern char magic_char; extern struct timeval smb_last_time; extern userdom_struct current_user_info; - /**************************************************************************** Load parameters specific to a connection/service. ****************************************************************************/ @@ -80,7 +78,6 @@ BOOL set_current_service(connection_struct *conn, uint16 flags, BOOL do_chdir) conn->case_sensitive = False; break; } - magic_char = lp_magicchar(snum); return(True); } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index dd72db2fae..9f29a89f01 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -1064,7 +1064,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, if(!(got_match = *got_exact_match = exact_match(fname, mask, conn->case_sensitive))) got_match = mask_match(fname, mask, conn->case_sensitive); - if(!got_match && check_mangled_names && !mangle_is_8_3(fname, False)) { + if(!got_match && check_mangled_names && !mangle_is_8_3(fname, False, SNUM(conn))) { /* * It turns out that NT matches wildcards against @@ -1286,7 +1286,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, case SMB_FIND_FILE_BOTH_DIRECTORY_INFO: DEBUG(10,("get_lanman2_dir_entry: SMB_FIND_FILE_BOTH_DIRECTORY_INFO\n")); - was_8_3 = mangle_is_8_3(fname, True); + was_8_3 = mangle_is_8_3(fname, True, SNUM(conn)); p += 4; SIVAL(p,0,reskey); p += 4; put_long_date(p,cdate); p += 8; @@ -1422,7 +1422,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn, case SMB_FIND_ID_BOTH_DIRECTORY_INFO: DEBUG(10,("get_lanman2_dir_entry: SMB_FIND_ID_BOTH_DIRECTORY_INFO\n")); - was_8_3 = mangle_is_8_3(fname, True); + was_8_3 = mangle_is_8_3(fname, True, SNUM(conn)); p += 4; SIVAL(p,0,reskey); p += 4; put_long_date(p,cdate); p += 8; @@ -1813,7 +1813,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd * (see PR#13758). JRA. */ - if(!mangle_is_8_3_wildcards( mask, False)) + if(!mangle_is_8_3_wildcards( mask, False, SNUM(conn))) mangle_map(mask, True, True, SNUM(conn)); return(-1); @@ -2007,7 +2007,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd * could be mangled. Ensure we check the unmangled name. */ - if (mangle_is_mangled(resume_name)) { + if (mangle_is_mangled(resume_name, SNUM(conn))) { mangle_check_cache(resume_name, sizeof(resume_name)-1); } @@ -3044,7 +3044,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd DEBUG(10,("call_trans2qfilepathinfo: SMB_FILE_ALTERNATE_NAME_INFORMATION\n")); pstrcpy(short_name,base_name); /* Mangle if not already 8.3 */ - if(!mangle_is_8_3(short_name, True)) { + if(!mangle_is_8_3(short_name, True, SNUM(conn))) { mangle_map(short_name,True,True,SNUM(conn)); } len = srvstr_push(outbuf, pdata+4, short_name, -1, STR_UNICODE); |