diff options
-rw-r--r-- | source3/auth/auth.c | 14 | ||||
-rw-r--r-- | source3/intl/lang_tdb.c | 6 | ||||
-rw-r--r-- | source3/lib/debug.c | 2 | ||||
-rw-r--r-- | source3/lib/username.c | 2 | ||||
-rw-r--r-- | source3/lib/util_str.c | 5 | ||||
-rw-r--r-- | source3/param/loadparm.c | 4 | ||||
-rw-r--r-- | source3/passdb/pdb_interface.c | 2 | ||||
-rw-r--r-- | source3/smbd/password.c | 2 | ||||
-rw-r--r-- | source3/web/neg_lang.c | 50 | ||||
-rw-r--r-- | source3/wrepld/process.c | 2 |
10 files changed, 66 insertions, 23 deletions
diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 4f7a5c24a0..dca9c6c3c4 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -395,33 +395,33 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) { case SEC_DOMAIN: DEBUG(5,("Making default auth method list for security=domain\n")); - auth_method_list = str_list_make("guest sam ntdomain"); + auth_method_list = str_list_make("guest sam ntdomain", NULL); break; case SEC_SERVER: DEBUG(5,("Making default auth method list for security=server\n")); - auth_method_list = str_list_make("guest sam smbserver"); + auth_method_list = str_list_make("guest sam smbserver", NULL); break; case SEC_USER: if (lp_encrypted_passwords()) { DEBUG(5,("Making default auth method list for security=user, encrypt passwords = yes\n")); - auth_method_list = str_list_make("guest sam"); + auth_method_list = str_list_make("guest sam", NULL); } else { DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n")); - auth_method_list = str_list_make("guest unix"); + auth_method_list = str_list_make("guest unix", NULL); } break; case SEC_SHARE: if (lp_encrypted_passwords()) { DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n")); - auth_method_list = str_list_make("guest sam"); + auth_method_list = str_list_make("guest sam", NULL); } else { DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n")); - auth_method_list = str_list_make("guest unix"); + auth_method_list = str_list_make("guest unix", NULL); } break; case SEC_ADS: DEBUG(5,("Making default auth method list for security=ADS\n")); - auth_method_list = str_list_make("guest sam ads ntdomain"); + auth_method_list = str_list_make("guest sam ads ntdomain", NULL); break; default: DEBUG(5,("Unknown auth method!\n")); diff --git a/source3/intl/lang_tdb.c b/source3/intl/lang_tdb.c index d5e8bd41bd..a86ea0a3f9 100644 --- a/source3/intl/lang_tdb.c +++ b/source3/intl/lang_tdb.c @@ -106,8 +106,10 @@ BOOL lang_tdb_init(const char *lang) if (initialised) { /* we are re-initialising, free up any old init */ - tdb_close(tdb); - tdb = NULL; + if (tdb) { + tdb_close(tdb); + tdb = NULL; + } SAFE_FREE(current_lang); } diff --git a/source3/lib/debug.c b/source3/lib/debug.c index be5f66a562..842d2dac1d 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -423,7 +423,7 @@ BOOL debug_parse_levels(const char *params_str) if (AllowDebugChange == False) return True; - params = str_list_make(params_str); + params = str_list_make(params_str, NULL); if (debug_parse_params(params, DEBUGLEVEL_CLASS, DEBUGLEVEL_CLASS_ISSET)) diff --git a/source3/lib/username.c b/source3/lib/username.c index 4813c8fd19..5db7f58b1e 100644 --- a/source3/lib/username.c +++ b/source3/lib/username.c @@ -163,7 +163,7 @@ BOOL map_username(char *user) } } - dosuserlist = str_list_make(dosname); + dosuserlist = str_list_make(dosname, NULL); if (!dosuserlist) { DEBUG(0,("Unable to build user list\n")); return False; diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 7e974269ec..9dc80c89db 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1125,7 +1125,7 @@ some platforms don't have strnlen #define S_LIST_ABS 16 /* List Allocation Block Size */ -char **str_list_make(const char *string) +char **str_list_make(const char *string, const char *sep) { char **list, **rlist; char *str, *s; @@ -1139,12 +1139,13 @@ char **str_list_make(const char *string) DEBUG(0,("str_list_make: Unable to allocate memory")); return NULL; } + if (!sep) sep = LIST_SEP; num = lsize = 0; list = NULL; str = s; - while (next_token(&str, tok, LIST_SEP, sizeof(tok))) { + while (next_token(&str, tok, sep, sizeof(tok))) { if (num == lsize) { lsize += S_LIST_ABS; rlist = (char **)Realloc(list, ((sizeof(char **)) * (lsize +1))); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 445663f547..64542cd153 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1194,7 +1194,7 @@ static void init_globals(void) string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE); string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR); - Globals.szPassdbBackend = str_list_make("smbpasswd unixsam"); + Globals.szPassdbBackend = str_list_make("smbpasswd unixsam", NULL); /* use the new 'hash2' method by default */ string_set(&Globals.szManglingMethod, "hash2"); @@ -2850,7 +2850,7 @@ BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue) break; case P_LIST: - *(char ***)parm_ptr = str_list_make(pszParmValue); + *(char ***)parm_ptr = str_list_make(pszParmValue, NULL); break; case P_STRING: diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 3b0f54b2b3..daa3222c5a 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -353,7 +353,7 @@ NTSTATUS make_pdb_context_list(struct pdb_context **context, char **selected) NTSTATUS make_pdb_context_string(struct pdb_context **context, const char *selected) { NTSTATUS ret; - char **newsel = str_list_make(selected); + char **newsel = str_list_make(selected, NULL); ret = make_pdb_context_list(context, newsel); str_list_free(&newsel); return ret; diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 391de02dea..2558ffe163 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -351,7 +351,7 @@ BOOL user_ok(const char *user,int snum) if (valid) str_list_free (&valid); if (ret && lp_onlyuser(snum)) { - char **user_list = str_list_make (lp_username(snum)); + char **user_list = str_list_make (lp_username(snum), NULL); if (user_list && str_list_substitute(user_list, "%S", lp_servicename(snum))) { ret = user_in_list(user, user_list); } diff --git a/source3/web/neg_lang.c b/source3/web/neg_lang.c index 88bc5498e9..72dd70fd98 100644 --- a/source3/web/neg_lang.c +++ b/source3/web/neg_lang.c @@ -52,14 +52,54 @@ int web_open(const char *fname, int flags, mode_t mode) choose from a list of languages. The list can be comma or space separated Keep choosing until we get a hit + Changed to habdle priority -- Simo */ -void web_set_lang(const char *lang_list) +void web_set_lang(const char *lang_string) { - fstring lang; - char *p = (char *)lang_list; + char **lang_list, **count; + float *pri; + int lang_num, i; + + /* build the lang list */ + lang_list = str_list_make(lang_string, ", \t\r\n"); + if (!lang_list) return; - while (next_token(&p, lang, ", \t\r\n", sizeof(lang))) { - if (lang_tdb_init(lang)) return; + /* sort the list by priority */ + lang_num = 0; + count = lang_list; + while (*count && **count) { + count++; + lang_num++; + } + pri = (float *)malloc(sizeof(float) * lang_num); + for (i = 0; i < lang_num; i++) { + char *pri_code; + if ((pri_code=strstr(lang_list[i], ";q="))) { + *pri_code = '\0'; + pri_code += 3; + pri[i] = strtof(pri_code, NULL); + } else { + pri[i] = 1; + } + if (i != 0) { + int l; + for (l = i; l > 0; l--) { + if (pri[l] > pri[l-1]) { + char *tempc; + int tempf; + tempc = lang_list[l]; + tempf = pri[l]; + lang_list[l] = lang_list[l-1]; + pri[i] = pri[l-1]; + lang_list[l-1] = tempc; + pri[l-1] = tempf; + } + } + } + } + + for (i = 0; i < lang_num; i++) { + if (lang_tdb_init(lang_list[i])) return; } /* it's not an error to not initialise - we just fall back to diff --git a/source3/wrepld/process.c b/source3/wrepld/process.c index 7615b8c78a..56013d2e17 100644 --- a/source3/wrepld/process.c +++ b/source3/wrepld/process.c @@ -152,7 +152,7 @@ initialise and fill the in-memory partner table. int init_wins_partner_table(void) { int i=1,j=0,k; - char **partner = str_list_make(lp_wins_partners()); + char **partner = str_list_make(lp_wins_partners(), NULL); if (partner==NULL) { DEBUG(0,("wrepld: no partner list in smb.conf, exiting\n")); |