r7842: With the patch I sent Steve yesterday this gives us complete POSIX pathnames.
authorJeremy Allison <jra@samba.org>
Wed, 22 Jun 2005 21:20:41 +0000 (21:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:57:59 +0000 (10:57 -0500)
ie. files containing : and \ can be accessed from Linux.
Jeremy.
(This used to be commit e9b8d23d6138d909a65ea70b2e801881e8333b38)

source3/lib/util.c
source3/param/loadparm.c
source3/smbd/dir.c
source3/smbd/mangle.c
source3/smbd/mangle_hash2.c
source3/smbd/nttrans.c
source3/smbd/reply.c
source3/smbd/trans2.c

index 297eeb4d03000ae758e2405096a04e4185bc5c52..b7651f892944634559025cdcef58ffe49b23d3c3 100644 (file)
@@ -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 '*':
index 0083b50820827cc151488830ed19e42a89437ae3..fd0154d275baf54327893a733c0c68b51823369a 100644 (file)
@@ -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;
+}
index 072f396b8ccda8ee5269641942fba1950ae0e6a7..ae21e16e311b902ad99fb23c74c3d3421ec5f208 100644 (file)
@@ -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);
index afc1ca12f0572696b284d4d1dcddc4c69d573f90..ed69a6210e88fd40311c8e872a3a7f15b233f5dc 100644 (file)
@@ -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
 */
index 4325c07f580e785cd6476a2dc134732807c4a757..e44aaf17e75546e97adb848b352ce0660e826919 100644 (file)
@@ -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;
+}
index a0f94d616dfbbd59fbd67540a5170c90cb12b4db..cc37d531f2485f00abec8d241919fc600113b087 100644 (file)
@@ -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;
 }
 
index d49823bea5c20498a5855c29e966604f6d9c0cd4..99e0d5d9a105b3369f81efd4f3b334b473a91927 100644 (file)
@@ -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);
index 98f4de2bf9178619eca31c5eb14c843669d4560a..978afa6d74dea5e4d468cc95e7b02be52a432bee 100644 (file)
@@ -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: