The branch, master has been updated
       via  41aa7d790a5140be2947781ea7def3a17b213a28 (commit)
       via  a84028590f0138bbb4db6ba22450f6d320fde83f (commit)
      from  57e03b6a1d98219d5adafff570d1cb01d8b5758e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 41aa7d790a5140be2947781ea7def3a17b213a28
Author: Jeremy Allison <j...@samba.org>
Date:   Thu May 14 16:03:31 2009 -0700

    Add a test showing what ascii values cause an NTFS volume to
    create a mangled name. We don't pass this yet, but it's not
    run by default.
    Jeremy.

commit a84028590f0138bbb4db6ba22450f6d320fde83f
Author: Jeremy Allison <j...@samba.org>
Date:   Thu May 14 16:03:18 2009 -0700

    Remove one use of mangle_is_8_3(), not needed.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source3/smbd/reply.c      |    6 +--
 source3/torture/torture.c |  133 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 1f73b2f..a81c22b 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -6018,8 +6018,6 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                /*
                 * No wildcards - just process the one file.
                 */
-               bool is_short_name = mangle_is_8_3(name, True, conn->params);
-
                /* Add a terminating '/' to the directory name. */
                directory = talloc_asprintf_append(directory,
                                "/%s",
@@ -6041,10 +6039,10 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                DEBUG(3, ("rename_internals: case_sensitive = %d, "
                          "case_preserve = %d, short case preserve = %d, "
                          "directory = %s, newname = %s, "
-                         "last_component_dest = %s, is_8_3 = %d\n",
+                         "last_component_dest = %s\n",
                          conn->case_sensitive, conn->case_preserve,
                          conn->short_case_preserve, directory,
-                         newname, last_component_dest, is_short_name));
+                         newname, last_component_dest));
 
                /* The dest name still may have wildcards. */
                if (dest_has_wild) {
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 578f6a3..99bf378 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5265,6 +5265,138 @@ static bool run_uid_regression_test(int dummy)
        return correct;
 }
 
+
+static const char *illegal_chars = "*\\/?<>|\":";
+static char force_shortname_chars[] = " +,.[];=\177";
+
+static void shortname_del_fn(const char *mnt, file_info *finfo, const char 
*mask, void *state)
+{
+       struct cli_state *pcli = (struct cli_state *)state;
+       fstring fname;
+       slprintf(fname, sizeof(fname), "\\shortname\\%s", finfo->name);
+
+       if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0)
+               return;
+
+       if (finfo->mode & aDIR) {
+               if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname)))
+                       printf("del_fn: failed to rmdir %s\n,", fname );
+       } else {
+               if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | 
aHIDDEN)))
+                       printf("del_fn: failed to unlink %s\n,", fname );
+       }
+}
+
+struct sn_state {
+       int i;
+       bool val;
+};
+
+static void shortname_list_fn(const char *mnt, file_info *finfo, const char 
*name, void *state)
+{
+       struct sn_state *s = (struct sn_state  *)state;
+       int i = s->i;
+
+#if 0
+       printf("shortname list: i = %d, name = |%s|, shortname = |%s|\n",
+               i, finfo->name, finfo->short_name);
+#endif
+
+       if (strchr(force_shortname_chars, i)) {
+               if (!finfo->short_name[0]) {
+                       /* Shortname not created when it should be. */
+                       d_printf("(%s) ERROR: Shortname was not created for 
file %s\n",
+                               __location__, finfo->name);
+                       s->val = true;
+               }
+       } else if (finfo->short_name[0]){
+               /* Shortname created when it should not be. */
+               d_printf("(%s) ERROR: Shortname %s was created for file %s\n",
+                       __location__, finfo->short_name, finfo->name);
+               s->val = true;
+       }
+}
+
+static bool run_shortname_test(int dummy)
+{
+       static struct cli_state *cli;
+       bool correct = True;
+       int i;
+       struct sn_state s;
+       char fname[20];
+
+       printf("starting shortname test\n");
+
+       if (!torture_open_connection(&cli, 0)) {
+               return False;
+       }
+
+       cli_sockopt(cli, sockops);
+
+       cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
+       cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
+       cli_rmdir(cli, "\\shortname");
+
+       if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\shortname"))) {
+               d_printf("(%s) cli_mkdir of \\shortname failed: %s\n",
+                       __location__, cli_errstr(cli));
+               correct = false;
+               goto out;
+       }
+
+       strlcpy(fname, "\\shortname\\", sizeof(fname));
+       strlcat(fname, "test .txt", sizeof(fname));
+
+       s.val = false;
+
+       for (i = 32; i < 128; i++) {
+               NTSTATUS status;
+               uint16_t fnum = (uint16_t)-1;
+
+               s.i = i;
+
+               if (strchr(illegal_chars, i)) {
+                       continue;
+               }
+               fname[15] = i;
+
+               status = cli_ntcreate(cli, fname, 0, GENERIC_ALL_ACCESS, 
FILE_ATTRIBUTE_NORMAL,
+                                   FILE_SHARE_READ|FILE_SHARE_WRITE, 
FILE_OVERWRITE_IF, 0, 0, &fnum);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("(%s) cli_nt_create of %s failed: %s\n",
+                               __location__, fname, cli_errstr(cli));
+                       correct = false;
+                       goto out;
+               }
+               cli_close(cli, fnum);
+               if (cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, 
&s) != 1) {
+                       d_printf("(%s) failed to list %s: %s\n",
+                               __location__, fname, cli_errstr(cli));
+                       correct = false;
+                       goto out;
+               }
+               if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | 
aHIDDEN))) {
+                       d_printf("(%s) failed to delete %s: %s\n",
+                               __location__, fname, cli_errstr(cli));
+                       correct = false;
+                       goto out;
+               }
+
+               if (s.val) {
+                       correct = false;
+                       goto out;
+               }
+       }
+
+  out:
+
+       cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
+       cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
+       cli_rmdir(cli, "\\shortname");
+       torture_close_connection(cli);
+       return correct;
+}
+
 static bool run_local_substitute(int dummy)
 {
        bool ok = true;
@@ -5899,6 +6031,7 @@ static struct {
        {"OPEN", run_opentest, 0},
        {"POSIX", run_simple_posix_open_test, 0},
        { "UID-REGRESSION-TEST", run_uid_regression_test, 0},
+       { "SHORTNAME-TEST", run_shortname_test, 0},
 #if 1
        {"OPENATTR", run_openattrtest, 0},
 #endif


-- 
Samba Shared Repository

Reply via email to