Fix "unable to initialize" bug when smbd hasn't been run with
authorJeremy Allison <jra@samba.org>
Mon, 23 Feb 2004 20:12:31 +0000 (20:12 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 23 Feb 2004 20:12:31 +0000 (20:12 +0000)
new system and a user is being added via pdbedit/smbpasswd.
Found at Connectathon setup.
Jeremy.

source/utils/pdbedit.c
source/utils/smbpasswd.c

index 541dc33a0842ba997c0f4e8e3b9965e4146c1921..3f7aba83668f19b2498c6150d017d72a72d38404 100644 (file)
@@ -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';
 
index b43b29d0ad23559a7bfe28598193c5e06ea8b321..2f68d02ef6e592a7b658a01961a51f708478548f 100644 (file)
@@ -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