summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-11-22 04:33:36 +0000
committerGerald Carter <jerry@samba.org>2003-11-22 04:33:36 +0000
commit11f4893145f94c85b4f1268544a84116d3a38751 (patch)
tree72b5add6f724e945ddbb05a04bdd7bdb0d2d03cc
parentd66def408ea394fe6475e87cd2405173eb7c8c8c (diff)
downloadsamba-11f4893145f94c85b4f1268544a84116d3a38751.tar.gz
samba-11f4893145f94c85b4f1268544a84116d3a38751.tar.bz2
samba-11f4893145f94c85b4f1268544a84116d3a38751.zip
Ensure that items in a list of strings containing whitespace
are written out surrounded by single quotes. This means that both double and single quotes are now used to surround strings in smb.conf. This is a slight change from the previous behavior but needed or else things like printer admin = +ntadmin, 'VALE\Domain, Admin' get written to smb.conf by SWAT. (This used to be commit 5bf91c79d620e34ac71d72c80f74e47754d49dcb)
-rw-r--r--source3/lib/util_str.c2
-rw-r--r--source3/param/loadparm.c10
-rw-r--r--source3/web/swat.c12
3 files changed, 18 insertions, 6 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index d2b64aff2e..2928584b8a 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -62,7 +62,7 @@ BOOL next_token(const char **ptr,char *buff, const char *sep, size_t bufsize)
/* copy over the token */
pbuf = buff;
for (quoted = False; len < bufsize && *s && (quoted || !strchr_m(sep,*s)); s++) {
- if (*s == '\"') {
+ if (*s == '\"' || *s == '\'') {
quoted = !quoted;
} else {
len++;
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 8643ecb028..e98d924964 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3301,9 +3301,13 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
- for (; *list; list++)
- fprintf(f, "%s%s", *list,
- ((*(list+1))?", ":""));
+ for (; *list; list++) {
+ /* surround strings with whitespace in single quotes */
+ if ( strchr_m( *list, ' ' ) )
+ fprintf(f, "\'%s\'%s", *list, ((*(list+1))?", ":""));
+ else
+ fprintf(f, "%s%s", *list, ((*(list+1))?", ":""));
+ }
}
break;
diff --git a/source3/web/swat.c b/source3/web/swat.c
index f4046b46a2..1faef46e25 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -212,7 +212,11 @@ static void show_parameter(int snum, struct parm_struct *parm)
if ((char ***)ptr && *(char ***)ptr && **(char ***)ptr) {
char **list = *(char ***)ptr;
for (;*list;list++) {
- d_printf("%s%s", *list, ((*(list+1))?" ":""));
+ /* enclose in quotes if the string contains a space */
+ if ( strchr_m(*list, ' ') )
+ d_printf("\'%s\'%s", *list, ((*(list+1))?", ":""));
+ else
+ d_printf("%s%s", *list, ((*(list+1))?", ":""));
}
}
d_printf("\">");
@@ -221,7 +225,11 @@ static void show_parameter(int snum, struct parm_struct *parm)
if (parm->def.lvalue) {
char **list = (char **)(parm->def.lvalue);
for (; *list; list++) {
- d_printf("%s%s", *list, ((*(list+1))?" ":""));
+ /* enclose in quotes if the string contains a space */
+ if ( strchr_m(*list, ' ') )
+ d_printf("\'%s\'%s", *list, ((*(list+1))?", ":""));
+ else
+ d_printf("%s%s", *list, ((*(list+1))?", ":""));
}
}
d_printf("\'\">");