summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-11-22 04:35:36 +0000
committerGerald Carter <jerry@samba.org>2003-11-22 04:35:36 +0000
commit59e9d6e301c752e99fb6a50204d7941f7f84566a (patch)
tree9d879ed59d261cedb85a5cd6a89f859b1b714478 /source
parentf68c2ff0f3307612ddbe62b8cc2ea12251d54ec6 (diff)
downloadsamba-59e9d6e301c752e99fb6a50204d7941f7f84566a.tar.gz
samba-59e9d6e301c752e99fb6a50204d7941f7f84566a.tar.xz
samba-59e9d6e301c752e99fb6a50204d7941f7f84566a.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.
Diffstat (limited to 'source')
-rw-r--r--source/lib/util_str.c2
-rw-r--r--source/param/loadparm.c10
-rw-r--r--source/web/swat.c12
3 files changed, 18 insertions, 6 deletions
diff --git a/source/lib/util_str.c b/source/lib/util_str.c
index aa50b07f61c..1aa33a1a4be 100644
--- a/source/lib/util_str.c
+++ b/source/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/source/param/loadparm.c b/source/param/loadparm.c
index 8e6064ab59f..b124c6fd3bb 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -3310,9 +3310,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/source/web/swat.c b/source/web/swat.c
index f4046b46a26..1faef46e254 100644
--- a/source/web/swat.c
+++ b/source/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("\'\">");