Allowing veto files = /blah-blah-blah/ to contain \3 ...
Richard Sharpe
realrichardsharpe at gmail.com
Fri Apr 30 17:06:28 MDT 2010
Hi,
In mixed environments (Mac and Windows) you don't want to veto /Icon?/
because iTunes needs to create files like Icon1 Icon2 etc.
However, if Mac users copy folders onto a Samba server that have
customized icons in them, they end up with a file called Icon\r.
We wanted to veto just these files.
The following patch allows you to do: veto files = /Icon\r/
--- ../rootfs-components/samba-3.4.4/source3/lib/util.c 2010-04-30
11:24:04.000000000 -0700
+++ samba-3.4.4/source3/lib/util.c 2010-04-30 16:02:44.000000000 -0700
@@ -1708,6 +1708,36 @@ bool is_in_path(const char *name, name_c
return False;
}
+/*
+ * This does an inplace conversion of \\ and \r to \ and 0x0D. Yes, it is
+ * O(n^2) but where it is used we don't care.
+ */
+static void convert_non_print(char * str)
+{
+ int i = 0;
+
+ if (str == NULL || strlen(str) == 0)
+ return;
+
+ while (str[i]) {
+ if ((str[i] == '\\') && str[i + 1]) { /* This is safe! */
+
+ if ((str[i + 1] == 'r') || (str[i + 1] == 'R')) {
+ str[i] = 0x0D;
+ safe_strcpy(&str[i + 1], &str[i + 2],
+ strlen(&str[i]));
+ }
+ else if (str[i + 1] == '\\') { /* Copy down one */
+ safe_strcpy(&str[i], &str[i + 1],
+ strlen(&str[i]));
+ }
+ }
+ i++; /* Skip the char we just dealt with */
+ }
+
+ return;
+}
+
/*******************************************************************
Strip a '/' separated list into an array of
name_compare_enties structures suitable for
@@ -1787,6 +1817,9 @@ void set_namearray(name_compare_entry **
return;
}
+ /* DRI mod ... transform \r and \\ into 0x0D and \. RJS */
+ convert_non_print((*ppname_array)[i].name);
+
/* next segment please */
nameptr = name_end + 1;
i++;
--
Regards,
Richard Sharpe
More information about the samba-technical
mailing list