diff options
author | Jeremy Allison <jra@samba.org> | 2005-06-22 21:20:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:57:59 -0500 |
commit | 7e509e9b99a18495bde01a990e37de70bae35aac (patch) | |
tree | 36cb4800a573693b66ec270baf9c5d609fa4801c | |
parent | bc8954c4fce89992eb31bcb88e27728859aa7132 (diff) | |
download | samba-7e509e9b99a18495bde01a990e37de70bae35aac.tar.gz samba-7e509e9b99a18495bde01a990e37de70bae35aac.tar.bz2 samba-7e509e9b99a18495bde01a990e37de70bae35aac.zip |
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)
-rw-r--r-- | source3/lib/util.c | 6 | ||||
-rw-r--r-- | source3/param/loadparm.c | 26 | ||||
-rw-r--r-- | source3/smbd/dir.c | 2 | ||||
-rw-r--r-- | source3/smbd/mangle.c | 10 | ||||
-rw-r--r-- | source3/smbd/mangle_hash2.c | 39 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 3 | ||||
-rw-r--r-- | source3/smbd/reply.c | 12 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 8 |
8 files changed, 101 insertions, 5 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 297eeb4d03..b7651f8929 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2451,6 +2451,12 @@ char *parent_dirname(const char *path) BOOL ms_has_wild(const char *s) { char c; + + if (lp_posix_pathnames()) { + /* With posix pathnames no characters are wild. */ + return False; + } + while ((c = *s++)) { switch (c) { case '*': diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 0083b50820..fd0154d275 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -4523,3 +4523,29 @@ void set_store_dos_attributes(int snum, BOOL val) return; ServicePtrs[(snum)]->bStoreDosAttributes = val; } + +void lp_set_mangling_method(const char *new_method) +{ + string_set(&Globals.szManglingMethod, new_method); +} + +/******************************************************************* + Global state for POSIX pathname processing. +********************************************************************/ + +static BOOL posix_pathnames; + +BOOL lp_posix_pathnames(void) +{ + return posix_pathnames; +} + +/******************************************************************* + Change everything needed to ensure POSIX pathname processing (currently + not much). +********************************************************************/ + +void lp_set_posix_pathnames(void) +{ + posix_pathnames = True; +} 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: |