From aa4abfb3b589bf5123b5d0d674c3c26ebdabe1a0 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 23 Feb 2004 20:12:31 +0000 Subject: Fix "unable to initialize" bug when smbd hasn't been run with new system and a user is being added via pdbedit/smbpasswd. Found at Connectathon setup. Jeremy. (This used to be commit f9c7a42e895f50e15d2f5079bfb2cb389fdf2df4) --- source3/utils/pdbedit.c | 4 ++++ source3/utils/smbpasswd.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 541dc33a08..3f7aba8366 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -398,6 +398,8 @@ static int new_user (struct pdb_context *in, const char *username, NTSTATUS nt_status; char *password1, *password2, *staticpass; + get_global_sam_sid(); + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_new(&sam_pwent, username, 0))) { DEBUG(0, ("could not create account to add new user %s\n", username)); return -1; @@ -490,6 +492,8 @@ static int new_machine (struct pdb_context *in, const char *machine_in) fstring machineaccount; struct passwd *pwd = NULL; + get_global_sam_sid(); + fstrcpy(machinename, machine_in); machinename[15]= '\0'; diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index b43b29d0ad..2f68d02ef6 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -341,8 +341,7 @@ static int process_root(int local_flags) int result = 0; char *old_passwd = NULL; - if (local_flags & LOCAL_SET_LDAP_ADMIN_PW) - { + if (local_flags & LOCAL_SET_LDAP_ADMIN_PW) { printf("Setting stored password for \"%s\" in secrets.tdb\n", lp_ldap_admin_dn()); if (!store_ldap_admin_pw(ldap_secret)) @@ -350,6 +349,9 @@ static int process_root(int local_flags) goto done; } + /* Ensure we have a SAM sid. */ + get_global_sam_sid(); + /* * Ensure both add/delete user are not set * Ensure add/delete user and either remote machine or join domain are -- cgit