From 7e509e9b99a18495bde01a990e37de70bae35aac Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 22 Jun 2005 21:20:41 +0000 Subject: r7842: With the patch I sent Steve yesterday this gives us complete POSIX pathnames. ie. files containing : and \ can be accessed from Linux. Jeremy. (This used to be commit e9b8d23d6138d909a65ea70b2e801881e8333b38) --- source3/smbd/dir.c | 2 +- source3/smbd/mangle.c | 10 +++++++++- source3/smbd/mangle_hash2.c | 39 +++++++++++++++++++++++++++++++++++++++ source3/smbd/nttrans.c | 3 +++ source3/smbd/reply.c | 12 +++++++++++- source3/smbd/trans2.c | 8 ++++++-- 6 files changed, 69 insertions(+), 5 deletions(-) (limited to 'source3/smbd') diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 072f396b8c..ae21e16e31 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -238,7 +238,7 @@ BOOL dptr_set_wcard_and_attributes(int key, const char *wcard, uint16 attr) dptr->wcard = SMB_STRDUP(wcard); if (!dptr->wcard) return False; - if (wcard[0] == '.' && wcard[1] == 0) { + if (lp_posix_pathnames() || (wcard[0] == '.' && wcard[1] == 0)) { dptr->has_wild = True; } else { dptr->has_wild = ms_has_wild(wcard); diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c index afc1ca12f0..ed69a6210e 100644 --- a/source3/smbd/mangle.c +++ b/source3/smbd/mangle.c @@ -29,6 +29,7 @@ static const struct { } mangle_backends[] = { { "hash", mangle_hash_init }, { "hash2", mangle_hash2_init }, + { "posix", posix_mangle_init }, /*{ "tdb", mangle_tdb_init }, */ { NULL, NULL } }; @@ -39,7 +40,7 @@ static const struct { static void mangle_init(void) { int i; - char *method; + const char *method; if (mangle_fns) return; @@ -70,6 +71,13 @@ void mangle_reset_cache(void) mangle_fns->reset(); } +void mangle_change_to_posix(void) +{ + mangle_fns = NULL; + lp_set_mangling_method("posix"); + mangle_reset_cache(); +} + /* see if a filename has come out of our mangling code */ diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c index 4325c07f58..e44aaf17e7 100644 --- a/source3/smbd/mangle_hash2.c +++ b/source3/smbd/mangle_hash2.c @@ -716,3 +716,42 @@ struct mangle_fns *mangle_hash2_init(void) return &mangle_fns; } + +static void posix_mangle_reset(void) +{;} + +static BOOL posix_is_mangled(const char *s, int snum) +{ + return False; +} + +static BOOL posix_is_8_3(const char *fname, BOOL check_case, BOOL allow_wildcards, int snum) +{ + return False; +} + +static BOOL posix_check_cache( char *s, size_t maxlen, int snum ) +{ + return False; +} + +static void posix_name_map(char *OutName, BOOL need83, BOOL cache83, int default_case, int snum) +{ + if (need83) { + memset(OutName, '\0', 13); + } +} + +/* POSIX paths backend - no mangle. */ +static struct mangle_fns posix_mangle_fns = { + posix_mangle_reset, + posix_is_mangled, + posix_is_8_3, + posix_check_cache, + posix_name_map +}; + +struct mangle_fns *posix_mangle_init(void) +{ + return &posix_mangle_fns; +} diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index a0f94d616d..cc37d531f2 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -267,6 +267,9 @@ static int send_nt_replies(char *inbuf, char *outbuf, int bufsize, NTSTATUS nt_e BOOL is_ntfs_stream_name(const char *fname) { + if (lp_posix_pathnames()) { + return False; + } return (strchr_m(fname, ':') != NULL) ? True : False; } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d49823bea5..99e0d5d9a1 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -398,7 +398,9 @@ size_t srvstr_get_path(char *inbuf, char *dest, const char *src, size_t dest_len } else { ret = srvstr_pull( inbuf, tmppath_ptr, src, dest_len, src_len, flags); } - if (allow_wcard_names) { + if (lp_posix_pathnames()) { + *err = check_path_syntax_posix(dest, tmppath); + } else if (allow_wcard_names) { *err = check_path_syntax_wcard(dest, tmppath); } else { *err = check_path_syntax(dest, tmppath); @@ -1032,6 +1034,10 @@ int reply_search(connection_struct *conn, char *inbuf,char *outbuf, int dum_size NTSTATUS nt_status; BOOL allow_long_path_components = (SVAL(inbuf,smb_flg2) & FLAGS2_LONG_PATH_COMPONENTS) ? True : False; + if (lp_posix_pathnames()) { + return reply_unknown(inbuf, outbuf); + } + START_PROFILE(SMBsearch); *mask = *directory = *fname = 0; @@ -1228,6 +1234,10 @@ int reply_fclose(connection_struct *conn, char *inbuf,char *outbuf, int dum_size char *p; NTSTATUS err; + if (lp_posix_pathnames()) { + return reply_unknown(inbuf, outbuf); + } + START_PROFILE(SMBfclose); outsize = set_message(outbuf,1,0,True); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 98f4de2bf9..978afa6d74 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -2390,7 +2390,8 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned data_len = 12; SSVAL(pdata,0,CIFS_UNIX_MAJOR_VERSION); SSVAL(pdata,2,CIFS_UNIX_MINOR_VERSION); - SBIG_UINT(pdata,4,((SMB_BIG_UINT)CIFS_UNIX_POSIX_ACLS_CAP)); /* We have POSIX ACLs. */ + SBIG_UINT(pdata,4,((SMB_BIG_UINT)(CIFS_UNIX_POSIX_ACLS_CAP| + CIFS_UNIX_POSIX_PATHNAMES_CAP))); /* We have POSIX ACLs and pathname capability. */ break; case SMB_MAC_QUERY_FS_INFO: @@ -2461,13 +2462,16 @@ static int call_trans2setfsinfo(connection_struct *conn, char *inbuf, char *outb client_unix_cap_low = IVAL(pdata,4); client_unix_cap_high = IVAL(pdata,8); /* Just print these values for now. */ - DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u\ + DEBUG(10,("call_trans2setfsinfo: set unix info. major = %u, minor = %u \ cap_low = 0x%x, cap_high = 0x%x\n", (unsigned int)client_unix_major, (unsigned int)client_unix_minor, (unsigned int)client_unix_cap_low, (unsigned int)client_unix_cap_high )); + /* Here is where we must switch to posix pathname processing... */ + lp_set_posix_pathnames(); + mangle_change_to_posix(); break; } case SMB_FS_QUOTA_INFORMATION: -- cgit