r13571: Replace all calls to talloc_free() with thye TALLOC_FREE()
[ira/wip.git] / source3 / smbd / password.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Password and authentication handling
4    Copyright (C) Andrew Tridgell 1992-1998
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "includes.h"
22
23 /* users from session setup */
24 static char *session_userlist = NULL;
25 static int len_session_userlist = 0;
26
27 /* this holds info on user ids that are already validated for this VC */
28 static user_struct *validated_users;
29 static int next_vuid = VUID_OFFSET;
30 static int num_validated_vuids;
31
32 extern userdom_struct current_user_info;
33
34
35 /****************************************************************************
36  Check if a uid has been validated, and return an pointer to the user_struct
37  if it has. NULL if not. vuid is biased by an offset. This allows us to
38  tell random client vuid's (normally zero) from valid vuids.
39 ****************************************************************************/
40
41 user_struct *get_valid_user_struct(uint16 vuid)
42 {
43         user_struct *usp;
44         int count=0;
45
46         if (vuid == UID_FIELD_INVALID)
47                 return NULL;
48
49         for (usp=validated_users;usp;usp=usp->next,count++) {
50                 if (vuid == usp->vuid && usp->server_info) {
51                         if (count > 10) {
52                                 DLIST_PROMOTE(validated_users, usp);
53                         }
54                         return usp;
55                 }
56         }
57
58         return NULL;
59 }
60
61 /****************************************************************************
62  Get the user struct of a partial NTLMSSP login
63 ****************************************************************************/
64
65 user_struct *get_partial_auth_user_struct(uint16 vuid)
66 {
67         user_struct *usp;
68         int count=0;
69
70         if (vuid == UID_FIELD_INVALID)
71                 return NULL;
72
73         for (usp=validated_users;usp;usp=usp->next,count++) {
74                 if (vuid == usp->vuid && !usp->server_info) {
75                         if (count > 10) {
76                                 DLIST_PROMOTE(validated_users, usp);
77                         }
78                         return usp;
79                 }
80         }
81
82         return NULL;
83 }
84
85 /****************************************************************************
86  Invalidate a uid.
87 ****************************************************************************/
88
89 void invalidate_vuid(uint16 vuid)
90 {
91         user_struct *vuser = get_valid_user_struct(vuid);
92
93         if (vuser == NULL)
94                 return;
95         
96         SAFE_FREE(vuser->homedir);
97         SAFE_FREE(vuser->unix_homedir);
98         SAFE_FREE(vuser->logon_script);
99         
100         session_yield(vuser);
101         SAFE_FREE(vuser->session_keystr);
102
103         TALLOC_FREE(vuser->server_info);
104
105         data_blob_free(&vuser->session_key);
106
107         DLIST_REMOVE(validated_users, vuser);
108
109         /* clear the vuid from the 'cache' on each connection, and
110            from the vuid 'owner' of connections */
111         conn_clear_vuid_cache(vuid);
112
113         SAFE_FREE(vuser->groups);
114         TALLOC_FREE(vuser->nt_user_token);
115         SAFE_FREE(vuser);
116         num_validated_vuids--;
117 }
118
119 /****************************************************************************
120  Invalidate all vuid entries for this process.
121 ****************************************************************************/
122
123 void invalidate_all_vuids(void)
124 {
125         user_struct *usp, *next=NULL;
126
127         for (usp=validated_users;usp;usp=next) {
128                 next = usp->next;
129                 
130                 invalidate_vuid(usp->vuid);
131         }
132 }
133
134 /**
135  *  register that a valid login has been performed, establish 'session'.
136  *  @param server_info The token returned from the authentication process. 
137  *   (now 'owned' by register_vuid)
138  *
139  *  @param session_key The User session key for the login session (now also
140  *  'owned' by register_vuid)
141  *
142  *  @param respose_blob The NT challenge-response, if available.  (May be
143  *  freed after this call)
144  *
145  *  @param smb_name The untranslated name of the user
146  *
147  *  @return Newly allocated vuid, biased by an offset. (This allows us to
148  *   tell random client vuid's (normally zero) from valid vuids.)
149  *
150  */
151
152 int register_vuid(auth_serversupplied_info *server_info,
153                   DATA_BLOB session_key, DATA_BLOB response_blob,
154                   const char *smb_name)
155 {
156         user_struct *vuser = NULL;
157
158         /* Ensure no vuid gets registered in share level security. */
159         if(lp_security() == SEC_SHARE) {
160                 data_blob_free(&session_key);
161                 return UID_FIELD_INVALID;
162         }
163
164         /* Limit allowed vuids to 16bits - VUID_OFFSET. */
165         if (num_validated_vuids >= 0xFFFF-VUID_OFFSET) {
166                 data_blob_free(&session_key);
167                 return UID_FIELD_INVALID;
168         }
169
170         if((vuser = SMB_MALLOC_P(user_struct)) == NULL) {
171                 DEBUG(0,("Failed to malloc users struct!\n"));
172                 data_blob_free(&session_key);
173                 return UID_FIELD_INVALID;
174         }
175
176         ZERO_STRUCTP(vuser);
177
178         /* Allocate a free vuid. Yes this is a linear search... :-) */
179         while( get_valid_user_struct(next_vuid) != NULL ) {
180                 next_vuid++;
181                 /* Check for vuid wrap. */
182                 if (next_vuid == UID_FIELD_INVALID)
183                         next_vuid = VUID_OFFSET;
184         }
185
186         DEBUG(10,("register_vuid: allocated vuid = %u\n",
187                   (unsigned int)next_vuid ));
188
189         vuser->vuid = next_vuid;
190
191         if (!server_info) {
192                 next_vuid++;
193                 num_validated_vuids++;
194                 
195                 vuser->server_info = NULL;
196                 
197                 DLIST_ADD(validated_users, vuser);
198                 
199                 return vuser->vuid;
200         }
201
202         /* the next functions should be done by a SID mapping system (SMS) as
203          * the new real sam db won't have reference to unix uids or gids
204          */
205         
206         vuser->uid = server_info->uid;
207         vuser->gid = server_info->gid;
208         
209         vuser->n_groups = server_info->n_groups;
210         if (vuser->n_groups) {
211                 if (!(vuser->groups = (gid_t *)memdup(server_info->groups,
212                                                       sizeof(gid_t) *
213                                                       vuser->n_groups))) {
214                         DEBUG(0,("register_vuid: failed to memdup "
215                                  "vuser->groups\n"));
216                         data_blob_free(&session_key);
217                         free(vuser);
218                         TALLOC_FREE(server_info);
219                         return UID_FIELD_INVALID;
220                 }
221         }
222
223         vuser->guest = server_info->guest;
224         fstrcpy(vuser->user.unix_name, server_info->unix_name); 
225
226         /* This is a potentially untrusted username */
227         alpha_strcpy(vuser->user.smb_name, smb_name, ". _-$",
228                      sizeof(vuser->user.smb_name));
229
230         fstrcpy(vuser->user.domain, pdb_get_domain(server_info->sam_account));
231         fstrcpy(vuser->user.full_name,
232                 pdb_get_fullname(server_info->sam_account));
233
234         {
235                 /* Keep the homedir handy */
236                 const char *homedir =
237                         pdb_get_homedir(server_info->sam_account);
238                 const char *logon_script =
239                         pdb_get_logon_script(server_info->sam_account);
240
241                 if (!IS_SAM_DEFAULT(server_info->sam_account,
242                                     PDB_UNIXHOMEDIR)) {
243                         const char *unix_homedir =
244                                 pdb_get_unix_homedir(server_info->sam_account);
245                         if (unix_homedir) {
246                                 vuser->unix_homedir =
247                                         smb_xstrdup(unix_homedir);
248                         }
249                 } else {
250                         struct passwd *passwd =
251                                 getpwnam_alloc(NULL, vuser->user.unix_name);
252                         if (passwd) {
253                                 vuser->unix_homedir =
254                                         smb_xstrdup(passwd->pw_dir);
255                                 TALLOC_FREE(passwd);
256                         }
257                 }
258                 
259                 if (homedir) {
260                         vuser->homedir = smb_xstrdup(homedir);
261                 }
262                 if (logon_script) {
263                         vuser->logon_script = smb_xstrdup(logon_script);
264                 }
265         }
266
267         vuser->session_key = session_key;
268
269         DEBUG(10,("register_vuid: (%u,%u) %s %s %s guest=%d\n", 
270                   (unsigned int)vuser->uid, 
271                   (unsigned int)vuser->gid,
272                   vuser->user.unix_name, vuser->user.smb_name,
273                   vuser->user.domain, vuser->guest ));
274
275         DEBUG(3, ("User name: %s\tReal name: %s\n", vuser->user.unix_name,
276                   vuser->user.full_name));      
277
278         if (server_info->ptok) {
279                 vuser->nt_user_token = dup_nt_token(NULL, server_info->ptok);
280         } else {
281                 DEBUG(1, ("server_info does not contain a user_token - "
282                           "cannot continue\n"));
283                 TALLOC_FREE(server_info);
284                 data_blob_free(&session_key);
285                 SAFE_FREE(vuser->homedir);
286                 SAFE_FREE(vuser->unix_homedir);
287                 SAFE_FREE(vuser->logon_script);
288
289                 SAFE_FREE(vuser);
290                 return UID_FIELD_INVALID;
291         }
292
293         /* use this to keep tabs on all our info from the authentication */
294         vuser->server_info = server_info;
295
296         DEBUG(3,("UNIX uid %d is UNIX user %s, and will be vuid %u\n",
297                  (int)vuser->uid,vuser->user.unix_name, vuser->vuid));
298
299         next_vuid++;
300         num_validated_vuids++;
301
302         DLIST_ADD(validated_users, vuser);
303
304         if (!session_claim(vuser)) {
305                 DEBUG(1, ("Failed to claim session for vuid=%d\n",
306                           vuser->vuid));
307                 invalidate_vuid(vuser->vuid);
308                 return -1;
309         }
310
311         /* Register a home dir service for this user iff
312         
313            (a) This is not a guest connection,
314            (b) we have a home directory defined 
315            (c) there s not an existing static share by that name
316            
317            If a share exists by this name (autoloaded or not) reuse it . */
318
319         vuser->homes_snum = -1;
320
321         if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) 
322         {
323                 int servicenumber = lp_servicenumber(vuser->user.unix_name);
324
325                 if ( servicenumber == -1 ) {
326                         DEBUG(3, ("Adding homes service for user '%s' using "
327                                   "home directory: '%s'\n", 
328                                 vuser->user.unix_name, vuser->unix_homedir));
329                         vuser->homes_snum =
330                                 add_home_service(vuser->user.unix_name, 
331                                                  vuser->user.unix_name,
332                                                  vuser->unix_homedir);
333                 } else {
334                         DEBUG(3, ("Using static (or previously created) "
335                                   "service for user '%s'; path = '%s'\n", 
336                                   vuser->user.unix_name,
337                                   lp_pathname(servicenumber) ));
338                         vuser->homes_snum = servicenumber;
339                 }
340         } 
341         
342         if (srv_is_signing_negotiated() && !vuser->guest &&
343             !srv_signing_started()) {
344                 /* Try and turn on server signing on the first non-guest
345                  * sessionsetup. */
346                 srv_set_signing(vuser->session_key, response_blob);
347         }
348         
349         /* fill in the current_user_info struct */
350         set_current_user_info( &vuser->user );
351
352
353         return vuser->vuid;
354 }
355
356 /****************************************************************************
357  Add a name to the session users list.
358 ****************************************************************************/
359
360 void add_session_user(const char *user)
361 {
362         fstring suser;
363         struct passwd *passwd;
364
365         if (!(passwd = Get_Pwnam(user)))
366                 return;
367
368         fstrcpy(suser,passwd->pw_name);
369
370         if(!*suser)
371                 return;
372
373         if( session_userlist && in_list(suser,session_userlist,False) )
374                 return;
375
376         if( !session_userlist ||
377             (strlen(suser) + strlen(session_userlist) + 2 >=
378              len_session_userlist) ) {
379                 char *newlist;
380
381                 if (len_session_userlist > 128 * PSTRING_LEN) {
382                         DEBUG(3,("add_session_user: session userlist already "
383                                  "too large.\n"));
384                         return;
385                 }
386                 newlist = (char *)SMB_REALLOC(
387                         session_userlist,
388                         len_session_userlist + PSTRING_LEN );
389                 if( newlist == NULL ) {
390                         DEBUG(1,("Unable to resize session_userlist\n"));
391                         return;
392                 }
393                 if (!session_userlist) {
394                         *newlist = '\0';
395                 }
396                 session_userlist = newlist;
397                 len_session_userlist += PSTRING_LEN;
398         }
399
400         safe_strcat(session_userlist," ",len_session_userlist-1);
401         safe_strcat(session_userlist,suser,len_session_userlist-1);
402 }
403
404 /****************************************************************************
405  Check if a user is in a netgroup user list. If at first we don't succeed,
406  try lower case.
407 ****************************************************************************/
408
409 BOOL user_in_netgroup(const char *user, const char *ngname)
410 {
411 #ifdef HAVE_NETGROUP
412         static char *mydomain = NULL;
413         fstring lowercase_user;
414
415         if (mydomain == NULL)
416                 yp_get_default_domain(&mydomain);
417
418         if(mydomain == NULL) {
419                 DEBUG(5,("Unable to get default yp domain\n"));
420                 return False;
421         }
422
423         DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
424                 user, mydomain, ngname));
425
426         if (innetgr(ngname, NULL, user, mydomain)) {
427                 DEBUG(5,("user_in_netgroup: Found\n"));
428                 return (True);
429         } else {
430
431                 /*
432                  * Ok, innetgr is case sensitive. Try once more with lowercase
433                  * just in case. Attempt to fix #703. JRA.
434                  */
435
436                 fstrcpy(lowercase_user, user);
437                 strlower_m(lowercase_user);
438         
439                 DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
440                         lowercase_user, mydomain, ngname));
441
442                 if (innetgr(ngname, NULL, lowercase_user, mydomain)) {
443                         DEBUG(5,("user_in_netgroup: Found\n"));
444                         return (True);
445                 }
446         }
447 #endif /* HAVE_NETGROUP */
448         return False;
449 }
450
451 /****************************************************************************
452  Check if a user is in a user list - can check combinations of UNIX
453  and netgroup lists.
454 ****************************************************************************/
455
456 BOOL user_in_list(const char *user,const char **list)
457 {
458         if (!list || !*list)
459                 return False;
460
461         DEBUG(10,("user_in_list: checking user %s in list\n", user));
462
463         while (*list) {
464
465                 DEBUG(10,("user_in_list: checking user |%s| against |%s|\n",
466                           user, *list));
467
468                 /*
469                  * Check raw username.
470                  */
471                 if (strequal(user, *list))
472                         return(True);
473
474                 /*
475                  * Now check to see if any combination
476                  * of UNIX and netgroups has been specified.
477                  */
478
479                 if(**list == '@') {
480                         /*
481                          * Old behaviour. Check netgroup list
482                          * followed by UNIX list.
483                          */
484                         if(user_in_netgroup(user, *list +1))
485                                 return True;
486                         if(user_in_group(user, *list +1))
487                                 return True;
488                 } else if (**list == '+') {
489
490                         if((*(*list +1)) == '&') {
491                                 /*
492                                  * Search UNIX list followed by netgroup.
493                                  */
494                                 if(user_in_group(user, *list +2))
495                                         return True;
496                                 if(user_in_netgroup(user, *list +2))
497                                         return True;
498
499                         } else {
500
501                                 /*
502                                  * Just search UNIX list.
503                                  */
504
505                                 if(user_in_group(user, *list +1))
506                                         return True;
507                         }
508
509                 } else if (**list == '&') {
510
511                         if(*(*list +1) == '+') {
512                                 /*
513                                  * Search netgroup list followed by UNIX list.
514                                  */
515                                 if(user_in_netgroup(user, *list +2))
516                                         return True;
517                                 if(user_in_group(user, *list +2))
518                                         return True;
519                         } else {
520                                 /*
521                                  * Just search netgroup list.
522                                  */
523                                 if(user_in_netgroup(user, *list +1))
524                                         return True;
525                         }
526                 }
527     
528                 list++;
529         }
530         return(False);
531 }
532
533 /****************************************************************************
534  Check if a username is valid.
535 ****************************************************************************/
536
537 static BOOL user_ok(const char *user, int snum)
538 {
539         char **valid, **invalid;
540         BOOL ret;
541
542         valid = invalid = NULL;
543         ret = True;
544
545         if (lp_invalid_users(snum)) {
546                 str_list_copy(&invalid, lp_invalid_users(snum));
547                 if (invalid &&
548                     str_list_substitute(invalid, "%S", lp_servicename(snum))) {
549                         if ( invalid &&
550                              str_list_sub_basic(invalid,
551                                                 current_user_info.smb_name) ) {
552                                 ret = !user_in_list(user,
553                                                     (const char **)invalid);
554                         }
555                 }
556         }
557         if (invalid)
558                 str_list_free (&invalid);
559
560         if (ret && lp_valid_users(snum)) {
561                 str_list_copy(&valid, lp_valid_users(snum));
562                 if ( valid &&
563                      str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
564                         if ( valid &&
565                              str_list_sub_basic(valid,
566                                                 current_user_info.smb_name) ) {
567                                 ret = user_in_list(user, (const char **)valid);
568                         }
569                 }
570         }
571         if (valid)
572                 str_list_free (&valid);
573
574         if (ret && lp_onlyuser(snum)) {
575                 char **user_list = str_list_make (lp_username(snum), NULL);
576                 if (user_list &&
577                     str_list_substitute(user_list, "%S",
578                                         lp_servicename(snum))) {
579                         ret = user_in_list(user, (const char **)user_list);
580                 }
581                 if (user_list) str_list_free (&user_list);
582         }
583
584         return(ret);
585 }
586
587 /****************************************************************************
588  Validate a group username entry. Return the username or NULL.
589 ****************************************************************************/
590
591 static char *validate_group(char *group, DATA_BLOB password,int snum)
592 {
593 #ifdef HAVE_NETGROUP
594         {
595                 char *host, *user, *domain;
596                 setnetgrent(group);
597                 while (getnetgrent(&host, &user, &domain)) {
598                         if (user) {
599                                 if (user_ok(user, snum) && 
600                                     password_ok(user,password)) {
601                                         endnetgrent();
602                                         return(user);
603                                 }
604                         }
605                 }
606                 endnetgrent();
607         }
608 #endif
609   
610 #ifdef HAVE_GETGRENT
611         {
612                 struct group *gptr;
613                 setgrent();
614                 while ((gptr = (struct group *)getgrent())) {
615                         if (strequal(gptr->gr_name,group))
616                                 break;
617                 }
618
619                 /*
620                  * As user_ok can recurse doing a getgrent(), we must
621                  * copy the member list into a pstring on the stack before
622                  * use. Bug pointed out by leon@eatworms.swmed.edu.
623                  */
624
625                 if (gptr) {
626                         pstring member_list;
627                         char *member;
628                         size_t copied_len = 0;
629                         int i;
630
631                         *member_list = '\0';
632                         member = member_list;
633
634                         for(i = 0; gptr->gr_mem && gptr->gr_mem[i]; i++) {
635                                 size_t member_len = strlen(gptr->gr_mem[i])+1;
636                                 if(copied_len+member_len < sizeof(pstring)) { 
637
638                                         DEBUG(10,("validate_group: = gr_mem = "
639                                                   "%s\n", gptr->gr_mem[i]));
640
641                                         safe_strcpy(member, gptr->gr_mem[i],
642                                                     sizeof(pstring) -
643                                                     copied_len - 1);
644                                         copied_len += member_len;
645                                         member += copied_len;
646                                 } else {
647                                         *member = '\0';
648                                 }
649                         }
650
651                         endgrent();
652
653                         member = member_list;
654                         while (*member) {
655                                 static fstring name;
656                                 fstrcpy(name,member);
657                                 if (user_ok(name,snum) &&
658                                     password_ok(name,password)) {
659                                         endgrent();
660                                         return(&name[0]);
661                                 }
662
663                                 DEBUG(10,("validate_group = member = %s\n",
664                                           member));
665
666                                 member += strlen(member) + 1;
667                         }
668                 } else {
669                         endgrent();
670                         return NULL;
671                 }
672         }
673 #endif
674         return(NULL);
675 }
676
677 /****************************************************************************
678  Check for authority to login to a service with a given username/password.
679  Note this is *NOT* used when logging on using sessionsetup_and_X.
680 ****************************************************************************/
681
682 BOOL authorise_login(int snum, fstring user, DATA_BLOB password, 
683                      BOOL *guest)
684 {
685         BOOL ok = False;
686         
687 #ifdef DEBUG_PASSWORD
688         DEBUG(100,("authorise_login: checking authorisation on "
689                    "user=%s pass=%s\n", user,password.data));
690 #endif
691
692         *guest = False;
693   
694         /* there are several possibilities:
695                 1) login as the given user with given password
696                 2) login as a previously registered username with the given 
697                    password
698                 3) login as a session list username with the given password
699                 4) login as a previously validated user/password pair
700                 5) login as the "user =" user with given password
701                 6) login as the "user =" user with no password 
702                    (guest connection)
703                 7) login as guest user with no password
704
705                 if the service is guest_only then steps 1 to 5 are skipped
706         */
707
708         /* now check the list of session users */
709         if (!ok) {
710                 char *auser;
711                 char *user_list = NULL;
712
713                 if ( session_userlist )
714                         user_list = SMB_STRDUP(session_userlist);
715                 else
716                         user_list = SMB_STRDUP("");
717
718                 if (!user_list)
719                         return(False);
720                 
721                 for (auser=strtok(user_list,LIST_SEP); !ok && auser;
722                      auser = strtok(NULL,LIST_SEP)) {
723                         fstring user2;
724                         fstrcpy(user2,auser);
725                         if (!user_ok(user2,snum))
726                                 continue;
727                         
728                         if (password_ok(user2,password)) {
729                                 ok = True;
730                                 fstrcpy(user,user2);
731                                 DEBUG(3,("authorise_login: ACCEPTED: session "
732                                          "list username (%s) and given "
733                                          "password ok\n", user));
734                         }
735                 }
736
737                 SAFE_FREE(user_list);
738         }
739         
740         /* check the user= fields and the given password */
741         if (!ok && lp_username(snum)) {
742                 char *auser;
743                 pstring user_list;
744                 pstrcpy(user_list,lp_username(snum));
745                 
746                 pstring_sub(user_list,"%S",lp_servicename(snum));
747                 
748                 for (auser=strtok(user_list,LIST_SEP); auser && !ok;
749                      auser = strtok(NULL,LIST_SEP)) {
750                         if (*auser == '@') {
751                                 auser = validate_group(auser+1,password,snum);
752                                 if (auser) {
753                                         ok = True;
754                                         fstrcpy(user,auser);
755                                         DEBUG(3,("authorise_login: ACCEPTED: "
756                                                  "group username and given "
757                                                  "password ok (%s)\n", user));
758                                 }
759                         } else {
760                                 fstring user2;
761                                 fstrcpy(user2,auser);
762                                 if (user_ok(user2,snum) &&
763                                     password_ok(user2,password)) {
764                                         ok = True;
765                                         fstrcpy(user,user2);
766                                         DEBUG(3,("authorise_login: ACCEPTED: "
767                                                  "user list username and "
768                                                  "given password ok (%s)\n",
769                                                  user));
770                                 }
771                         }
772                 }
773         }
774
775         /* check for a normal guest connection */
776         if (!ok && GUEST_OK(snum)) {
777                 fstring guestname;
778                 fstrcpy(guestname,lp_guestaccount());
779                 if (Get_Pwnam(guestname)) {
780                         fstrcpy(user,guestname);
781                         ok = True;
782                         DEBUG(3,("authorise_login: ACCEPTED: guest account "
783                                  "and guest ok (%s)\n", user));
784                 } else {
785                         DEBUG(0,("authorise_login: Invalid guest account "
786                                  "%s??\n",guestname));
787                 }
788                 *guest = True;
789         }
790
791         if (ok && !user_ok(user, snum)) {
792                 DEBUG(0,("authorise_login: rejected invalid user %s\n",user));
793                 ok = False;
794         }
795
796         return(ok);
797 }