r15589: While trying to understand the vuid code I found that security=share is broken
[samba.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         /* Paranoia check. */
159         if(lp_security() == SEC_SHARE) {
160                 smb_panic("Tried to register uid in security=share\n");
161         }
162
163         /* Limit allowed vuids to 16bits - VUID_OFFSET. */
164         if (num_validated_vuids >= 0xFFFF-VUID_OFFSET) {
165                 data_blob_free(&session_key);
166                 return UID_FIELD_INVALID;
167         }
168
169         if((vuser = SMB_MALLOC_P(user_struct)) == NULL) {
170                 DEBUG(0,("Failed to malloc users struct!\n"));
171                 data_blob_free(&session_key);
172                 return UID_FIELD_INVALID;
173         }
174
175         ZERO_STRUCTP(vuser);
176
177         /* Allocate a free vuid. Yes this is a linear search... :-) */
178         while( get_valid_user_struct(next_vuid) != NULL ) {
179                 next_vuid++;
180                 /* Check for vuid wrap. */
181                 if (next_vuid == UID_FIELD_INVALID)
182                         next_vuid = VUID_OFFSET;
183         }
184
185         DEBUG(10,("register_vuid: allocated vuid = %u\n",
186                   (unsigned int)next_vuid ));
187
188         vuser->vuid = next_vuid;
189
190         if (!server_info) {
191                 /*
192                  * This happens in an unfinished NTLMSSP session setup. We
193                  * need to allocate a vuid between the first and second calls
194                  * to NTLMSSP.
195                  */
196                 next_vuid++;
197                 num_validated_vuids++;
198                 
199                 vuser->server_info = NULL;
200                 
201                 DLIST_ADD(validated_users, vuser);
202                 
203                 return vuser->vuid;
204         }
205
206         /* the next functions should be done by a SID mapping system (SMS) as
207          * the new real sam db won't have reference to unix uids or gids
208          */
209         
210         vuser->uid = server_info->uid;
211         vuser->gid = server_info->gid;
212         
213         vuser->n_groups = server_info->n_groups;
214         if (vuser->n_groups) {
215                 if (!(vuser->groups = (gid_t *)memdup(server_info->groups,
216                                                       sizeof(gid_t) *
217                                                       vuser->n_groups))) {
218                         DEBUG(0,("register_vuid: failed to memdup "
219                                  "vuser->groups\n"));
220                         data_blob_free(&session_key);
221                         free(vuser);
222                         TALLOC_FREE(server_info);
223                         return UID_FIELD_INVALID;
224                 }
225         }
226
227         vuser->guest = server_info->guest;
228         fstrcpy(vuser->user.unix_name, server_info->unix_name); 
229
230         /* This is a potentially untrusted username */
231         alpha_strcpy(vuser->user.smb_name, smb_name, ". _-$",
232                      sizeof(vuser->user.smb_name));
233
234         fstrcpy(vuser->user.domain, pdb_get_domain(server_info->sam_account));
235         fstrcpy(vuser->user.full_name,
236                 pdb_get_fullname(server_info->sam_account));
237
238         {
239                 /* Keep the homedir handy */
240                 const char *homedir =
241                         pdb_get_homedir(server_info->sam_account);
242                 const char *logon_script =
243                         pdb_get_logon_script(server_info->sam_account);
244
245                 if (!IS_SAM_DEFAULT(server_info->sam_account,
246                                     PDB_UNIXHOMEDIR)) {
247                         const char *unix_homedir =
248                                 pdb_get_unix_homedir(server_info->sam_account);
249                         if (unix_homedir) {
250                                 vuser->unix_homedir =
251                                         smb_xstrdup(unix_homedir);
252                         }
253                 } else {
254                         struct passwd *passwd =
255                                 getpwnam_alloc(NULL, vuser->user.unix_name);
256                         if (passwd) {
257                                 vuser->unix_homedir =
258                                         smb_xstrdup(passwd->pw_dir);
259                                 TALLOC_FREE(passwd);
260                         }
261                 }
262                 
263                 if (homedir) {
264                         vuser->homedir = smb_xstrdup(homedir);
265                 }
266                 if (logon_script) {
267                         vuser->logon_script = smb_xstrdup(logon_script);
268                 }
269         }
270
271         vuser->session_key = session_key;
272
273         DEBUG(10,("register_vuid: (%u,%u) %s %s %s guest=%d\n", 
274                   (unsigned int)vuser->uid, 
275                   (unsigned int)vuser->gid,
276                   vuser->user.unix_name, vuser->user.smb_name,
277                   vuser->user.domain, vuser->guest ));
278
279         DEBUG(3, ("User name: %s\tReal name: %s\n", vuser->user.unix_name,
280                   vuser->user.full_name));      
281
282         if (server_info->ptok) {
283                 vuser->nt_user_token = dup_nt_token(NULL, server_info->ptok);
284         } else {
285                 DEBUG(1, ("server_info does not contain a user_token - "
286                           "cannot continue\n"));
287                 TALLOC_FREE(server_info);
288                 data_blob_free(&session_key);
289                 SAFE_FREE(vuser->homedir);
290                 SAFE_FREE(vuser->unix_homedir);
291                 SAFE_FREE(vuser->logon_script);
292
293                 SAFE_FREE(vuser);
294                 return UID_FIELD_INVALID;
295         }
296
297         /* use this to keep tabs on all our info from the authentication */
298         vuser->server_info = server_info;
299
300         DEBUG(3,("UNIX uid %d is UNIX user %s, and will be vuid %u\n",
301                  (int)vuser->uid,vuser->user.unix_name, vuser->vuid));
302
303         next_vuid++;
304         num_validated_vuids++;
305
306         DLIST_ADD(validated_users, vuser);
307
308         if (!session_claim(vuser)) {
309                 DEBUG(1, ("Failed to claim session for vuid=%d\n",
310                           vuser->vuid));
311                 invalidate_vuid(vuser->vuid);
312                 return UID_FIELD_INVALID;
313         }
314
315         /* Register a home dir service for this user iff
316         
317            (a) This is not a guest connection,
318            (b) we have a home directory defined 
319            (c) there s not an existing static share by that name
320            
321            If a share exists by this name (autoloaded or not) reuse it . */
322
323         vuser->homes_snum = -1;
324
325         if ( (!vuser->guest) && vuser->unix_homedir && *(vuser->unix_homedir)) 
326         {
327                 int servicenumber = lp_servicenumber(vuser->user.unix_name);
328
329                 if ( servicenumber == -1 ) {
330                         DEBUG(3, ("Adding homes service for user '%s' using "
331                                   "home directory: '%s'\n", 
332                                 vuser->user.unix_name, vuser->unix_homedir));
333                         vuser->homes_snum =
334                                 add_home_service(vuser->user.unix_name, 
335                                                  vuser->user.unix_name,
336                                                  vuser->unix_homedir);
337                 } else {
338                         DEBUG(3, ("Using static (or previously created) "
339                                   "service for user '%s'; path = '%s'\n", 
340                                   vuser->user.unix_name,
341                                   lp_pathname(servicenumber) ));
342                         vuser->homes_snum = servicenumber;
343                 }
344         } 
345         
346         if (srv_is_signing_negotiated() && !vuser->guest &&
347             !srv_signing_started()) {
348                 /* Try and turn on server signing on the first non-guest
349                  * sessionsetup. */
350                 srv_set_signing(vuser->session_key, response_blob);
351         }
352         
353         /* fill in the current_user_info struct */
354         set_current_user_info( &vuser->user );
355
356
357         return vuser->vuid;
358 }
359
360 /****************************************************************************
361  Add a name to the session users list.
362 ****************************************************************************/
363
364 void add_session_user(const char *user)
365 {
366         fstring suser;
367         struct passwd *passwd;
368
369         if (!(passwd = Get_Pwnam(user)))
370                 return;
371
372         fstrcpy(suser,passwd->pw_name);
373
374         if(!*suser)
375                 return;
376
377         if( session_userlist && in_list(suser,session_userlist,False) )
378                 return;
379
380         if( !session_userlist ||
381             (strlen(suser) + strlen(session_userlist) + 2 >=
382              len_session_userlist) ) {
383                 char *newlist;
384
385                 if (len_session_userlist > 128 * PSTRING_LEN) {
386                         DEBUG(3,("add_session_user: session userlist already "
387                                  "too large.\n"));
388                         return;
389                 }
390                 newlist = (char *)SMB_REALLOC_KEEP_OLD_ON_ERROR(
391                         session_userlist,
392                         len_session_userlist + PSTRING_LEN );
393                 if( newlist == NULL ) {
394                         DEBUG(1,("Unable to resize session_userlist\n"));
395                         return;
396                 }
397                 if (!session_userlist) {
398                         *newlist = '\0';
399                 }
400                 session_userlist = newlist;
401                 len_session_userlist += PSTRING_LEN;
402         }
403
404         safe_strcat(session_userlist," ",len_session_userlist-1);
405         safe_strcat(session_userlist,suser,len_session_userlist-1);
406 }
407
408 /****************************************************************************
409  Check if a user is in a netgroup user list. If at first we don't succeed,
410  try lower case.
411 ****************************************************************************/
412
413 BOOL user_in_netgroup(const char *user, const char *ngname)
414 {
415 #ifdef HAVE_NETGROUP
416         static char *mydomain = NULL;
417         fstring lowercase_user;
418
419         if (mydomain == NULL)
420                 yp_get_default_domain(&mydomain);
421
422         if(mydomain == NULL) {
423                 DEBUG(5,("Unable to get default yp domain\n"));
424                 return False;
425         }
426
427         DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
428                 user, mydomain, ngname));
429
430         if (innetgr(ngname, NULL, user, mydomain)) {
431                 DEBUG(5,("user_in_netgroup: Found\n"));
432                 return (True);
433         } else {
434
435                 /*
436                  * Ok, innetgr is case sensitive. Try once more with lowercase
437                  * just in case. Attempt to fix #703. JRA.
438                  */
439
440                 fstrcpy(lowercase_user, user);
441                 strlower_m(lowercase_user);
442         
443                 DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
444                         lowercase_user, mydomain, ngname));
445
446                 if (innetgr(ngname, NULL, lowercase_user, mydomain)) {
447                         DEBUG(5,("user_in_netgroup: Found\n"));
448                         return (True);
449                 }
450         }
451 #endif /* HAVE_NETGROUP */
452         return False;
453 }
454
455 /****************************************************************************
456  Check if a user is in a user list - can check combinations of UNIX
457  and netgroup lists.
458 ****************************************************************************/
459
460 BOOL user_in_list(const char *user,const char **list)
461 {
462         if (!list || !*list)
463                 return False;
464
465         DEBUG(10,("user_in_list: checking user %s in list\n", user));
466
467         while (*list) {
468
469                 DEBUG(10,("user_in_list: checking user |%s| against |%s|\n",
470                           user, *list));
471
472                 /*
473                  * Check raw username.
474                  */
475                 if (strequal(user, *list))
476                         return(True);
477
478                 /*
479                  * Now check to see if any combination
480                  * of UNIX and netgroups has been specified.
481                  */
482
483                 if(**list == '@') {
484                         /*
485                          * Old behaviour. Check netgroup list
486                          * followed by UNIX list.
487                          */
488                         if(user_in_netgroup(user, *list +1))
489                                 return True;
490                         if(user_in_group(user, *list +1))
491                                 return True;
492                 } else if (**list == '+') {
493
494                         if((*(*list +1)) == '&') {
495                                 /*
496                                  * Search UNIX list followed by netgroup.
497                                  */
498                                 if(user_in_group(user, *list +2))
499                                         return True;
500                                 if(user_in_netgroup(user, *list +2))
501                                         return True;
502
503                         } else {
504
505                                 /*
506                                  * Just search UNIX list.
507                                  */
508
509                                 if(user_in_group(user, *list +1))
510                                         return True;
511                         }
512
513                 } else if (**list == '&') {
514
515                         if(*(*list +1) == '+') {
516                                 /*
517                                  * Search netgroup list followed by UNIX list.
518                                  */
519                                 if(user_in_netgroup(user, *list +2))
520                                         return True;
521                                 if(user_in_group(user, *list +2))
522                                         return True;
523                         } else {
524                                 /*
525                                  * Just search netgroup list.
526                                  */
527                                 if(user_in_netgroup(user, *list +1))
528                                         return True;
529                         }
530                 }
531     
532                 list++;
533         }
534         return(False);
535 }
536
537 /****************************************************************************
538  Check if a username is valid.
539 ****************************************************************************/
540
541 static BOOL user_ok(const char *user, int snum)
542 {
543         char **valid, **invalid;
544         BOOL ret;
545
546         valid = invalid = NULL;
547         ret = True;
548
549         if (lp_invalid_users(snum)) {
550                 str_list_copy(&invalid, lp_invalid_users(snum));
551                 if (invalid &&
552                     str_list_substitute(invalid, "%S", lp_servicename(snum))) {
553                         if ( invalid &&
554                              str_list_sub_basic(invalid,
555                                                 current_user_info.smb_name) ) {
556                                 ret = !user_in_list(user,
557                                                     (const char **)invalid);
558                         }
559                 }
560         }
561         if (invalid)
562                 str_list_free (&invalid);
563
564         if (ret && lp_valid_users(snum)) {
565                 str_list_copy(&valid, lp_valid_users(snum));
566                 if ( valid &&
567                      str_list_substitute(valid, "%S", lp_servicename(snum)) ) {
568                         if ( valid &&
569                              str_list_sub_basic(valid,
570                                                 current_user_info.smb_name) ) {
571                                 ret = user_in_list(user, (const char **)valid);
572                         }
573                 }
574         }
575         if (valid)
576                 str_list_free (&valid);
577
578         if (ret && lp_onlyuser(snum)) {
579                 char **user_list = str_list_make (lp_username(snum), NULL);
580                 if (user_list &&
581                     str_list_substitute(user_list, "%S",
582                                         lp_servicename(snum))) {
583                         ret = user_in_list(user, (const char **)user_list);
584                 }
585                 if (user_list) str_list_free (&user_list);
586         }
587
588         return(ret);
589 }
590
591 /****************************************************************************
592  Validate a group username entry. Return the username or NULL.
593 ****************************************************************************/
594
595 static char *validate_group(char *group, DATA_BLOB password,int snum)
596 {
597 #ifdef HAVE_NETGROUP
598         {
599                 char *host, *user, *domain;
600                 setnetgrent(group);
601                 while (getnetgrent(&host, &user, &domain)) {
602                         if (user) {
603                                 if (user_ok(user, snum) && 
604                                     password_ok(user,password)) {
605                                         endnetgrent();
606                                         return(user);
607                                 }
608                         }
609                 }
610                 endnetgrent();
611         }
612 #endif
613   
614 #ifdef HAVE_GETGRENT
615         {
616                 struct group *gptr;
617                 setgrent();
618                 while ((gptr = (struct group *)getgrent())) {
619                         if (strequal(gptr->gr_name,group))
620                                 break;
621                 }
622
623                 /*
624                  * As user_ok can recurse doing a getgrent(), we must
625                  * copy the member list into a pstring on the stack before
626                  * use. Bug pointed out by leon@eatworms.swmed.edu.
627                  */
628
629                 if (gptr) {
630                         pstring member_list;
631                         char *member;
632                         size_t copied_len = 0;
633                         int i;
634
635                         *member_list = '\0';
636                         member = member_list;
637
638                         for(i = 0; gptr->gr_mem && gptr->gr_mem[i]; i++) {
639                                 size_t member_len = strlen(gptr->gr_mem[i])+1;
640                                 if(copied_len+member_len < sizeof(pstring)) { 
641
642                                         DEBUG(10,("validate_group: = gr_mem = "
643                                                   "%s\n", gptr->gr_mem[i]));
644
645                                         safe_strcpy(member, gptr->gr_mem[i],
646                                                     sizeof(pstring) -
647                                                     copied_len - 1);
648                                         copied_len += member_len;
649                                         member += copied_len;
650                                 } else {
651                                         *member = '\0';
652                                 }
653                         }
654
655                         endgrent();
656
657                         member = member_list;
658                         while (*member) {
659                                 static fstring name;
660                                 fstrcpy(name,member);
661                                 if (user_ok(name,snum) &&
662                                     password_ok(name,password)) {
663                                         endgrent();
664                                         return(&name[0]);
665                                 }
666
667                                 DEBUG(10,("validate_group = member = %s\n",
668                                           member));
669
670                                 member += strlen(member) + 1;
671                         }
672                 } else {
673                         endgrent();
674                         return NULL;
675                 }
676         }
677 #endif
678         return(NULL);
679 }
680
681 /****************************************************************************
682  Check for authority to login to a service with a given username/password.
683  Note this is *NOT* used when logging on using sessionsetup_and_X.
684 ****************************************************************************/
685
686 BOOL authorise_login(int snum, fstring user, DATA_BLOB password, 
687                      BOOL *guest)
688 {
689         BOOL ok = False;
690         
691 #ifdef DEBUG_PASSWORD
692         DEBUG(100,("authorise_login: checking authorisation on "
693                    "user=%s pass=%s\n", user,password.data));
694 #endif
695
696         *guest = False;
697   
698         /* there are several possibilities:
699                 1) login as the given user with given password
700                 2) login as a previously registered username with the given 
701                    password
702                 3) login as a session list username with the given password
703                 4) login as a previously validated user/password pair
704                 5) login as the "user =" user with given password
705                 6) login as the "user =" user with no password 
706                    (guest connection)
707                 7) login as guest user with no password
708
709                 if the service is guest_only then steps 1 to 5 are skipped
710         */
711
712         /* now check the list of session users */
713         if (!ok) {
714                 char *auser;
715                 char *user_list = NULL;
716
717                 if ( session_userlist )
718                         user_list = SMB_STRDUP(session_userlist);
719                 else
720                         user_list = SMB_STRDUP("");
721
722                 if (!user_list)
723                         return(False);
724                 
725                 for (auser=strtok(user_list,LIST_SEP); !ok && auser;
726                      auser = strtok(NULL,LIST_SEP)) {
727                         fstring user2;
728                         fstrcpy(user2,auser);
729                         if (!user_ok(user2,snum))
730                                 continue;
731                         
732                         if (password_ok(user2,password)) {
733                                 ok = True;
734                                 fstrcpy(user,user2);
735                                 DEBUG(3,("authorise_login: ACCEPTED: session "
736                                          "list username (%s) and given "
737                                          "password ok\n", user));
738                         }
739                 }
740
741                 SAFE_FREE(user_list);
742         }
743         
744         /* check the user= fields and the given password */
745         if (!ok && lp_username(snum)) {
746                 char *auser;
747                 pstring user_list;
748                 pstrcpy(user_list,lp_username(snum));
749                 
750                 pstring_sub(user_list,"%S",lp_servicename(snum));
751                 
752                 for (auser=strtok(user_list,LIST_SEP); auser && !ok;
753                      auser = strtok(NULL,LIST_SEP)) {
754                         if (*auser == '@') {
755                                 auser = validate_group(auser+1,password,snum);
756                                 if (auser) {
757                                         ok = True;
758                                         fstrcpy(user,auser);
759                                         DEBUG(3,("authorise_login: ACCEPTED: "
760                                                  "group username and given "
761                                                  "password ok (%s)\n", user));
762                                 }
763                         } else {
764                                 fstring user2;
765                                 fstrcpy(user2,auser);
766                                 if (user_ok(user2,snum) &&
767                                     password_ok(user2,password)) {
768                                         ok = True;
769                                         fstrcpy(user,user2);
770                                         DEBUG(3,("authorise_login: ACCEPTED: "
771                                                  "user list username and "
772                                                  "given password ok (%s)\n",
773                                                  user));
774                                 }
775                         }
776                 }
777         }
778
779         /* check for a normal guest connection */
780         if (!ok && GUEST_OK(snum)) {
781                 fstring guestname;
782                 fstrcpy(guestname,lp_guestaccount());
783                 if (Get_Pwnam(guestname)) {
784                         fstrcpy(user,guestname);
785                         ok = True;
786                         DEBUG(3,("authorise_login: ACCEPTED: guest account "
787                                  "and guest ok (%s)\n", user));
788                 } else {
789                         DEBUG(0,("authorise_login: Invalid guest account "
790                                  "%s??\n",guestname));
791                 }
792                 *guest = True;
793         }
794
795         if (ok && !user_ok(user, snum)) {
796                 DEBUG(0,("authorise_login: rejected invalid user %s\n",user));
797                 ok = False;
798         }
799
800         return(ok);
801 }