a9b9a9d4d944ec3c299feddfa56a493c053e09f3
[kai/samba.git] / source3 / smbd / service.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    service (connection) opening and closing
5    Copyright (C) Andrew Tridgell 1992-1998
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 extern struct timeval smb_last_time;
25 extern int case_default;
26 extern BOOL case_preserve;
27 extern BOOL short_case_preserve;
28 extern BOOL case_mangle;
29 extern BOOL case_sensitive;
30 extern BOOL use_mangled_map;
31 extern fstring remote_machine;
32 extern userdom_struct current_user_info;
33 extern fstring remote_machine;
34
35
36 /****************************************************************************
37  Load parameters specific to a connection/service.
38 ****************************************************************************/
39
40 BOOL set_current_service(connection_struct *conn,BOOL do_chdir)
41 {
42         extern char magic_char;
43         static connection_struct *last_conn;
44         int snum;
45
46         if (!conn)  {
47                 last_conn = NULL;
48                 return(False);
49         }
50
51         conn->lastused = smb_last_time.tv_sec;
52
53         snum = SNUM(conn);
54   
55         if (do_chdir &&
56             vfs_ChDir(conn,conn->connectpath) != 0 &&
57             vfs_ChDir(conn,conn->origpath) != 0) {
58                 DEBUG(0,("chdir (%s) failed\n",
59                          conn->connectpath));
60                 return(False);
61         }
62
63         if (conn == last_conn)
64                 return(True);
65
66         last_conn = conn;
67
68         case_default = lp_defaultcase(snum);
69         case_preserve = lp_preservecase(snum);
70         short_case_preserve = lp_shortpreservecase(snum);
71         case_mangle = lp_casemangle(snum);
72         case_sensitive = lp_casesensitive(snum);
73         magic_char = lp_magicchar(snum);
74         use_mangled_map = (*lp_mangled_map(snum) ? True:False);
75         return(True);
76 }
77
78 /****************************************************************************
79  Add a home service. Returns the new service number or -1 if fail.
80 ****************************************************************************/
81
82 int add_home_service(const char *service, const char *homedir)
83 {
84         int iHomeService;
85         int iService;
86         fstring new_service;
87         fstring domain;
88
89         if (!service || !homedir)
90                 return -1;
91
92         if ((iHomeService = lp_servicenumber(HOMES_NAME)) < 0)
93                 return -1;
94
95         /*
96          * If this is a winbindd provided username, remove
97          * the domain component before adding the service.
98          * Log a warning if the "path=" parameter does not
99          * include any macros.
100          */
101
102         split_domain_and_name(service, domain, new_service);
103         lp_add_home(new_service, iHomeService, homedir);
104         iService = lp_servicenumber(new_service);
105
106         return iService;
107 }
108
109
110 /**
111  * Find a service entry. service is always in dos codepage.
112  *
113  * @param service is modified (to canonical form??)
114  **/
115 int find_service(fstring service)
116 {
117    int iService;
118
119    all_string_sub(service,"\\","/",0);
120
121    iService = lp_servicenumber(service);
122
123    /* now handle the special case of a home directory */
124    if (iService < 0)
125    {
126       char *phome_dir = get_user_service_home_dir(service);
127
128       if(!phome_dir)
129       {
130         /*
131          * Try mapping the servicename, it may
132          * be a Windows to unix mapped user name.
133          */
134         if(map_username(service))
135           phome_dir = get_user_service_home_dir(service);
136       }
137
138       DEBUG(3,("checking for home directory %s gave %s\n",service,
139             phome_dir?phome_dir:"(NULL)"));
140
141       iService = add_home_service(service,phome_dir);
142    }
143
144    /* If we still don't have a service, attempt to add it as a printer. */
145    if (iService < 0)
146    {
147       int iPrinterService;
148
149       if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0)
150       {
151          char *pszTemp;
152
153          DEBUG(3,("checking whether %s is a valid printer name...\n", service));
154          pszTemp = PRINTCAP;
155          if ((pszTemp != NULL) && pcap_printername_ok(service, pszTemp))
156          {
157             DEBUG(3,("%s is a valid printer name\n", service));
158             DEBUG(3,("adding %s as a printer service\n", service));
159             lp_add_printer(service, iPrinterService);
160             iService = lp_servicenumber(service);
161             if (iService < 0)
162                DEBUG(0,("failed to add %s as a printer service!\n", service));
163          }
164          else
165             DEBUG(3,("%s is not a valid printer name\n", service));
166       }
167    }
168
169    /* Check for default vfs service?  Unsure whether to implement this */
170    if (iService < 0)
171    {
172    }
173
174    /* just possibly it's a default service? */
175    if (iService < 0) 
176    {
177      char *pdefservice = lp_defaultservice();
178      if (pdefservice && *pdefservice && 
179          !strequal(pdefservice,service) &&
180          !strstr(service,".."))
181      {
182        /*
183         * We need to do a local copy here as lp_defaultservice() 
184         * returns one of the rotating lp_string buffers that
185         * could get overwritten by the recursive find_service() call
186         * below. Fix from Josef Hinteregger <joehtg@joehtg.co.at>.
187         */
188        pstring defservice;
189        pstrcpy(defservice, pdefservice);
190        iService = find_service(defservice);
191        if (iService >= 0)
192        {
193          all_string_sub(service, "_","/",0);
194          iService = lp_add_service(service, iService);
195        }
196      }
197    }
198
199    if (iService >= 0)
200      if (!VALID_SNUM(iService))
201      {
202        DEBUG(0,("Invalid snum %d for %s\n",iService, service));
203        iService = -1;
204      }
205
206    if (iService < 0)
207      DEBUG(3,("find_service() failed to find service %s\n", service));
208
209    return (iService);
210 }
211
212
213 /****************************************************************************
214  do some basic sainity checks on the share.  
215  This function modifies dev, ecode.
216 ****************************************************************************/
217 static NTSTATUS share_sanity_checks(int snum, const char* service, pstring dev) 
218 {
219         
220         if (!lp_snum_ok(snum) || 
221             !check_access(smbd_server_fd(), 
222                           lp_hostsallow(snum), lp_hostsdeny(snum))) {    
223                 return NT_STATUS_ACCESS_DENIED;
224         }
225
226         /* you can only connect to the IPC$ service as an ipc device */
227         if (strequal(service,"IPC$") || strequal(service,"ADMIN$"))
228                 pstrcpy(dev,"IPC");
229         
230         if (dev[0] == '?' || !dev[0]) {
231                 if (lp_print_ok(snum)) {
232                         pstrcpy(dev,"LPT1:");
233                 } else {
234                         pstrcpy(dev,"A:");
235                 }
236         }
237
238         /* if the request is as a printer and you can't print then refuse */
239         strupper(dev);
240         if (!lp_print_ok(snum) && (strncmp(dev,"LPT",3) == 0)) {
241                 DEBUG(1,("Attempt to connect to non-printer as a printer\n"));
242                 return NT_STATUS_BAD_DEVICE_TYPE;
243         }
244
245         /* Behave as a printer if we are supposed to */
246         if (lp_print_ok(snum) && (strcmp(dev, "A:") == 0)) {
247                 pstrcpy(dev, "LPT1:");
248         }
249
250         return NT_STATUS_OK;
251 }
252
253
254 /****************************************************************************
255  readonly share?
256 ****************************************************************************/
257 static void set_read_only(connection_struct *conn) 
258 {
259         char **list;
260         char *service = lp_servicename(conn->service);
261         conn->read_only = lp_readonly(conn->service);
262
263         if (!service) return;
264
265         lp_list_copy(&list, lp_readlist(conn->service));
266         if (list) {
267                 if (!lp_list_substitute(list, "%S", service)) {
268                         DEBUG(0, ("ERROR: read list substitution failed\n"));
269                 }
270                 if (user_in_list(conn->user, list))
271                         conn->read_only = True;
272                 lp_list_free(&list);
273         }
274         
275         lp_list_copy(&list, lp_writelist(conn->service));
276         if (list) {
277                 if (!lp_list_substitute(list, "%S", service)) {
278                         DEBUG(0, ("ERROR: write list substitution failed\n"));
279                 }
280                 if (user_in_list(conn->user, list))
281                         conn->read_only = False;
282                 lp_list_free(&list);
283         }
284 }
285
286
287 /****************************************************************************
288   admin user check
289 ****************************************************************************/
290 static void set_admin_user(connection_struct *conn) 
291 {
292         /* admin user check */
293         
294         /* JRA - original code denied admin user if the share was
295            marked read_only. Changed as I don't think this is needed,
296            but old code left in case there is a problem here.
297         */
298         if (user_in_list(conn->user,lp_admin_users(conn->service)) 
299 #if 0
300             && !conn->read_only
301 #endif
302             ) {
303                 conn->admin_user = True;
304                 DEBUG(0,("%s logged in as admin user (root privileges)\n",conn->user));
305         } else {
306                 conn->admin_user = False;
307         }
308
309 #if 0 /* This done later, for now */    
310         /* admin users always run as uid=0 */
311         if (conn->admin_user) {
312                 conn->uid = 0;
313         }
314 #endif
315 }
316
317 /****************************************************************************
318  Make a connection to a service.
319  *
320  * @param service (May be modified to canonical form???)
321 ****************************************************************************/
322
323 connection_struct *make_connection(char *service, DATA_BLOB password, 
324                                    char *dev, uint16 vuid, NTSTATUS *status)
325 {
326         int snum;
327         struct passwd *pass = NULL;
328         BOOL guest = False;
329         BOOL force = False;
330         connection_struct *conn;
331         uid_t euid;
332
333         fstring user;
334         ZERO_STRUCT(user);
335
336         /* This must ONLY BE CALLED AS ROOT. As it exits this function as root. */
337         if (!non_root_mode() && (euid = geteuid()) != 0) {
338                 DEBUG(0,("make_connection: PANIC ERROR. Called as nonroot (%u)\n", (unsigned int)euid ));
339                 smb_panic("make_connection: PANIC ERROR. Called as nonroot\n");
340         }
341
342         strlower(service);
343
344         snum = find_service(service);
345
346         if (snum < 0) {
347                 if (strequal(service,"IPC$") || strequal(service,"ADMIN$")) {
348                         DEBUG(3,("refusing IPC connection\n"));
349                         *status = NT_STATUS_ACCESS_DENIED;
350                         return NULL;
351                 }
352
353                 DEBUG(0,("%s (%s) couldn't find service %s\n",
354                          remote_machine, client_addr(), service));
355                 *status = NT_STATUS_BAD_NETWORK_NAME;
356                 return NULL;
357         }
358
359         if (strequal(service,HOMES_NAME)) {
360                 if(lp_security() != SEC_SHARE) {
361                         if (validated_username(vuid)) {
362                                 fstring unix_username;
363                                 fstrcpy(unix_username,validated_username(vuid));
364                                 return make_connection(unix_username,
365                                                        password,dev,vuid,status);
366                         }
367                 } else {
368                         /* Security = share. Try with current_user_info.smb_name
369                          * as the username.  */
370                         if (* current_user_info.smb_name) {
371                                 fstring unix_username;
372                                 fstrcpy(unix_username,
373                                         current_user_info.smb_name);
374                                 map_username(unix_username);
375                                 return make_connection(unix_username,
376                                                        password,dev,vuid,status);
377                         }
378                 }
379         }
380
381         if (NT_STATUS_IS_ERR(*status = share_sanity_checks(snum, service, dev))) {
382                 return NULL;
383         }       
384
385         /* add it as a possible user name if we 
386            are in share mode security */
387         if (lp_security() == SEC_SHARE) {
388                 add_session_user(service);
389         }
390
391
392         /* shall we let them in? */
393         if (!authorise_login(snum,user,password,&guest,&force,vuid)) {
394                 DEBUG( 2, ( "Invalid username/password for %s [%s]\n", service, user ) );
395                 *status = NT_STATUS_WRONG_PASSWORD;
396                 return NULL;
397         }
398
399         add_session_user(user);
400   
401         conn = conn_new();
402         if (!conn) {
403                 DEBUG(0,("Couldn't find free connection.\n"));
404                 *status = NT_STATUS_INSUFFICIENT_RESOURCES;
405                 return NULL;
406         }
407
408         /* find out some info about the user */
409         pass = smb_getpwnam(user,True);
410
411         if (pass == NULL) {
412                 DEBUG(0,( "Couldn't find account %s\n",user));
413                 *status = NT_STATUS_NO_SUCH_USER;
414                 conn_free(conn);
415                 return NULL;
416         }
417
418         conn->force_user = force;
419         conn->vuid = vuid;
420         conn->uid = pass->pw_uid;
421         conn->gid = pass->pw_gid;
422         safe_strcpy(conn->client_address, client_addr(), 
423                     sizeof(conn->client_address)-1);
424         conn->num_files_open = 0;
425         conn->lastused = time(NULL);
426         conn->service = snum;
427         conn->used = True;
428         conn->printer = (strncmp(dev,"LPT",3) == 0);
429         conn->ipc = ((strncmp(dev,"IPC",3) == 0) || strequal(dev,"ADMIN$"));
430         conn->dirptr = NULL;
431         conn->veto_list = NULL;
432         conn->hide_list = NULL;
433         conn->veto_oplock_list = NULL;
434         string_set(&conn->dirpath,"");
435         string_set(&conn->user,user);
436         conn->nt_user_token = NULL;
437         
438         set_read_only(conn);
439         
440         set_admin_user(conn);
441
442         /*
443          * If force user is true, then store the
444          * given userid and also the primary groupid
445          * of the user we're forcing.
446          */
447         
448         if (*lp_force_user(snum)) {
449                 struct passwd *pass2;
450                 pstring fuser;
451                 pstrcpy(fuser,lp_force_user(snum));
452
453                 /* Allow %S to be used by force user. */
454                 pstring_sub(fuser,"%S",service);
455
456                 pass2 = (struct passwd *)Get_Pwnam_Modify(fuser);
457                 if (pass2) {
458                         conn->uid = pass2->pw_uid;
459                         conn->gid = pass2->pw_gid;
460                         string_set(&conn->user,fuser);
461                         fstrcpy(user,fuser);
462                         conn->force_user = True;
463                         DEBUG(3,("Forced user %s\n",fuser));      
464                 } else {
465                         DEBUG(1,("Couldn't find user %s\n",fuser));
466                 }
467         }
468
469         /* admin users always run as uid=0 */
470         if (conn->admin_user) {
471                 conn->uid = 0;
472         }
473
474 #ifdef HAVE_GETGRNAM 
475         /*
476          * If force group is true, then override
477          * any groupid stored for the connecting user.
478          */
479         
480         if (*lp_force_group(snum)) {
481                 gid_t gid;
482                 pstring gname;
483                 pstring tmp_gname;
484                 BOOL user_must_be_member = False;
485                 
486                 StrnCpy(tmp_gname,lp_force_group(snum),sizeof(pstring)-1);
487
488                 if (tmp_gname[0] == '+') {
489                         user_must_be_member = True;
490                         StrnCpy(gname,&tmp_gname[1],sizeof(pstring)-2);
491                 } else {
492                         StrnCpy(gname,tmp_gname,sizeof(pstring)-1);
493                 }
494                 /* default service may be a group name          */
495                 pstring_sub(gname,"%S",service);
496                 gid = nametogid(gname);
497                 
498                 if (gid != (gid_t)-1) {
499                         /*
500                          * If the user has been forced and the forced group starts
501                          * with a '+', then we only set the group to be the forced
502                          * group if the forced user is a member of that group.
503                          * Otherwise, the meaning of the '+' would be ignored.
504                          */
505                         if (conn->force_user && user_must_be_member) {
506                                 if (user_in_group_list( user, gname )) {
507                                                 conn->gid = gid;
508                                                 DEBUG(3,("Forced group %s for member %s\n",gname,user));
509                                 }
510                         } else {
511                                 conn->gid = gid;
512                                 DEBUG(3,("Forced group %s\n",gname));
513                         }
514                 } else {
515                         DEBUG(1,("Couldn't find group %s\n",gname));
516                 }
517         }
518 #endif /* HAVE_GETGRNAM */
519
520         {
521                 pstring s;
522                 pstrcpy(s,lp_pathname(snum));
523                 standard_sub_conn(conn,s);
524                 string_set(&conn->connectpath,s);
525                 DEBUG(3,("Connect path is %s\n",s));
526         }
527
528         /* groups stuff added by ih */
529         conn->ngroups = 0;
530         conn->groups = NULL;
531         
532         /* Find all the groups this uid is in and
533            store them. Used by change_to_user() */
534         initialise_groups(conn->user, conn->uid, conn->gid); 
535         get_current_groups(&conn->ngroups,&conn->groups);
536                 
537         conn->nt_user_token = create_nt_token(conn->uid, conn->gid, 
538                                               conn->ngroups, conn->groups,
539                                               guest, NULL);
540
541         /*
542          * New code to check if there's a share security descripter
543          * added from NT server manager. This is done after the
544          * smb.conf checks are done as we need a uid and token. JRA.
545          */
546
547         {
548                 BOOL can_write = share_access_check(conn, snum, vuid, FILE_WRITE_DATA);
549
550                 if (!can_write) {
551                         if (!share_access_check(conn, snum, vuid, FILE_READ_DATA)) {
552                                 /* No access, read or write. */
553                                 *status = NT_STATUS_ACCESS_DENIED;
554                                 DEBUG(0,( "make_connection: connection to %s denied due to security descriptor.\n",
555                                         service ));
556                                 conn_free(conn);
557                                 return NULL;
558                         } else {
559                                 conn->read_only = True;
560                         }
561                 }
562         }
563         /* Initialise VFS function pointers */
564
565         if (!smbd_vfs_init(conn)) {
566                 DEBUG(0, ("vfs_init failed for service %s\n", lp_servicename(SNUM(conn))));
567                 conn_free(conn);
568                 return NULL;
569         }
570
571 /* ROOT Activities: */  
572         /* check number of connections */
573         if (!claim_connection(conn,
574                               lp_servicename(SNUM(conn)),
575                               lp_max_connections(SNUM(conn)),
576                               False)) {
577                 DEBUG(1,("too many connections - rejected\n"));
578                 *status = NT_STATUS_INSUFFICIENT_RESOURCES;
579                 conn_free(conn);
580                 return NULL;
581         }  
582
583         /* Preexecs are done here as they might make the dir we are to ChDir to below */
584         /* execute any "root preexec = " line */
585         if (*lp_rootpreexec(SNUM(conn))) {
586                 int ret;
587                 pstring cmd;
588                 pstrcpy(cmd,lp_rootpreexec(SNUM(conn)));
589                 standard_sub_conn(conn,cmd);
590                 DEBUG(5,("cmd=%s\n",cmd));
591                 ret = smbrun(cmd,NULL);
592                 if (ret != 0 && lp_rootpreexec_close(SNUM(conn))) {
593                         DEBUG(1,("root preexec gave %d - failing connection\n", ret));
594                         yield_connection(conn, lp_servicename(SNUM(conn)));
595                         conn_free(conn);
596                         *status = NT_STATUS_UNSUCCESSFUL;
597                         return NULL;
598                 }
599         }
600
601 /* USER Activites: */
602         if (!change_to_user(conn, conn->vuid)) {
603                 /* No point continuing if they fail the basic checks */
604                 DEBUG(0,("Can't become connected user!\n"));
605                 conn_free(conn);
606                 *status = NT_STATUS_LOGON_FAILURE;
607                 return NULL;
608         }
609
610         /* Remember that a different vuid can connect later without these checks... */
611
612         /* Preexecs are done here as they might make the dir we are to ChDir to below */
613         /* execute any "preexec = " line */
614         if (*lp_preexec(SNUM(conn))) {
615                 int ret;
616                 pstring cmd;
617                 pstrcpy(cmd,lp_preexec(SNUM(conn)));
618                 standard_sub_conn(conn,cmd);
619                 ret = smbrun(cmd,NULL);
620                 if (ret != 0 && lp_preexec_close(SNUM(conn))) {
621                         DEBUG(1,("preexec gave %d - failing connection\n", ret));
622                         change_to_root_user();
623                         yield_connection(conn, lp_servicename(SNUM(conn)));
624                         conn_free(conn);
625                         *status = NT_STATUS_UNSUCCESSFUL;
626                         return NULL;
627                 }
628         }
629
630         if (vfs_ChDir(conn,conn->connectpath) != 0) {
631                 DEBUG(0,("%s (%s) Can't change directory to %s (%s)\n",
632                          remote_machine, conn->client_address,
633                          conn->connectpath,strerror(errno)));
634                 change_to_root_user();
635                 yield_connection(conn, lp_servicename(SNUM(conn)));
636                 conn_free(conn);
637                 *status = NT_STATUS_BAD_NETWORK_NAME;
638                 return NULL;
639         }
640         
641         string_set(&conn->origpath,conn->connectpath);
642         
643 #if SOFTLINK_OPTIMISATION
644         /* resolve any soft links early */
645         {
646                 pstring s;
647                 pstrcpy(s,conn->connectpath);
648                 vfs_GetWd(conn,s);
649                 string_set(&conn->connectpath,s);
650                 vfs_ChDir(conn,conn->connectpath);
651         }
652 #endif
653         
654         /*
655          * Print out the 'connected as' stuff here as we need
656          * to know the effective uid and gid we will be using
657          * (at least initially).
658          */
659
660         if( DEBUGLVL( IS_IPC(conn) ? 3 : 1 ) ) {
661                 dbgtext( "%s (%s) ", remote_machine, conn->client_address );
662                 dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) );
663                 dbgtext( "initially as user %s ", user );
664                 dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
665                 dbgtext( "(pid %d)\n", (int)sys_getpid() );
666         }
667         
668         /* Add veto/hide lists */
669         if (!IS_IPC(conn) && !IS_PRINT(conn)) {
670                 set_namearray( &conn->veto_list, lp_veto_files(SNUM(conn)));
671                 set_namearray( &conn->hide_list, lp_hide_files(SNUM(conn)));
672                 set_namearray( &conn->veto_oplock_list, lp_veto_oplocks(SNUM(conn)));
673         }
674         
675         /* Invoke VFS make connection hook */
676
677         if (conn->vfs_ops.connect) {
678                 if (conn->vfs_ops.connect(conn, service, user) < 0) {
679                         DEBUG(0,("make_connection: VFS make connection failed!\n"));
680                         *status = NT_STATUS_UNSUCCESSFUL;
681                         change_to_root_user();
682                         conn_free(conn);
683                         return NULL;
684                 }
685         }
686
687         /* we've finished with the user stuff - go back to root */
688         change_to_root_user();
689             
690         return(conn);
691 }
692
693
694 /****************************************************************************
695 close a cnum
696 ****************************************************************************/
697 void close_cnum(connection_struct *conn, uint16 vuid)
698 {
699         DirCacheFlush(SNUM(conn));
700
701         change_to_root_user();
702
703         DEBUG(IS_IPC(conn)?3:1, ("%s (%s) closed connection to service %s\n",
704                                  remote_machine,conn->client_address,
705                                  lp_servicename(SNUM(conn))));
706
707         if (conn->vfs_ops.disconnect != NULL) {
708
709             /* Call VFS disconnect hook */
710             
711             conn->vfs_ops.disconnect(conn);
712             
713         }
714
715         yield_connection(conn, lp_servicename(SNUM(conn)));
716
717         file_close_conn(conn);
718         dptr_closecnum(conn);
719
720         /* execute any "postexec = " line */
721         if (*lp_postexec(SNUM(conn)) && 
722             change_to_user(conn, vuid))  {
723                 pstring cmd;
724                 pstrcpy(cmd,lp_postexec(SNUM(conn)));
725                 standard_sub_conn(conn,cmd);
726                 smbrun(cmd,NULL);
727                 change_to_root_user();
728         }
729
730         change_to_root_user();
731         /* execute any "root postexec = " line */
732         if (*lp_rootpostexec(SNUM(conn)))  {
733                 pstring cmd;
734                 pstrcpy(cmd,lp_rootpostexec(SNUM(conn)));
735                 standard_sub_conn(conn,cmd);
736                 smbrun(cmd,NULL);
737         }
738         conn_free(conn);
739 }