r81: Make EA's case independent - fix smbtorture to test for this.
authorJeremy Allison <jra@samba.org>
Tue, 6 Apr 2004 14:24:13 +0000 (14:24 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:51:07 +0000 (10:51 -0500)
Jeremy.

source/smbd/trans2.c
source/torture/torture.c

index a88722edde51febab368dc8bb69925852e1c32c2..1e7d845714e6614e2d1e2b5d88bac544667a4ace 100644 (file)
@@ -273,6 +273,27 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
        return total_ea_len;
 }
 
+/****************************************************************************
+ Ensure the EA name is case insensitive by matching any existing EA name.
+****************************************************************************/
+
+static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, const char *fname, fstring unix_ea_name)
+{
+       size_t total_ea_len;
+       TALLOC_CTX *mem_ctx = talloc_init("canonicalize_ea_name");
+       struct ea_list *ea_list = get_ea_list(mem_ctx, conn, fsp, fname, &total_ea_len);
+
+       for (; ea_list; ea_list = ea_list->next) {
+               if (strequal(&unix_ea_name[5], ea_list->ea.name)) {
+                       DEBUG(10,("canonicalize_ea_name: %s -> %s\n",
+                               &unix_ea_name[5], ea_list->ea.name));
+                       safe_strcpy(&unix_ea_name[5], ea_list->ea.name, sizeof(fstring)-6);
+                       break;
+               }
+       }
+       talloc_destroy(mem_ctx);
+}
+
 /****************************************************************************
  Set or delete an extended attribute.
 ****************************************************************************/
@@ -317,6 +338,8 @@ static NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *f
        pull_ascii(&unix_ea_name[5], pdata, sizeof(fstring) - 5, -1, STR_TERMINATE);
        pdata += (namelen + 1);
 
+       canonicalize_ea_name(conn, fsp, fname, unix_ea_name);
+
        DEBUG(10,("set_ea: ea_name %s ealen = %u\n", unix_ea_name, ealen));
        if (ealen) {
                DEBUG(10,("set_ea: data :\n"));
@@ -341,8 +364,8 @@ static NTSTATUS set_ea(connection_struct *conn, files_struct *fsp, const char *f
                }
 #ifdef ENOATTR
                /* Removing a non existent attribute always succeeds. */
-               DEBUG(10,("set_ea: deleting ea name %s didn't exist - succeeding by default.\n", unix_ea_name));
                if (ret == -1 && errno == ENOATTR) {
+                       DEBUG(10,("set_ea: deleting ea name %s didn't exist - succeeding by default.\n", unix_ea_name));
                        ret = 0;
                }
 #endif
index 17a2ee00a8db0f874e902efbad54c0581c82194d..161aa2cd73b1fcb9252c8944a0f13c6f62380fce 100644 (file)
@@ -4378,11 +4378,11 @@ static BOOL run_eatest(int dummy)
        }
 
        /* Setting EA's to zero length deletes them. Test this */
-       printf("Now deleting all EA's....\n");
+       printf("Now deleting all EA's - case indepenent....\n");
 
        for (i = 0; i < 20; i++) {
                fstring ea_name;
-               slprintf(ea_name, sizeof(ea_name), "EA_%d", i);
+               slprintf(ea_name, sizeof(ea_name), "ea_%d", i);
                if (!cli_set_ea_path(cli, fname, ea_name, "", 0)) {
                        printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
                        return False;