mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
Patch from ctrlsoft to make the pluggable passdb subsystem use an lp_list
rather than a string when configuring mulitple backends.
Also adjust some of the users of get_global_sam_sid() to cope with the fact
that it just might not exist (uninitialised, can't access secrets.tdb).
More places need conversion.
Add some const and remove silly casts.
Andrew Bartlett
(This used to be commit c264bf2ec9
)
This commit is contained in:
parent
0886638844
commit
0d7ac4bc2c
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user