s3/smbd: convert "mangled names" option to an enum
authorRalph Boehme <slow@samba.org>
Thu, 17 Nov 2016 13:22:41 +0000 (14:22 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 9 Jan 2017 18:31:20 +0000 (19:31 +0100)
This is in preparation of adding an additional setting for this
option. No change in behaviour by this commit, that comes in the next
one.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/param/loadparm.h
lib/param/param_table.c
source3/param/loadparm.c
source3/smbd/mangle.c
source3/smbd/trans2.c

index f9fb7d8d804f9d08f8e1ee3b2b6e67e660bfaf32..2cd5ccac1c29f7d86e2be8a3c567a5cd956316f2 100644 (file)
@@ -236,6 +236,9 @@ enum inheritowner_options {
        INHERIT_OWNER_UNIX_ONLY
 };
 
+/* mangled names options */
+enum mangled_names_options {MANGLED_NAMES_NO, MANGLED_NAMES_YES};
+
 /*
  * Default passwd chat script.
  */
index 4b5234a7c9e484cbb2a2e30b698e013a100cb55b..8eb791aa2c4b18b2025bef1595d786921ef5113b 100644 (file)
@@ -315,6 +315,16 @@ static const struct enum_list enum_inherit_owner_vals[] = {
     {INHERIT_OWNER_UNIX_ONLY, "unix only"},
     {-1, NULL}};
 
+static const struct enum_list enum_mangled_names[] = {
+       {MANGLED_NAMES_NO, "no"},
+       {MANGLED_NAMES_NO, "false"},
+       {MANGLED_NAMES_NO, "0"},
+       {MANGLED_NAMES_YES, "yes"},
+       {MANGLED_NAMES_YES, "true"},
+       {MANGLED_NAMES_YES, "1"},
+       {-1, NULL}
+};
+
 /* Note: We do not initialise the defaults union - it is not allowed in ANSI C
  *
  * NOTE: Handling of duplicated (synonym) parameters:
index d8da749ccba122e6b310a8fdfd2b9a09a23e733f..ac9ba490fb717ea85ea53cafa4fca07257c51c4a 100644 (file)
@@ -201,7 +201,7 @@ static struct loadparm_service sDefault =
        .oplocks = true,
        .kernel_oplocks = false,
        .level2_oplocks = true,
-       .mangled_names = true,
+       .mangled_names = MANGLED_NAMES_YES,
        .wide_links = false,
        .follow_symlinks = true,
        .sync_always = false,
index a8988f0219987e805a9ddd05a8eade9f01823dba..3649bf772fa629a227e29eb9cea4eb556e5acfa3 100644 (file)
@@ -104,7 +104,7 @@ bool mangle_is_8_3_wildcards(const char *fname, bool check_case,
 bool mangle_must_mangle(const char *fname,
                   const struct share_params *p)
 {
-       if (!lp_mangled_names(p)) {
+       if (lp_mangled_names(p) == MANGLED_NAMES_NO) {
                return False;
        }
        return mangle_fns->must_mangle(fname, p);
@@ -140,7 +140,7 @@ bool name_to_8_3(const char *in,
 
        /* name mangling can be disabled for speed, in which case
           we just truncate the string */
-       if (!lp_mangled_names(p)) {
+       if (lp_mangled_names(p) == MANGLED_NAMES_NO) {
                strlcpy(out, in, 13);
                return True;
        }
index 6999b2d0715a53c82c5509a7ff8a42ff7630526a..6fe3f92f6bf309079542ccf5abb1f79709a80ccc 100644 (file)
@@ -2440,11 +2440,17 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
        bool ok;
        uint64_t last_entry_off = 0;
        NTSTATUS status;
+       enum mangled_names_options mangled_names;
+       bool marshall_with_83_names;
+
+       mangled_names = lp_mangled_names(conn->params);
 
        ZERO_STRUCT(state);
        state.conn = conn;
        state.info_level = info_level;
-       state.check_mangled_names = lp_mangled_names(conn->params);
+       if (mangled_names != MANGLED_NAMES_NO) {
+               state.check_mangled_names = true;
+       }
        state.has_wild = dptr_has_wild(dirptr);
        state.got_exact_match = false;
 
@@ -2480,12 +2486,14 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
 
        *got_exact_match = state.got_exact_match;
 
+       marshall_with_83_names = (mangled_names == MANGLED_NAMES_YES);
+
        status = smbd_marshall_dir_entry(ctx,
                                     conn,
                                     flags2,
                                     info_level,
                                     name_list,
-                                    state.check_mangled_names,
+                                    marshall_with_83_names,
                                     requires_resume_key,
                                     mode,
                                     fname,