Added manpages.
[samba.git] / source / client / smbmount.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB client
5    Copyright (C) Andrew Tridgell 1994-1997
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 #ifdef SYSLOG
23 #undef SYSLOG
24 #endif
25
26 #include "includes.h"
27 #include <linux/smb_fs.h>
28 static struct smb_conn_opt conn_options;
29
30 #ifndef REGISTER
31 #define REGISTER 0
32 #endif
33
34 pstring cur_dir = "\\";
35 pstring cd_path = "";
36 extern pstring service;
37 extern pstring desthost;
38 extern pstring myname;
39 extern pstring myhostname;
40 extern pstring password;
41 extern pstring username;
42 extern pstring workgroup;
43 char *cmdstr="";
44 extern BOOL got_pass;
45 extern BOOL connect_as_printer;
46 extern BOOL connect_as_ipc;
47 extern struct in_addr ipzero;
48
49 extern BOOL doencrypt;
50
51 extern pstring user_socket_options;
52
53 /* 30 second timeout on most commands */
54 #define CLIENT_TIMEOUT (30*1000)
55 #define SHORT_TIMEOUT (5*1000)
56
57 /* value for unused fid field in trans2 secondary request */
58 #define FID_UNUSED (0xFFFF)
59
60 extern int name_type;
61
62 extern int max_protocol;
63
64
65 time_t newer_than = 0;
66 int archive_level = 0;
67
68 extern pstring debugf;
69 extern int DEBUGLEVEL;
70
71 BOOL translation = False;
72
73 extern int cnum;
74 extern int mid;
75 extern int pid;
76 extern int tid;
77 extern int gid;
78 extern int uid;
79
80 extern BOOL have_ip;
81 extern int max_xmit;
82
83 /* clitar bits insert */
84 extern int blocksize;
85 extern BOOL tar_inc;
86 extern BOOL tar_reset;
87 /* clitar bits end */
88  
89
90 int myumask = 0755;
91
92 extern pstring scope;
93
94 BOOL prompt = True;
95
96 int printmode = 1;
97
98 BOOL recurse = False;
99 BOOL lowercase = False;
100
101 struct in_addr dest_ip;
102
103 #define SEPARATORS " \t\n\r"
104
105 BOOL abort_mget = True;
106
107 extern int Protocol;
108
109 extern BOOL readbraw_supported ;
110 extern BOOL writebraw_supported;
111
112 pstring fileselection = "";
113
114 extern file_info def_finfo;
115
116 /* timing globals */
117 int get_total_size = 0;
118 int get_total_time_ms = 0;
119 int put_total_size = 0;
120 int put_total_time_ms = 0;
121
122 /* totals globals */
123 int dir_total = 0;
124
125 extern int Client;
126
127 #define USENMB
128
129 static BOOL setup_term_code(char *code)
130 {
131         interpret_coding_system(code);
132         return True;
133 }
134 #define CNV_LANG(s) dos2unix_format(s,False)
135 #define CNV_INPUT(s) unix2dos_format(s,True)
136
137 /****************************************************************************
138 check for existance of a dir
139 ****************************************************************************/
140 static BOOL chkpath(char *path,BOOL report)
141 {
142   fstring path2;
143   pstring inbuf,outbuf;
144   char *p;
145
146   strcpy(path2,path);
147   trim_string(path2,NULL,"\\");
148   if (!*path2) *path2 = '\\';
149
150   bzero(outbuf,smb_size);
151   set_message(outbuf,0,4 + strlen(path2),True);
152   SCVAL(outbuf,smb_com,SMBchkpth);
153   SSVAL(outbuf,smb_tid,cnum);
154   cli_setup_pkt(outbuf);
155
156   p = smb_buf(outbuf);
157   *p++ = 4;
158   strcpy(p,path2);
159
160 #if 0
161   {
162           /* this little bit of code can be used to extract NT error codes.
163              Just feed a bunch of "cd foo" commands to smbclient then watch
164              in netmon (tridge) */
165           static int code=0;
166           SIVAL(outbuf, smb_rcls, code | 0xC0000000);
167           SSVAL(outbuf, smb_flg2, SVAL(outbuf, smb_flg2) | (1<<14));
168           code++;
169   }
170 #endif
171
172   send_smb(Client,outbuf);
173   client_receive_smb(Client,inbuf,CLIENT_TIMEOUT);
174
175   if (report && CVAL(inbuf,smb_rcls) != 0)
176     DEBUG(2,("chkpath: %s\n",smb_errstr(inbuf)));
177
178   return(CVAL(inbuf,smb_rcls) == 0);
179 }
180
181
182 /* #define SMBFS_DEBUG 1 */
183
184 static void
185 daemonize(void)
186 {
187         int i;
188         if ((i = fork()) < 0)
189         {
190                 DEBUG(0, ("could not fork\n"));
191         }
192         if (i > 0)
193         {
194                 /* parent simply exits */
195                 exit(0);
196         }
197         setsid();
198         chdir("/");
199 }
200
201 static void
202 close_our_files(void)
203 {
204         int i;
205         for (i = 0; i < NR_OPEN; i++) {
206                 if (i == Client) {
207                         continue;
208                 }
209                 close(i);
210         }
211 }
212
213 static void
214 usr1_handler(int x)
215 {
216         return;
217 }
218
219 /*
220  * Send a login and store the connection options. This is a separate
221  * function to keep clientutil.c independent of linux kernel changes.
222  */
223 static BOOL mount_send_login(char *inbuf, char *outbuf)
224 {
225   struct connection_options opt;
226   int res = cli_send_login(inbuf, outbuf, True, True, &opt);
227
228   if (!res)
229     return res;
230
231   conn_options.protocol = opt.protocol;
232   conn_options.case_handling = CASE_LOWER;
233   conn_options.max_xmit = opt.max_xmit;
234   conn_options.server_uid = opt.server_uid;
235   conn_options.tid = opt.tid;
236   conn_options.secmode = opt.sec_mode;
237   conn_options.maxmux = opt.max_mux;
238   conn_options.maxvcs = opt.max_vcs;
239   conn_options.rawmode = opt.rawmode;
240   conn_options.sesskey = opt.sesskey;
241   conn_options.maxraw = opt.maxraw;
242   conn_options.capabilities = opt.capabilities;
243   conn_options.serverzone = opt.serverzone;
244
245   return True;
246 }
247
248 /*
249  * Call the smbfs ioctl to install a connection socket,
250  * then wait for a signal to reconnect. Note that we do
251  * not exit after open_sockets() or send_login() errors,
252  * as the smbfs mount would then have no way to recover.
253  */
254 static void
255 send_fs_socket(char *mount_point, char *inbuf, char *outbuf)
256 {
257         int fd, closed = 0, res = 1;
258
259         while (1)
260         {
261                 if ((fd = open(mount_point, O_RDONLY)) < 0)
262                 {
263 #ifdef SMBFS_DEBUG
264                         printf("smbclient: can't open %s\n", mount_point);
265 #endif
266                         break;
267                 }               
268
269                 /*
270                  * Call the ioctl even if we couldn't get a socket ...
271                  * there's no point in making smbfs wait for a timeout.
272                  */
273                 conn_options.fd = -1;
274                 if (res)
275                         conn_options.fd = Client;
276                 res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
277                 if (res != 0)
278                 {
279 #ifdef SMBFS_DEBUG
280                         printf("smbclient: ioctl failed, res=%d\n",res);
281 #endif
282                 }
283
284                 close_sockets();
285                 close(fd);
286                 /*
287                  * Close all open files if we haven't done so yet.
288                  */
289 #ifndef SMBFS_DEBUG
290                 if (!closed)
291                 {
292                         closed = 1;
293                         close_our_files();
294                 }
295 #endif
296
297                 /*
298                  * Wait for a signal from smbfs ...
299                  */
300                 signal(SIGUSR1, &usr1_handler);
301                 pause();
302 #ifdef SMBFS_DEBUG
303                 printf("smbclient: got signal, getting new socket\n");
304 #endif
305
306                 res = mount_send_login(inbuf,outbuf);
307                 if (!res)
308                 {
309 #ifdef SMBFS_DEBUG
310                         printf("smbclient: login failed\n");
311 #endif
312                 }
313         }
314 #ifdef SMBFS_DEBUG
315         printf("smbclient: exit\n");
316 #endif
317         exit(1);
318 }
319
320 /****************************************************************************
321 mount smbfs
322 ****************************************************************************/
323 static void cmd_mount(char *inbuf,char *outbuf)
324 {
325         pstring mpoint;
326         char mount_point[MAXPATHLEN+1];
327         pstring mount_command;
328         fstring buf;
329         int retval;
330
331         if (!next_token(NULL, mpoint, NULL))
332         {
333                 DEBUG(0,("You must supply a mount point\n"));
334                 return;
335         }
336
337         memset(mount_point, 0, sizeof(mount_point));
338
339         if (realpath(mpoint, mount_point) == NULL)
340         {
341                 DEBUG(0, ("Could not resolve mount point\n"));
342                 return;
343         }
344
345         sprintf(mount_command, "smbmnt %s", mount_point);
346
347         while(next_token(NULL, buf, NULL))
348         {
349                 strcat(mount_command, " ");
350                 strcat(mount_command, buf);
351         }
352
353         DEBUG(3,("mount command: %s\n", mount_command));
354
355         /*
356          * Create the background process before trying the mount.
357          * (We delay closing files to allow diagnostic messages.)
358          */
359         daemonize();
360
361         /* The parent has exited here, the child handles the connection: */
362         if ((retval = system(mount_command)) != 0)
363         {
364                 DEBUG(0,("mount failed\n"));
365                 exit(1);
366         }
367         send_fs_socket(mount_point, inbuf, outbuf);
368 }       
369
370
371
372
373
374 /* This defines the commands supported by this client */
375 struct
376 {
377   char *name;
378   void (*fn)();
379   char *description;
380 } commands[] = 
381 {
382   {"mount", cmd_mount, "<mount-point options> mount an smbfs file system"},
383   {"",NULL,NULL}
384 };
385
386
387 /*******************************************************************
388   lookup a command string in the list of commands, including 
389   abbreviations
390   ******************************************************************/
391 static int process_tok(fstring tok)
392 {
393   int i = 0, matches = 0;
394   int cmd=0;
395   int tok_len = strlen(tok);
396   
397   while (commands[i].fn != NULL)
398     {
399       if (strequal(commands[i].name,tok))
400         {
401           matches = 1;
402           cmd = i;
403           break;
404         }
405       else if (strnequal(commands[i].name, tok, tok_len))
406         {
407           matches++;
408           cmd = i;
409         }
410       i++;
411     }
412   
413   if (matches == 0)
414     return(-1);
415   else if (matches == 1)
416     return(cmd);
417   else
418     return(-2);
419 }
420
421 /****************************************************************************
422 help
423 ****************************************************************************/
424 void cmd_help(void)
425 {
426   int i=0,j;
427   fstring buf;
428
429   if (next_token(NULL,buf,NULL))
430     {
431       if ((i = process_tok(buf)) >= 0)
432         DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));                   
433     }
434   else
435     while (commands[i].description)
436       {
437         for (j=0; commands[i].description && (j<5); j++) {
438           DEBUG(0,("%-15s",commands[i].name));
439           i++;
440         }
441         DEBUG(0,("\n"));
442       }
443 }
444
445 /****************************************************************************
446 wait for keyboard activity, swallowing network packets
447 ****************************************************************************/
448 #ifdef CLIX
449 static char wait_keyboard(char *buffer)
450 #else
451 static void wait_keyboard(char *buffer)
452 #endif
453 {
454   fd_set fds;
455   int selrtn;
456   struct timeval timeout;
457   
458 #ifdef CLIX
459   int delay = 0;
460 #endif
461   
462   while (1) 
463     {
464       extern int Client;
465       FD_ZERO(&fds);
466       FD_SET(Client,&fds);
467 #ifndef CLIX
468       FD_SET(fileno(stdin),&fds);
469 #endif
470
471       timeout.tv_sec = 20;
472       timeout.tv_usec = 0;
473 #ifdef CLIX
474       timeout.tv_sec = 0;
475 #endif
476       selrtn = sys_select(&fds,&timeout);
477       
478 #ifndef CLIX
479       if (FD_ISSET(fileno(stdin),&fds))
480         return;
481 #else
482       {
483         char ch;
484         int readret;
485
486     set_blocking(fileno(stdin), False); 
487         readret = read_data( fileno(stdin), &ch, 1);
488         set_blocking(fileno(stdin), True);
489         if (readret == -1)
490           {
491             if (errno != EAGAIN)
492               {
493                 /* should crash here */
494                 DEBUG(1,("readchar stdin failed\n"));
495               }
496           }
497         else if (readret != 0)
498           {
499             return ch;
500           }
501       }
502 #endif
503
504       /* We deliberately use receive_smb instead of
505          client_receive_smb as we want to receive
506          session keepalives and then drop them here.
507        */
508       if (FD_ISSET(Client,&fds))
509         receive_smb(Client,buffer,0);
510       
511 #ifdef CLIX
512       delay++;
513       if (delay > 100000)
514         {
515           delay = 0;
516           chkpath("\\",False);
517         }
518 #else
519       chkpath("\\",False);
520 #endif
521     }  
522 }
523
524
525 /****************************************************************************
526   process commands from the client
527 ****************************************************************************/
528 static BOOL process(char *base_directory)
529 {
530   extern FILE *dbf;
531   pstring line;
532   char *cmd;
533
534   char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
535   char *OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
536
537   if ((InBuffer == NULL) || (OutBuffer == NULL)) 
538     return(False);
539   
540   bzero(OutBuffer,smb_size);
541
542   if (!mount_send_login(InBuffer,OutBuffer))
543     return(False);
544
545   cmd = cmdstr;
546   if (cmd[0] != '\0') while (cmd[0] != '\0')
547     {
548       char *p;
549       fstring tok;
550       int i;
551
552       if ((p = strchr(cmd, ';')) == 0)
553         {
554           strncpy(line, cmd, 999);
555           line[1000] = '\0';
556           cmd += strlen(cmd);
557         }
558       else
559         {
560           if (p - cmd > 999) p = cmd + 999;
561           strncpy(line, cmd, p - cmd);
562           line[p - cmd] = '\0';
563           cmd = p + 1;
564         }
565
566       /* input language code to internal one */
567       CNV_INPUT (line);
568       
569       /* and get the first part of the command */
570       {
571         char *ptr = line;
572         if (!next_token(&ptr,tok,NULL)) continue;
573       }
574
575       if ((i = process_tok(tok)) >= 0)
576         commands[i].fn(InBuffer,OutBuffer);
577       else if (i == -2)
578         DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
579       else
580         DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
581     }
582   else while (!feof(stdin))
583     {
584       fstring tok;
585       int i;
586
587       bzero(OutBuffer,smb_size);
588
589       /* display a prompt */
590       DEBUG(0,("smb: %s> ", CNV_LANG(cur_dir)));
591       fflush(dbf);
592
593 #ifdef CLIX
594       line[0] = wait_keyboard(InBuffer);
595       /* this might not be such a good idea... */
596       if ( line[0] == EOF)
597         break;
598 #else
599       wait_keyboard(InBuffer);
600 #endif
601   
602       /* and get a response */
603 #ifdef CLIX
604       fgets( &line[1],999, stdin);
605 #else
606       if (!fgets(line,1000,stdin))
607         break;
608 #endif
609
610       /* input language code to internal one */
611       CNV_INPUT (line);
612
613       /* special case - first char is ! */
614       if (*line == '!')
615         {
616           system(line + 1);
617           continue;
618         }
619       
620       /* and get the first part of the command */
621       {
622         char *ptr = line;
623         if (!next_token(&ptr,tok,NULL)) continue;
624       }
625
626       if ((i = process_tok(tok)) >= 0)
627         commands[i].fn(InBuffer,OutBuffer);
628       else if (i == -2)
629         DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok)));
630       else
631         DEBUG(0,("%s: command not found\n",CNV_LANG(tok)));
632     }
633   
634   cli_send_logout();
635   return(True);
636 }
637
638 /****************************************************************************
639 usage on the program
640 ****************************************************************************/
641 static void usage(char *pname)
642 {
643   DEBUG(0,("Usage: %s service <password> [-p port] [-d debuglevel] [-l log] ",
644            pname));
645
646   DEBUG(0,("\nVersion %s\n",VERSION));
647   DEBUG(0,("\t-p port               connect to the specified port\n"));
648   DEBUG(0,("\t-d debuglevel         set the debuglevel\n"));
649   DEBUG(0,("\t-l log basename.      Basename for log/debug files\n"));
650   DEBUG(0,("\t-n netbios name.      Use this name as my netbios name\n"));
651   DEBUG(0,("\t-N                    don't ask for a password\n"));
652   DEBUG(0,("\t-m max protocol       set the max protocol level\n"));
653   DEBUG(0,("\t-I dest IP            use this IP to connect to\n"));
654   DEBUG(0,("\t-E                    write messages to stderr instead of stdout\n"));
655   DEBUG(0,("\t-U username           set the network username\n"));
656   DEBUG(0,("\t-W workgroup          set the workgroup name\n"));
657   DEBUG(0,("\t-c command string     execute semicolon separated commands\n"));
658   DEBUG(0,("\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
659   DEBUG(0,("\t-D directory          start from directory\n"));
660   DEBUG(0,("\n"));
661 }
662
663 /****************************************************************************
664   main program
665 ****************************************************************************/
666  int main(int argc,char *argv[])
667 {
668   fstring base_directory;
669   char *pname = argv[0];
670   int port = SMB_PORT;
671   int opt;
672   extern FILE *dbf;
673   extern char *optarg;
674   extern int optind;
675   pstring query_host;
676   BOOL nt_domain_logon = False;
677   static pstring servicesf = CONFIGFILE;
678   pstring term_code;
679   char *p;
680
681 #ifdef KANJI
682   strcpy(term_code, KANJI);
683 #else /* KANJI */
684   *term_code = 0;
685 #endif /* KANJI */
686
687   *query_host = 0;
688   *base_directory = 0;
689
690   DEBUGLEVEL = 2;
691
692   setup_logging(pname,True);
693
694   TimeInit();
695   charset_initialise();
696
697   pid = getpid();
698   uid = getuid();
699   gid = getgid();
700   mid = pid + 100;
701   myumask = umask(0);
702   umask(myumask);
703
704   if (getenv("USER"))
705   {
706     strcpy(username,getenv("USER"));
707
708     /* modification to support userid%passwd syntax in the USER var
709        25.Aug.97, jdblair@uab.edu */
710
711     if ((p=strchr(username,'%')))
712     {
713       *p = 0;
714       strcpy(password,p+1);
715       got_pass = True;
716       memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
717     }
718     strupper(username);
719   }
720
721  /* modification to support PASSWD environmental var
722   25.Aug.97, jdblair@uab.edu */
723
724   if (getenv("PASSWD"))
725     strcpy(password,getenv("PASSWD"));
726
727   if (*username == 0 && getenv("LOGNAME"))
728     {
729       strcpy(username,getenv("LOGNAME"));
730       strupper(username);
731     }
732
733   if (argc < 2)
734     {
735       usage(pname);
736       exit(1);
737     }
738   
739   if (*argv[1] != '-')
740     {
741
742       strcpy(service,argv[1]);  
743       /* Convert any '/' characters in the service name to '\' characters */
744       string_replace( service, '/','\\');
745       argc--;
746       argv++;
747
748       if (count_chars(service,'\\') < 3)
749         {
750           usage(pname);
751           printf("\n%s: Not enough '\\' characters in service\n",service);
752           exit(1);
753         }
754
755 /*
756       if (count_chars(service,'\\') > 3)
757         {
758           usage(pname);
759           printf("\n%s: Too many '\\' characters in service\n",service);
760           exit(1);
761         }
762         */
763
764       if (argc > 1 && (*argv[1] != '-'))
765         {
766           got_pass = True;
767           strcpy(password,argv[1]);  
768           memset(argv[1],'X',strlen(argv[1]));
769           argc--;
770           argv++;
771         }
772     }
773
774   while ((opt = 
775           getopt(argc, argv,"s:B:O:M:S:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
776     switch (opt)
777       {
778       case 'm':
779         max_protocol = interpret_protocol(optarg,max_protocol);
780         break;
781       case 'O':
782         strcpy(user_socket_options,optarg);
783         break;  
784       case 'S':
785         strcpy(desthost,optarg);
786         strupper(desthost);
787         nt_domain_logon = True;
788         break;
789       case 'B':
790         iface_set_default(NULL,optarg,NULL);
791         break;
792       case 'D':
793         strcpy(base_directory,optarg);
794         break;
795       case 'i':
796         strcpy(scope,optarg);
797         break;
798       case 'U':
799         {
800           char *lp;
801         strcpy(username,optarg);
802         if ((lp=strchr(username,'%')))
803           {
804             *lp = 0;
805             strcpy(password,lp+1);
806             got_pass = True;
807             memset(strchr(optarg,'%')+1,'X',strlen(password));
808           }
809         }
810             
811         break;
812       case 'W':
813         strcpy(workgroup,optarg);
814         break;
815       case 'E':
816         dbf = stderr;
817         break;
818       case 'I':
819         {
820           dest_ip = *interpret_addr2(optarg);
821           if (zero_ip(dest_ip)) exit(1);
822           have_ip = True;
823         }
824         break;
825       case 'n':
826         strcpy(myname,optarg);
827         break;
828       case 'N':
829         got_pass = True;
830         break;
831       case 'd':
832         if (*optarg == 'A')
833           DEBUGLEVEL = 10000;
834         else
835           DEBUGLEVEL = atoi(optarg);
836         break;
837       case 'l':
838         sprintf(debugf,"%s.client",optarg);
839         break;
840       case 'p':
841         port = atoi(optarg);
842         break;
843       case 'c':
844         cmdstr = optarg;
845         got_pass = True;
846         break;
847       case 'h':
848         usage(pname);
849         exit(0);
850         break;
851       case 's':
852         strcpy(servicesf, optarg);
853         break;
854       case 't':
855         strcpy(term_code, optarg);
856         break;
857       default:
858         usage(pname);
859         exit(1);
860       }
861
862   if (!*query_host && !*service)
863     {
864       usage(pname);
865       exit(1);
866     }
867
868
869   DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
870
871   if(!get_myname(myhostname,NULL))
872   {
873     DEBUG(0,("Failed to get my hostname.\n"));
874   }
875
876   if (!lp_load(servicesf,True)) {
877     fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
878   }
879
880   codepage_initialise(lp_client_code_page());
881
882   if(lp_client_code_page() == KANJI_CODEPAGE)
883   {
884         if (!setup_term_code (term_code))
885     {
886             DEBUG(0, ("%s: unknown terminal code name\n", optarg));
887             usage (pname);
888             exit (1);
889         }
890   }
891
892   if (*workgroup == 0)
893     strcpy(workgroup,lp_workgroup());
894
895   load_interfaces();
896   get_myname((*myname)?NULL:myname,NULL);  
897   strupper(myname);
898
899 #ifdef NTDOMAIN
900
901         if (nt_domain_logon)
902         {
903                 int ret = 0;
904                 sprintf(service,"\\\\%s\\IPC$",query_host);
905                 strupper(service);
906                 connect_as_ipc = True;
907
908                 DEBUG(5,("NT Domain Logon.  Service: %s\n", service));
909
910                 if (cli_open_sockets(port))
911                 {
912                         if (!cli_send_login(NULL,NULL,True,True,NULL)) return(1);
913
914                         do_nt_login(desthost, myhostname, Client, cnum);
915
916                         cli_send_logout();
917                         close_sockets();
918                 }
919
920                 return(ret);
921         }
922 #endif 
923
924   if (cli_open_sockets(port))
925     {
926       if (!process(base_directory))
927         {
928           close_sockets();
929           return(1);
930         }
931       close_sockets();
932     }
933   else
934     return(1);
935
936   return(0);
937 }