summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-04-30 13:37:19 +0200
committerVolker Lendecke <vl@samba.org>2009-04-30 13:42:12 +0200
commitf4fcf2c1c0f4fbf465afe78e2dddd04436ad1a40 (patch)
tree7e857feda6446cfb17ab5544125ee6c6c1bd2fdb
parent3b666bf0f9691e552999b655b2feca71048aa640 (diff)
downloadsamba-f4fcf2c1c0f4fbf465afe78e2dddd04436ad1a40.tar.gz
samba-f4fcf2c1c0f4fbf465afe78e2dddd04436ad1a40.tar.bz2
samba-f4fcf2c1c0f4fbf465afe78e2dddd04436ad1a40.zip
Re-import the v3-3 version of str_list_make().
The merged version behaves differently: "Domain Users" is parsed into two values, as it does not look at quotes. Samba3 users depend on the ability do say for example valid users = "domain users" which would not work anymore with the merged version. Thanks to Björn Jacke for testing this! Volker
-rw-r--r--source3/lib/util_str.c66
1 files changed, 59 insertions, 7 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 6fd477b537..3a941f2c21 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -2422,17 +2422,69 @@ char *escape_shell_string(const char *src)
}
/***************************************************
- Wrapper for str_list_make() to restore the s3 behavior.
- In samba 3.2 passing NULL or an empty string returned NULL.
-
- In master, it now returns a list of length 1 with the first string set
- to NULL (an empty list)
+ str_list_make, v3 version. The v4 version does not
+ look at quoted strings with embedded blanks, so
+ do NOT merge this function please!
***************************************************/
+#define S_LIST_ABS 16 /* List Allocation Block Size */
+
char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep)
{
- if (!string || !*string) {
+ char **list;
+ const char *str;
+ char *s;
+ int num, lsize;
+ char *tok;
+
+ if (!string || !*string)
+ return NULL;
+
+ list = TALLOC_ARRAY(mem_ctx, char *, S_LIST_ABS+1);
+ if (list == NULL) {
+ return NULL;
+ }
+ lsize = S_LIST_ABS;
+
+ s = talloc_strdup(list, string);
+ if (s == NULL) {
+ DEBUG(0,("str_list_make: Unable to allocate memory"));
+ TALLOC_FREE(list);
return NULL;
}
- return str_list_make(mem_ctx, string, sep);
+ if (!sep) sep = LIST_SEP;
+
+ num = 0;
+ str = s;
+
+ while (next_token_talloc(list, &str, &tok, sep)) {
+
+ if (num == lsize) {
+ char **tmp;
+
+ lsize += S_LIST_ABS;
+
+ tmp = TALLOC_REALLOC_ARRAY(mem_ctx, list, char *,
+ lsize + 1);
+ if (tmp == NULL) {
+ DEBUG(0,("str_list_make: "
+ "Unable to allocate memory"));
+ TALLOC_FREE(list);
+ return NULL;
+ }
+
+ list = tmp;
+
+ memset (&list[num], 0,
+ ((sizeof(char**)) * (S_LIST_ABS +1)));
+ }
+
+ list[num] = tok;
+ num += 1;
+ }
+
+ list[num] = NULL;
+
+ TALLOC_FREE(s);
+ return list;
}