The Samba-Bugzilla – Attachment 373 Details for
Bug 962
MB ']' (0x5D) problem in share name definition
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
A patch for loading smb.conf twice, once in unix charset and once in UTF-8
samba-load-twice.patch (text/plain), 6.59 KB, created by
Shiro Yamada
on 2004-01-29 21:26:48 UTC
(
hide
)
Description:
A patch for loading smb.conf twice, once in unix charset and once in UTF-8
Filename:
MIME Type:
Creator:
Shiro Yamada
Created:
2004-01-29 21:26:48 UTC
Size:
6.59 KB
patch
obsolete
>diff -uNr samba-3.0.1.org/source/param/loadparm.c samba-3.0.1/source/param/loadparm.c >--- samba-3.0.1.org/source/param/loadparm.c Tue Jan 27 13:36:43 2004 >+++ samba-3.0.1/source/param/loadparm.c Tue Jan 27 17:26:04 2004 >@@ -55,6 +55,7 @@ > > BOOL in_client = False; /* Not in the client by default */ > BOOL bLoaded = False; >+BOOL loaded_once = False; > > extern userdom_struct current_user_info; > extern pstring user_socket_options; >@@ -3258,6 +3259,9 @@ > if (!bInGlobalSection && bGlobalOnly) > return (True); > >+ if (!loaded_once && !bInGlobalSection) >+ return (True); >+ > DEBUGADD(4, ("doing parameter %s = %s\n", pszParmName, pszParmValue)); > > return (lp_do_parameter(bInGlobalSection ? -2 : iServiceIndex, >@@ -3421,6 +3425,9 @@ > if (!bInGlobalSection && bGlobalOnly) > return (True); > >+ if (!loaded_once && !bInGlobalSection) >+ return (True); >+ > /* if we have a current service, tidy it up before moving on */ > bRetval = True; > >@@ -3942,6 +3949,11 @@ > iServiceIndex = -1; > bRetval = pm_process(n2, do_section, do_parameter); > >+ init_iconv(); >+ loaded_once = True; >+ >+ bRetval = pm_process(n2, do_section, do_parameter); >+ > /* finish up the last section */ > DEBUG(4, ("pm_process() returned %s\n", BOOLSTR(bRetval))); > if (bRetval) >@@ -3968,8 +3980,6 @@ > if (in_client && Globals.bWINSsupport) { > lp_do_parameter(GLOBAL_SECTION_SNUM, "wins server", "127.0.0.1"); > } >- >- init_iconv(); > > return (bRetval); > } >diff -uNr samba-3.0.1.org/source/param/params.c samba-3.0.1/source/param/params.c >--- samba-3.0.1.org/source/param/params.c Tue Jan 27 13:36:43 2004 >+++ samba-3.0.1/source/param/params.c Tue Jan 27 17:56:57 2004 >@@ -100,6 +100,7 @@ > > static char *bufr = NULL; > static int bSize = 0; >+extern BOOL loaded_once; > > /* we can't use FILE* due to the 256 fd limit - use this cheap hack > instead */ >@@ -220,6 +221,8 @@ > int i; > int end; > const char *func = "params.c:Section() -"; >+ pstring unixshare; >+ int size; > > i = 0; /* <i> is the offset of the next free byte in bufr[] and */ > end = 0; /* <end> is the current "end of string" offset. In most */ >@@ -258,8 +261,18 @@ > DEBUG(0, ("%s Empty section name in configuration file.\n", func )); > return( False ); > } >- if( !sfunc(bufr) ) /* Got a valid name. Deal with it. */ >- return( False ); >+ if( loaded_once ) { >+ if ((size = convert_string(CH_UTF8, CH_UNIX, bufr, strlen(bufr), unixshare, sizeof(unixshare)-1)) < 0) { >+ DEBUG(0, ("Failed to convert back to the correct unix charset\n")); >+ return( False ); >+ } >+ unixshare[size] = '\0'; >+ if( !sfunc(unixshare) ) >+ return( False ); >+ } else { >+ if( !sfunc(bufr) ) /* Got a valid name. Deal with it. */ >+ return( False ); >+ } > (void)EatComment( InFile ); /* Finish off the line. */ > return( True ); > >@@ -326,6 +339,8 @@ > int end = 0; /* bufr[end] is current end-of-string. */ > int vstart = 0; /* Starting position of the parameter value. */ > const char *func = "params.c:Parameter() -"; >+ pstring paraname, paraval; >+ int name_size, val_size; > > /* Read the parameter name. */ > while( 0 == vstart ) /* Loop until we've found the start of the value. */ >@@ -441,6 +456,21 @@ > } > bufr[end] = '\0'; /* End of value. */ > >+ if (loaded_once) { >+ if ((name_size = convert_string(CH_UTF8, CH_UNIX, bufr, strlen(bufr), paraname, sizeof(paraname)-1)) < 0) { >+ DEBUG(0, ("Failed to convert back to the correct unix charset\n")); >+ return( False ); >+ } >+ paraname[name_size] = '\0'; >+ >+ if ((val_size = convert_string(CH_UTF8, CH_UNIX, &bufr[vstart], strlen(&bufr[vstart]), paraval, sizeof(paraval)-1)) < 0) { >+ DEBUG(0, ("Failed to convert back to the correct unix charset\n")); >+ return( False ); >+ } >+ paraval[val_size] = '\0'; >+ return( pfunc( paraname, paraval ) ); >+ } >+ > return( pfunc( bufr, &bufr[vstart] ) ); /* Pass name & value to pfunc(). */ > } /* Parameter */ > >@@ -556,12 +586,82 @@ > */ > { > int result; >- myFILE *InFile; >+ myFILE *InFile, *tmpFile; >+ char *current, *next, *converted, *concat; >+ size_t size, accum, allocated; > const char *func = "params.c:pm_process() -"; > > InFile = OpenConfFile( FileName ); /* Open the config file. */ > if( NULL == InFile ) > return( False ); >+ >+ if (loaded_once && InFile->size > 0) { >+ allocated = InFile->size; >+ concat = (char *)malloc(allocated+1); >+ if (!concat) { >+ DEBUG(0, ("Failed to allocate a buffer space for UTF-8 conversion\n")); >+ return( False ); >+ } >+ memset(concat, '\0', allocated+1); >+ accum = 0; >+ current = InFile->buf; >+ while ((next = strchr(current, '\n')) != NULL) { >+ *next = '\0'; >+ if ((size = convert_string_allocate(NULL, CH_UNIX, CH_UTF8, current, >+ strlen(current)+1, (void **)&converted)) < 0 || !converted) { >+ DEBUG(0, ("Failed to allocate a space for UTF-8 converted smb.conf\n")); >+ return( False ); >+ } >+ accum += size; >+ if( accum > allocated ) { >+ char *tmpbuf; >+ allocated = accum; >+ tmpbuf = Realloc(concat, allocated+1); >+ if ( NULL == tmpbuf ) { >+ DEBUG(0, ("Memory re-allocation failure.\n") ); >+ return( False ); >+ } >+ concat = tmpbuf; >+ } >+ safe_strcat(concat, converted, allocated); >+ SAFE_FREE(converted); >+ concat[accum-1] = '\n'; >+ concat[accum] = '\0'; >+ *next++ = '\n'; >+ current = next; >+ } >+ >+ if (strlen(current) > 0) { >+ if ((size = convert_string_allocate(NULL, CH_UNIX, CH_UTF8, current, >+ strlen(current)+1, (void **)&converted)) < 0 || !converted) { >+ DEBUG(0, ("Failed to allocate a space for UTF-8 converted smb.conf\n")); >+ return( False ); >+ } >+ accum += size-1; >+ if( accum > allocated ) { >+ char *tmpbuf; >+ allocated = accum; >+ tmpbuf = Realloc(concat, allocated+1); >+ if ( NULL == tmpbuf ) { >+ DEBUG(0, ("Memory re-allocation failure.\n") ); >+ return( False ); >+ } >+ concat = tmpbuf; >+ } >+ safe_strcat(concat, converted, allocated); >+ SAFE_FREE(converted); >+ } >+ >+ tmpFile = (myFILE *)malloc(sizeof(myFILE)); >+ if (!tmpFile) { >+ DEBUG(0, ("Memory re-allocation failure.\n") ); >+ return( False ); >+ } >+ tmpFile->p = tmpFile->buf = concat; >+ tmpFile->size = accum; >+ myfile_close(InFile); >+ InFile = tmpFile; >+ } > > DEBUG( 3, ("%s Processing configuration file \"%s\"\n", func, FileName) ); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 962
: 373 |
974
|
978
|
987