The branch, v3-4-test has been updated
       via  18d9e7074635c80052e8bb8d85ad5605663e2695 (commit)
       via  0e7f37336ec2d7e1158342fb855af3dff84a7d1e (commit)
      from  e6b6027218b96bf3357837d051ca5d2df0d88561 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit 18d9e7074635c80052e8bb8d85ad5605663e2695
Author: Jeremy Allison <[email protected]>
Date:   Thu May 14 15:56:13 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 0e7f37336ec2d7e1158342fb855af3dff84a7d1e
Author: Jeremy Allison <[email protected]>
Date:   Thu May 14 12:34:28 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 |  131 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9cf5280..66caa86 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5919,8 +5919,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",
@@ -5942,10 +5940,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 b4e8700..619da05 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5272,6 +5272,136 @@ 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 (!cli_rmdir(pcli, fname))
+                       printf("del_fn: failed to rmdir %s\n,", fname );
+       } else {
+               if (!cli_unlink(pcli, fname))
+                       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 (!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++) {
+               int fnum = -1;
+
+               s.i = i;
+
+               if (strchr(illegal_chars, i)) {
+                       continue;
+               }
+               fname[15] = i;
+               fnum = cli_nt_create_full(cli, fname, 0, GENERIC_ALL_ACCESS, 
FILE_ATTRIBUTE_NORMAL,
+                                   FILE_SHARE_READ|FILE_SHARE_WRITE, 
FILE_OVERWRITE_IF, 0, 0);
+               if (fnum == -1) {
+                       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 (!cli_unlink(cli, fname)) {
+                       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;
@@ -5852,6 +5982,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