Fix for bug #445 (missing unix user on kerberos auth doesn't call add user
authorJeremy Allison <jra@samba.org>
Sat, 6 Dec 2003 02:33:59 +0000 (02:33 +0000)
committerJeremy Allison <jra@samba.org>
Sat, 6 Dec 2003 02:33:59 +0000 (02:33 +0000)
script).
Jeremy.

source/auth/auth_util.c

index 5d3f8f02777b2b120bd45b2ce65418283704aa4b..6df31b94a71d2c59ac1e4ab7c252ecc065d2f913 100644 (file)
@@ -965,7 +965,7 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
  
 struct passwd *smb_getpwnam( char *domuser )
 {
-       struct passwd *pw;
+       struct passwd *pw = NULL;
        char *p;
        fstring mapped_username;
 
@@ -981,10 +981,20 @@ struct passwd *smb_getpwnam( char *domuser )
                p += 1;
                fstrcpy( mapped_username, p );
                map_username( mapped_username );        
-               return Get_Pwnam(mapped_username);
+               pw = Get_Pwnam(mapped_username);
+               if (!pw) {
+                       /* Create local user if requested. */
+                       p = strchr( mapped_username, *lp_winbind_separator() );
+                       if (p)
+                               p += 1;
+                       else
+                               p = mapped_username;
+                       auth_add_user_script(NULL, p);
+                       return Get_Pwnam(p);
+               }
        }
 
-       return NULL;
+       return pw;
 }
 
 /***************************************************************************