diff options
-rw-r--r-- | source3/lib/util_sid.c | 4 | ||||
-rw-r--r-- | source3/param/loadparm.c | 8 | ||||
-rw-r--r-- | source3/passdb/passdb.c | 2 | ||||
-rw-r--r-- | source3/passdb/pdb_get_set.c | 22 | ||||
-rw-r--r-- | source3/passdb/pdb_interface.c | 49 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 22 |
6 files changed, 61 insertions, 46 deletions
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index ca9ebb14d2..b27040b658 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -119,7 +119,7 @@ void split_domain_name(const char *fullname, char *domain, char *name) Convert a SID to an ascii string. *****************************************************************/ -char *sid_to_string(fstring sidstr_out, DOM_SID *sid) +char *sid_to_string(fstring sidstr_out, const DOM_SID *sid) { char subauth[16]; int i; @@ -149,7 +149,7 @@ char *sid_to_string(fstring sidstr_out, DOM_SID *sid) /* useful function for debug lines */ -const char *sid_string_static(DOM_SID *sid) +const char *sid_string_static(const DOM_SID *sid) { static fstring sid_str; sid_to_string(sid_str, sid); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6ad2c32628..2507e8a798 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -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.szLogFile) 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, &Globals.szSocketAddress) 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) diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index fa1bb4b2d9..dd951c02ac 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -184,7 +184,7 @@ NTSTATUS pdb_fill_sam_pw(SAM_ACCOUNT *sam_account, const struct passwd *pwd) */ if (!pdb_set_user_sid_from_rid(sam_account, - fallback_pdb_uid_to_user_rid(pwd->pw_uid))) { + fallback_pdb_uid_to_user_rid(pwd->pw_uid))) { DEBUG(0,("Can't set User SID from RID!\n")); return NT_STATUS_INVALID_PARAMETER; } diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index 0b5a1053ae..980850b89c 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -177,7 +177,7 @@ uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass) uint32 u_rid; if (sampass) - if (sid_peek_check_rid(get_global_sam_sid(), (DOM_SID *) pdb_get_user_sid(sampass),&u_rid)) + if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_user_sid(sampass),&u_rid)) return u_rid; return (-1); @@ -188,7 +188,7 @@ uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass) uint32 g_rid; if (sampass) - if (sid_peek_check_rid(get_global_sam_sid(), (DOM_SID *) pdb_get_group_sid(sampass),&g_rid)) + if (sid_peek_check_rid(get_global_sam_sid(), pdb_get_group_sid(sampass),&g_rid)) return g_rid; return (-1); } @@ -537,11 +537,17 @@ BOOL pdb_set_group_sid(SAM_ACCOUNT *sampass, DOM_SID *g_sid) BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid) { DOM_SID u_sid; - + const DOM_SID *global_sam_sid; + if (!sampass) return False; - sid_copy(&u_sid, get_global_sam_sid()); + if (!(global_sam_sid = get_global_sam_sid())) { + DEBUG(1, ("pdb_set_user_sid_from_rid: Could not read global sam sid!\n")); + return False; + } + + sid_copy(&u_sid, global_sam_sid); if (!sid_append_rid(&u_sid, rid)) return False; @@ -558,11 +564,17 @@ BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid) BOOL pdb_set_group_sid_from_rid (SAM_ACCOUNT *sampass, uint32 grid) { DOM_SID g_sid; + const DOM_SID *global_sam_sid; if (!sampass) return False; - sid_copy(&g_sid, get_global_sam_sid()); + if (!(global_sam_sid = get_global_sam_sid())) { + DEBUG(1, ("pdb_set_user_sid_from_rid: Could not read global sam sid!\n")); + return False; + } + + sid_copy(&g_sid, global_sam_sid); if (!sid_append_rid(&g_sid, grid)) return False; diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index d8f69e56b1..7ecc237cf4 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -314,14 +314,12 @@ static NTSTATUS make_pdb_context(struct pdb_context **context) /****************************************************************** - 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 pdb_context **context, const char *selecte 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_static_context(BOOL reload) 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; } } diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index ed7f648f2d..bc50c3521a 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -34,7 +34,7 @@ int export_database (struct pdb_context *in, char *db){ 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; } @@ -76,7 +76,7 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst if (!sam_pwent) return -1; if (verbosity) { - printf ("Unix username: %s\n", pdb_get_username(sam_pwent)); + printf ("Unix username: %s\n", pdb_get_username(sam_pwent)); printf ("NT username: %s\n", pdb_get_nt_username(sam_pwent)); if (IS_SAM_UNIX_USER(sam_pwent)) { uid = pdb_get_uid(sam_pwent); @@ -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) { |