Hi, Here's my latest patch for today :-). This one brings:
- convert lp_passdb_backend() parameter to a list - fix bug in sid_copy(), which crashed whenever a NULL pointer was given as an argument. (sometimes caused errors when user doesn't have access to secrets.tdb) Good night! Jelmer -- Jelmer Vernooij <[EMAIL PROTECTED]> - http://nl.linux.org/~jelmer/ Development And Underdevelopment: http://library.thinkquest.org/C0110231/ 22:46:59 up 3:03, 7 users, load average: 0.44, 0.45, 0.27
Index: source/lib/util_sid.c
===================================================================
RCS file: /cvsroot/samba/source/lib/util_sid.c,v
retrieving revision 1.51
diff -u -3 -p -r1.51 util_sid.c
--- source/lib/util_sid.c 13 Jun 2002 14:06:07 -0000 1.51
+++ source/lib/util_sid.c 13 Jun 2002 20:50:33 -0000
@@ -287,12 +287,16 @@ BOOL sid_peek_check_rid(DOM_SID *exp_dom
Copies a sid
*****************************************************************/
-void sid_copy(DOM_SID *dst, const DOM_SID *src)
+BOOL sid_copy(DOM_SID *dst, const DOM_SID *src)
{
int i;
+ if (!dst) return False;
+
memset((char *)dst, '\0', sizeof(DOM_SID));
+ if (!src) return False;
+
dst->sid_rev_num = src->sid_rev_num;
dst->num_auths = src->num_auths;
@@ -300,6 +304,8 @@ void sid_copy(DOM_SID *dst, const DOM_SI
for (i = 0; i < src->num_auths; i++)
dst->sub_auths[i] = src->sub_auths[i];
+
+ return True;
}
/*****************************************************************
Index: source/param/loadparm.c
===================================================================
RCS file: /cvsroot/samba/source/param/loadparm.c,v
retrieving revision 1.410
diff -u -3 -p -r1.410 loadparm.c
--- source/param/loadparm.c 11 Jun 2002 22:54:06 -0000 1.410
+++ source/param/loadparm.c 13 Jun 2002 20:50:35 -0000
@@ -110,7 +110,7 @@ typedef struct
char *szConfigFile;
char *szSMBPasswdFile;
char *szPrivateDir;
- char *szPassdbBackend;
+ char **szPassdbBackend;
char *szPasswordServer;
char *szSocketOptions;
char *szWorkGroup;
@@ -690,7 +690,7 @@ static struct parm_struct parm_table[] =
{"password server", P_STRING, P_GLOBAL, &Globals.szPasswordServer, NULL, NULL,
0},
{"smb passwd file", P_STRING, P_GLOBAL, &Globals.szSMBPasswdFile, NULL, NULL,
0},
{"private dir", P_STRING, P_GLOBAL, &Globals.szPrivateDir, NULL, NULL, 0},
- {"passdb backend", P_STRING, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL,
0},
+ {"passdb backend", P_LIST, P_GLOBAL, &Globals.szPassdbBackend, NULL, NULL, 0},
{"non unix account range", P_STRING, P_GLOBAL, &Globals.szNonUnixAccountRange,
handle_non_unix_account_range, NULL, 0},
{"algorithmic rid base", P_INTEGER, P_GLOBAL, &Globals.bAlgorithmicRidBase,
NULL, NULL, 0},
{"root directory", P_STRING, P_GLOBAL, &Globals.szRootdir, NULL, NULL, 0},
@@ -1186,7 +1186,7 @@ static void init_globals(void)
string_set(&Globals.szSMBPasswdFile, dyn_SMB_PASSWD_FILE);
string_set(&Globals.szPrivateDir, dyn_PRIVATE_DIR);
- string_set(&Globals.szPassdbBackend, "smbpasswd unixsam");
+ Globals.szPassdbBackend = lp_list_make("smbpasswd unixsam");
/* use the new 'hash2' method by default */
string_set(&Globals.szManglingMethod, "hash2");
@@ -1446,7 +1446,6 @@ FN_GLOBAL_STRING(lp_logfile, &Globals.sz
FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
-FN_GLOBAL_STRING(lp_passdb_backend, &Globals.szPassdbBackend)
FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
@@ -1488,6 +1487,7 @@ FN_GLOBAL_STRING(lp_socket_address, &Glo
FN_GLOBAL_STRING(lp_nis_home_map_name, &Globals.szNISHomeMapName)
static FN_GLOBAL_STRING(lp_announce_version, &Globals.szAnnounceVersion)
FN_GLOBAL_LIST(lp_netbios_aliases, &Globals.szNetbiosAliases)
+FN_GLOBAL_LIST(lp_passdb_backend, &Globals.szPassdbBackend)
FN_GLOBAL_STRING(lp_panic_action, &Globals.szPanicAction)
FN_GLOBAL_STRING(lp_adduser_script, &Globals.szAddUserScript)
FN_GLOBAL_STRING(lp_deluser_script, &Globals.szDelUserScript)
Index: source/passdb/pdb_interface.c
===================================================================
RCS file: /cvsroot/samba/source/passdb/pdb_interface.c,v
retrieving revision 1.16
diff -u -3 -p -r1.16 pdb_interface.c
--- source/passdb/pdb_interface.c 26 May 2002 19:11:52 -0000 1.16
+++ source/passdb/pdb_interface.c 13 Jun 2002 20:50:35 -0000
@@ -314,14 +314,12 @@ static NTSTATUS make_pdb_context(struct
/******************************************************************
- Make a pdb_context, given a text string.
+ Make a pdb_context, given an array of strings
*******************************************************************/
-NTSTATUS make_pdb_context_name(struct pdb_context **context, const char *selected)
+NTSTATUS make_pdb_context_list(struct pdb_context **context, char **selected)
{
- /* HINT: Don't store 'selected' becouse its often an lp_ string and will 'go
away' */
- char *conf = smb_xstrdup(selected);
- char *confcur = conf, *confnext;
+ int i = 0;
struct pdb_methods *curmethods, *tmpmethods;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
@@ -329,31 +327,34 @@ NTSTATUS make_pdb_context_name(struct pd
return nt_status;
}
- while(confcur){
- if(strchr(confcur, ' ')){
- confnext = strchr(confcur,' ');
- *confnext = '\0';
- confnext++;
- }else confnext = NULL;
-
+ while(selected[i]){
/* Try to initialise pdb */
- DEBUG(5,("Trying to load: %s\n", confcur));
- if(!NT_STATUS_IS_OK(make_pdb_methods_name(&curmethods, *context,
confcur))){
- DEBUG(5, ("Loading %s failed!\n", confcur));
+ DEBUG(5,("Trying to load: %s\n", selected[i]));
+ if(!NT_STATUS_IS_OK(nt_status = make_pdb_methods_name(&curmethods,
+*context, selected[i]))){
+ DEBUG(5, ("Loading %s failed!\n", selected[i]));
SAFE_FREE(curmethods);
- continue;
+ free_pdb_context(context);
+ return nt_status;
}
curmethods->parent = *context;
DLIST_ADD_END((*context)->pdb_methods, curmethods, tmpmethods);
-
- if(!confnext)break;
- confcur = confnext;
+ i++;
}
- SAFE_FREE(conf);
- nt_status = NT_STATUS_OK;
+ return NT_STATUS_OK;
+}
- return nt_status;
+/******************************************************************
+ Make a pdb_context, given a text string.
+ *******************************************************************/
+
+NTSTATUS make_pdb_context_string(struct pdb_context **context, const char *selected)
+{
+ NTSTATUS ret;
+ char **newsel = lp_list_make(selected);
+ ret = make_pdb_context_list(context, newsel);
+ lp_list_free(&newsel);
+ return ret;
}
/******************************************************************
@@ -367,13 +368,13 @@ static struct pdb_context *pdb_get_stati
if ((pdb_context) && (reload)) {
pdb_context->free_fn(&pdb_context);
- if (!NT_STATUS_IS_OK(make_pdb_context_name(&pdb_context,
lp_passdb_backend()))) {
+ if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context,
+lp_passdb_backend()))) {
return NULL;
}
}
if (!pdb_context) {
- if (!NT_STATUS_IS_OK(make_pdb_context_name(&pdb_context,
lp_passdb_backend()))) {
+ if (!NT_STATUS_IS_OK(make_pdb_context_list(&pdb_context,
+lp_passdb_backend()))) {
return NULL;
}
}
Index: source/utils/pdbedit.c
===================================================================
RCS file: /cvsroot/samba/source/utils/pdbedit.c,v
retrieving revision 1.47
diff -u -3 -p -r1.47 pdbedit.c
--- source/utils/pdbedit.c 13 Jun 2002 14:06:08 -0000 1.47
+++ source/utils/pdbedit.c 13 Jun 2002 20:50:35 -0000
@@ -34,7 +34,7 @@ int export_database (struct pdb_context
struct pdb_context *context;
SAM_ACCOUNT *user = NULL;
- if (!NT_STATUS_IS_OK(make_pdb_context_name(&context, db))){
+ if (!NT_STATUS_IS_OK(make_pdb_context_string(&context, db))){
fprintf(stderr, "Can't initialize %s.\n", db);
return 1;
}
@@ -457,10 +457,6 @@ int main (int argc, char **argv)
}
- if (!backend_in) {
- backend_in = lp_passdb_backend();
- }
-
setparms = (full_name || home_dir || home_drive || logon_script ||
profile_path);
if (((add_user?1:0) + (delete_user?1:0) + (list_users?1:0) + (import?1:0) +
(setparms?1:0)) + (backend_out?1:0) > 1) {
@@ -468,10 +464,16 @@ int main (int argc, char **argv)
exit(1);
}
-
- if (!NT_STATUS_IS_OK(make_pdb_context_name(&in, backend_in))){
- fprintf(stderr, "Can't initialize %s.\n", backend_in);
- return 1;
+ if (!backend_in) {
+ if (!NT_STATUS_IS_OK(make_pdb_context_list(&in, lp_passdb_backend()))){
+ fprintf(stderr, "Can't initialize passdb backend.\n");
+ return 1;
+ }
+ } else {
+ if (!NT_STATUS_IS_OK(make_pdb_context_string(&in, backend_in))){
+ fprintf(stderr, "Can't initialize passdb backend.\n");
+ return 1;
+ }
}
if (add_user) {
msg01411/pgp00000.pgp
Description: PGP signature
