259c10d11f3a32e4c5ed772e52a216ace064add5
[ira/wip.git] / source3 / rpcclient / rpcclient.c
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    SMB client
5    Copyright (C) Andrew Tridgell 1994-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 #ifdef SYSLOG
23 #undef SYSLOG
24 #endif
25
26 #include "includes.h"
27
28 #ifndef REGISTER
29 #define REGISTER 0
30 #endif
31
32 extern pstring debugf;
33 extern pstring scope;
34 extern pstring global_myname;
35
36 extern pstring user_socket_options;
37
38
39 extern int DEBUGLEVEL;
40
41
42 #define CNV_LANG(s) dos2unix_format(s,False)
43 #define CNV_INPUT(s) unix2dos_format(s,True)
44
45 static int process_tok(fstring tok);
46 static void cmd_help(struct client_info *info);
47 static void cmd_quit(struct client_info *info);
48
49 static struct cli_state smbcli;
50 struct cli_state *smb_cli = &smbcli;
51
52 FILE *out_hnd;
53
54 /****************************************************************************
55 initialise smb client structure
56 ****************************************************************************/
57 void rpcclient_init(void)
58 {
59         bzero(smb_cli, sizeof(smb_cli));
60         cli_initialise(smb_cli);
61         smb_cli->capabilities |= CAP_NT_SMBS | CAP_STATUS32;
62 }
63
64 /****************************************************************************
65 make smb client connection
66 ****************************************************************************/
67 static BOOL rpcclient_connect(struct client_info *info)
68 {
69         struct nmb_name calling;
70         struct nmb_name called;
71
72         make_nmb_name(&called , dns_to_netbios_name(info->dest_host ), info->name_type, scope);
73         make_nmb_name(&calling, dns_to_netbios_name(info->myhostname), 0x0            , scope);
74
75         if (!cli_establish_connection(smb_cli, 
76                                   info->dest_host, &info->dest_ip, 
77                                   &calling, &called,
78                                   info->share, info->svc_type,
79                                   False, True))
80         {
81                 DEBUG(0,("rpcclient_connect: connection failed\n"));
82                 cli_shutdown(smb_cli);
83                 return False;
84         }
85
86         return True;
87 }
88
89 /****************************************************************************
90 stop the smb connection(s?)
91 ****************************************************************************/
92 static void rpcclient_stop(void)
93 {
94         cli_shutdown(smb_cli);
95 }
96 /****************************************************************************
97  This defines the commands supported by this client
98  ****************************************************************************/
99 struct
100 {
101   char *name;
102   void (*fn)(struct client_info*);
103   char *description;
104 } commands[] = 
105 {
106   {"eventlog",   cmd_eventlog,         "list the events"},
107   {"svcenum",    cmd_svc_enum,         "[-i] Lists Services Manager"},
108   {"at",         cmd_at,               "Scheduler control (at /? for syntax)"},
109   {"time",       cmd_time,             "Display remote time"},
110   {"regenum",    cmd_reg_enum,         "<keyname> Registry Enumeration (keys, values)"},
111   {"regdeletekey",cmd_reg_delete_key,  "<keyname> Registry Key Delete"},
112   {"regcreatekey",cmd_reg_create_key,  "<keyname> [keyclass] Registry Key Create"},
113   {"shutdown",cmd_reg_shutdown,  "[-m message] [-t timeout] [-r or --reboot] Server Shutdown"},
114   {"regquerykey",cmd_reg_query_key,    "<keyname> Registry Key Query"},
115   {"regdeleteval",cmd_reg_delete_val,  "<valname> Registry Value Delete"},
116   {"regcreateval",cmd_reg_create_val,  "<valname> <valtype> <value> Registry Key Create"},
117   {"reggetsec",  cmd_reg_get_key_sec,  "<keyname> Registry Key Security"},
118   {"regtestsec", cmd_reg_test_key_sec, "<keyname> Test Registry Key Security"},
119   {"ntlogin",    cmd_netlogon_login_test, "[username] [password] NT Domain login test"},
120   {"domtrust",    cmd_netlogon_domain_test, "<domain> NT Inter-Domain test"},
121   {"wksinfo",    cmd_wks_query_info,   "Workstation Query Info"},
122   {"srvinfo",    cmd_srv_query_info,   "Server Query Info"},
123   {"srvsessions",cmd_srv_enum_sess,    "List sessions on a server"},
124   {"srvshares",  cmd_srv_enum_shares,  "List shares on a server"},
125   {"srvconnections",cmd_srv_enum_conn, "List connections on a server"},
126   {"srvfiles",   cmd_srv_enum_files,   "List files on a server"},
127   {"lsaquery",   cmd_lsa_query_info,   "Query Info Policy (domain member or server)"},
128   {"lookupsids", cmd_lsa_lookup_sids,  "Resolve names from SIDs"},
129   {"lookupnames",cmd_lsa_lookup_names,  "Resolve SIDs from names"},
130   {"lookupdomain",cmd_sam_lookup_domain, "Obtain SID for a local domain"},
131   {"enumusers",  cmd_sam_enum_users,   "SAM User Database Query (experimental!)"},
132   {"addgroupmem",cmd_sam_add_groupmem,"<group rid> [member rid1] [member rid2] ... SAM Add Domain Group Member"},
133   {"addaliasmem",cmd_sam_add_aliasmem,"<alias rid> [member sid1] [member sid2] ... SAM Add Domain Alias Member"},
134   {"creategroup",cmd_sam_create_dom_group,"SAM Create Domain Group"},
135   {"createalias",cmd_sam_create_dom_alias,"SAM Create Domain Alias"},
136   {"createuser", cmd_sam_create_dom_user,"<username> SAM Create Domain User"},
137   {"delgroup",   cmd_sam_delete_dom_group,"SAM Delete Domain Group"},
138   {"delalias",   cmd_sam_delete_dom_alias,"SAM Delete Domain Alias"},
139   {"ntpass",     cmd_sam_ntchange_pwd, "NT SAM Password Change"},
140   {"samuser",    cmd_sam_query_user,   "<username> SAM User Query (experimental!)"},
141   {"samtest",    cmd_sam_test      ,   "SAM User Encrypted RPC test (experimental!)"},
142   {"enumaliases",cmd_sam_enum_aliases, "SAM Aliases Database Query (experimental!)"},
143   {"enumgroups", cmd_sam_enum_groups,  "SAM Group Database Query (experimental!)"},
144   {"samgroups",  cmd_sam_query_dominfo, "SAM Query Domain Info(experimental!)"},
145   {"querysecret", cmd_lsa_query_secret, "LSA Query Secret (developer use)"},
146   {"samsync",    cmd_sam_sync,    "SAM Synchronization Test (experimental)"},
147   {"quit",       cmd_quit,        "logoff the server"},
148   {"q",          cmd_quit,        "logoff the server"},
149   {"exit",       cmd_quit,        "logoff the server"},
150   {"bye",        cmd_quit,        "logoff the server"},
151   {"help",       cmd_help,        "[command] give help on a command"},
152   {"?",          cmd_help,        "[command] give help on a command"},
153   {"!",          NULL,            "run a shell command on the local system"},
154   {"",           NULL,            NULL}
155 };
156
157
158 /****************************************************************************
159 do a (presumably graceful) quit...
160 ****************************************************************************/
161 static void cmd_quit(struct client_info *info)
162 {
163         rpcclient_stop();
164 #ifdef MEM_MAN
165         {
166                 extern FILE* dbf;
167                 smb_mem_write_status(dbf);
168                 smb_mem_write_errors(dbf);
169                 smb_mem_write_verbose(dbf);
170                 dbgflush();
171         }
172 #endif
173         exit(0);
174 }
175
176 /****************************************************************************
177 help
178 ****************************************************************************/
179 static void cmd_help(struct client_info *info)
180 {
181   int i=0,j;
182   fstring buf;
183
184   if (next_token(NULL,buf,NULL, sizeof(buf)))
185     {
186       if ((i = process_tok(buf)) >= 0)
187         fprintf(out_hnd, "HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description);                    
188     }
189   else
190     while (commands[i].description)
191       {
192         for (j=0; commands[i].description && (j<5); j++) {
193           fprintf(out_hnd, "%-15s",commands[i].name);
194           i++;
195         }
196         fprintf(out_hnd, "\n");
197       }
198 }
199
200 /*******************************************************************
201   lookup a command string in the list of commands, including 
202   abbreviations
203   ******************************************************************/
204 static int process_tok(fstring tok)
205 {
206   int i = 0, matches = 0;
207   int cmd=0;
208   int tok_len = strlen(tok);
209   
210   while (commands[i].fn != NULL)
211     {
212       if (strequal(commands[i].name,tok))
213         {
214           matches = 1;
215           cmd = i;
216           break;
217         }
218       else if (strnequal(commands[i].name, tok, tok_len))
219         {
220           matches++;
221           cmd = i;
222         }
223       i++;
224     }
225   
226   if (matches == 0)
227     return(-1);
228   else if (matches == 1)
229     return(cmd);
230   else
231     return(-2);
232 }
233
234 /****************************************************************************
235 wait for keyboard activity, swallowing network packets
236 ****************************************************************************/
237 static void wait_keyboard(struct cli_state *cli)
238 {
239   fd_set fds;
240   struct timeval timeout;
241   
242   while (1) 
243     {
244       FD_ZERO(&fds);
245       FD_SET(cli->fd,&fds);
246       FD_SET(fileno(stdin),&fds);
247
248       timeout.tv_sec = 20;
249       timeout.tv_usec = 0;
250       sys_select(MAX(cli->fd,fileno(stdin))+1,&fds,&timeout);
251       
252       if (FD_ISSET(fileno(stdin),&fds))
253         return;
254
255       /* We deliberately use receive_smb instead of
256          client_receive_smb as we want to receive
257          session keepalives and then drop them here.
258        */
259       if (FD_ISSET(cli->fd,&fds))
260         receive_smb(cli->fd,cli->inbuf,0);
261     }  
262 }
263
264 /****************************************************************************
265   process commands from the client
266 ****************************************************************************/
267 static void do_command(struct client_info *info, char *tok, char *line)
268 {
269         int i;
270
271         if ((i = process_tok(tok)) >= 0)
272         {
273                 commands[i].fn(info);
274         }
275         else if (i == -2)
276         {
277                 fprintf(out_hnd, "%s: command abbreviation ambiguous\n", CNV_LANG(tok));
278         }
279         else
280         {
281                 fprintf(out_hnd, "%s: command not found\n", CNV_LANG(tok));
282         }
283 }
284
285 /****************************************************************************
286   process commands from the client
287 ****************************************************************************/
288 static BOOL process( struct client_info *info, char *cmd_str)
289 {
290         pstring line;
291         char *cmd = cmd_str;
292
293         if (cmd[0] != '\0') while (cmd[0] != '\0')
294         {
295                 char *p;
296                 fstring tok;
297
298                 if ((p = strchr(cmd, ';')) == 0)
299                 {
300                         strncpy(line, cmd, 999);
301                         line[1000] = '\0';
302                         cmd += strlen(cmd);
303                 }
304                 else
305                 {
306                         if (p - cmd > 999) p = cmd + 999;
307                         strncpy(line, cmd, p - cmd);
308                         line[p - cmd] = '\0';
309                         cmd = p + 1;
310                 }
311
312                 /* input language code to internal one */
313                 CNV_INPUT (line);
314
315                 /* get the first part of the command */
316                 {
317                         char *ptr = line;
318                         if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
319                 }
320
321                 do_command(info, tok, line);
322         }
323         else while (!feof(stdin))
324         {
325                 fstring tok;
326
327                 /* display a prompt */
328                 fprintf(out_hnd, "smb: %s> ", CNV_LANG(info->cur_dir));
329                 fflush(out_hnd);
330
331 #ifdef CLIX
332                 line[0] = wait_keyboard(smb_cli);
333                 /* this might not be such a good idea... */
334                 if ( line[0] == EOF)
335                 {
336                         break;
337                 }
338 #else
339                 wait_keyboard(smb_cli);
340 #endif
341
342                 /* and get a response */
343 #ifdef CLIX
344                 fgets( &line[1],999, stdin);
345 #else
346                 if (!fgets(line,1000,stdin))
347                 {
348                         break;
349                 }
350 #endif
351
352                 /* input language code to internal one */
353                 CNV_INPUT (line);
354
355                 /* special case - first char is ! */
356                 if (*line == '!')
357                 {
358                         system(line + 1);
359                         continue;
360                 }
361
362                 fprintf(out_hnd, "%s\n", line);
363
364                 /* get the first part of the command */
365                 {
366                         char *ptr = line;
367                         if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
368                 }
369
370                 do_command(info, tok, line);
371         }
372
373         return(True);
374 }
375
376 /****************************************************************************
377 usage on the program
378 ****************************************************************************/
379 static void usage(char *pname)
380 {
381   fprintf(out_hnd, "Usage: %s service <password> [-d debuglevel] [-l log] ",
382            pname);
383
384   fprintf(out_hnd, "\nVersion %s\n",VERSION);
385   fprintf(out_hnd, "\t-d debuglevel         set the debuglevel\n");
386   fprintf(out_hnd, "\t-l log basename.      Basename for log/debug files\n");
387   fprintf(out_hnd, "\t-n netbios name.      Use this name as my netbios name\n");
388   fprintf(out_hnd, "\t-N                    don't ask for a password\n");
389   fprintf(out_hnd, "\t-m max protocol       set the max protocol level\n");
390   fprintf(out_hnd, "\t-I dest IP            use this IP to connect to\n");
391   fprintf(out_hnd, "\t-E                    write messages to stderr instead of stdout\n");
392   fprintf(out_hnd, "\t-U username           set the network username\n");
393   fprintf(out_hnd, "\t-W workgroup          set the workgroup name\n");
394   fprintf(out_hnd, "\t-c command string     execute semicolon separated commands\n");
395   fprintf(out_hnd, "\t-t terminal code      terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n");
396   fprintf(out_hnd, "\n");
397 }
398
399 enum client_action
400 {
401         CLIENT_NONE,
402         CLIENT_IPC,
403         CLIENT_SVC
404 };
405
406 /****************************************************************************
407   main program
408 ****************************************************************************/
409  int main(int argc,char *argv[])
410 {
411         BOOL interactive = True;
412
413         int opt;
414         extern FILE *dbf;
415         extern char *optarg;
416         extern int optind;
417         static pstring servicesf = CONFIGFILE;
418         pstring term_code;
419         char *p;
420         BOOL got_pass = False;
421         char *cmd_str="";
422         mode_t myumask = 0755;
423         enum client_action cli_action = CLIENT_NONE;
424
425         struct client_info cli_info;
426
427         pstring password; /* local copy only, if one is entered */
428
429         out_hnd = stdout;
430         fstrcpy(debugf, argv[0]);
431
432         rpcclient_init();
433
434 #ifdef KANJI
435         pstrcpy(term_code, KANJI);
436 #else /* KANJI */
437         *term_code = 0;
438 #endif /* KANJI */
439
440         DEBUGLEVEL = 2;
441
442         cli_info.put_total_size = 0;
443         cli_info.put_total_time_ms = 0;
444         cli_info.get_total_size = 0;
445         cli_info.get_total_time_ms = 0;
446
447         cli_info.dir_total = 0;
448         cli_info.newer_than = 0;
449         cli_info.archive_level = 0;
450         cli_info.print_mode = 1;
451
452         cli_info.translation = False;
453         cli_info.recurse_dir = False;
454         cli_info.lowercase = False;
455         cli_info.prompt = True;
456         cli_info.abort_mget = True;
457
458         cli_info.dest_ip.s_addr = 0;
459         cli_info.name_type = 0x20;
460
461         pstrcpy(cli_info.cur_dir , "\\");
462         pstrcpy(cli_info.file_sel, "");
463         pstrcpy(cli_info.base_dir, "");
464         pstrcpy(smb_cli->domain, "");
465         pstrcpy(smb_cli->user_name, "");
466         pstrcpy(cli_info.myhostname, "");
467         pstrcpy(cli_info.dest_host, "");
468
469         pstrcpy(cli_info.svc_type, "A:");
470         pstrcpy(cli_info.share, "");
471         pstrcpy(cli_info.service, "");
472
473         ZERO_STRUCT(cli_info.dom.level3_sid);
474         ZERO_STRUCT(cli_info.dom.level5_sid);
475         fstrcpy(cli_info.dom.level3_dom, "");
476         fstrcpy(cli_info.dom.level5_dom, "");
477
478         TimeInit();
479         charset_initialise();
480
481         myumask = umask(0);
482         umask(myumask);
483
484         if (!get_myname(global_myname, NULL))
485         {
486                 fprintf(stderr, "Failed to get my hostname.\n");
487         }
488
489         if (getenv("USER"))
490         {
491                 pstrcpy(smb_cli->user_name,getenv("USER"));
492
493                 /* modification to support userid%passwd syntax in the USER var
494                 25.Aug.97, jdblair@uab.edu */
495
496                 if ((p=strchr(smb_cli->user_name,'%')))
497                 {
498                         *p = 0;
499                         pstrcpy(password,p+1);
500                         got_pass = True;
501                         memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
502                 }
503                 strupper(smb_cli->user_name);
504         }
505
506         password[0] = 0;
507
508         /* modification to support PASSWD environmental var
509            25.Aug.97, jdblair@uab.edu */
510         if (getenv("PASSWD"))
511         {
512                 pstrcpy(password,getenv("PASSWD"));
513         }
514
515         if (*smb_cli->user_name == 0 && getenv("LOGNAME"))
516         {
517                 pstrcpy(smb_cli->user_name,getenv("LOGNAME"));
518                 strupper(smb_cli->user_name);
519         }
520
521         if (argc < 2)
522         {
523                 usage(argv[0]);
524                 exit(1);
525         }
526
527         if (*argv[1] != '-')
528         {
529
530                 pstrcpy(cli_info.service, argv[1]);  
531                 /* Convert any '/' characters in the service name to '\' characters */
532                 string_replace( cli_info.service, '/','\\');
533                 argc--;
534                 argv++;
535
536                 fprintf(out_hnd, "service: %s\n", cli_info.service);
537
538                 if (count_chars(cli_info.service,'\\') < 3)
539                 {
540                         usage(argv[0]);
541                         printf("\n%s: Not enough '\\' characters in service\n", cli_info.service);
542                         exit(1);
543                 }
544
545                 /*
546                 if (count_chars(cli_info.service,'\\') > 3)
547                 {
548                         usage(pname);
549                         printf("\n%s: Too many '\\' characters in service\n", cli_info.service);
550                         exit(1);
551                 }
552                 */
553
554                 if (argc > 1 && (*argv[1] != '-'))
555                 {
556                         got_pass = True;
557                         pstrcpy(password,argv[1]);  
558                         memset(argv[1],'X',strlen(argv[1]));
559                         argc--;
560                         argv++;
561                 }
562
563                 cli_action = CLIENT_SVC;
564         }
565
566         while ((opt = getopt(argc, argv,"s:B:O:M:S:i:N:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
567         {
568                 switch (opt)
569                 {
570                         case 'm':
571                         {
572                                 /* FIXME ... max_protocol seems to be funny here */
573
574                                 int max_protocol = 0;
575                                 max_protocol = interpret_protocol(optarg,max_protocol);
576                                 fprintf(stderr, "max protocol not currently supported\n");
577                                 break;
578                         }
579
580                         case 'O':
581                         {
582                                 pstrcpy(user_socket_options,optarg);
583                                 break;  
584                         }
585
586                         case 'S':
587                         {
588                                 pstrcpy(cli_info.dest_host,optarg);
589                                 strupper(cli_info.dest_host);
590                                 cli_action = CLIENT_IPC;
591                                 break;
592                         }
593
594                         case 'B':
595                         {
596                                 iface_set_default(NULL,optarg,NULL);
597                                 break;
598                         }
599
600                         case 'i':
601                         {
602                                 pstrcpy(scope, optarg);
603                                 break;
604                         }
605
606                         case 'U':
607                         {
608                                 char *lp;
609                                 pstrcpy(smb_cli->user_name,optarg);
610                                 if ((lp=strchr(smb_cli->user_name,'%')))
611                                 {
612                                         *lp = 0;
613                                         pstrcpy(password,lp+1);
614                                         got_pass = True;
615                                         memset(strchr(optarg,'%')+1,'X',strlen(password));
616                                 }
617                                 break;
618                         }
619
620                         case 'W':
621                         {
622                                 pstrcpy(smb_cli->domain,optarg);
623                                 break;
624                         }
625
626                         case 'E':
627                         {
628                                 dbf = stderr;
629                                 break;
630                         }
631
632                         case 'I':
633                         {
634                                 cli_info.dest_ip = *interpret_addr2(optarg);
635                                 if (zero_ip(cli_info.dest_ip))
636                                 {
637                                         exit(1);
638                                 }
639                                 break;
640                         }
641
642                         case 'n':
643                         {
644                                 fstrcpy(global_myname, optarg);
645                                 break;
646                         }
647
648                         case 'N':
649                         {
650                                 got_pass = True;
651                                 break;
652                         }
653
654                         case 'd':
655                         {
656                                 if (*optarg == 'A')
657                                         DEBUGLEVEL = 10000;
658                                 else
659                                         DEBUGLEVEL = atoi(optarg);
660                                 break;
661                         }
662
663                         case 'l':
664                         {
665                                 slprintf(debugf, sizeof(debugf)-1,
666                                          "%s.client", optarg);
667                                 interactive = False;
668                                 break;
669                         }
670
671                         case 'c':
672                         {
673                                 cmd_str = optarg;
674                                 got_pass = True;
675                                 break;
676                         }
677
678                         case 'h':
679                         {
680                                 usage(argv[0]);
681                                 exit(0);
682                                 break;
683                         }
684
685                         case 's':
686                         {
687                                 pstrcpy(servicesf, optarg);
688                                 break;
689                         }
690
691                         case 't':
692                         {
693                                 pstrcpy(term_code, optarg);
694                                 break;
695                         }
696
697                         default:
698                         {
699                                 usage(argv[0]);
700                                 exit(1);
701                                 break;
702                         }
703                 }
704         }
705
706         setup_logging(debugf, interactive);
707
708         if (cli_action == CLIENT_NONE)
709         {
710                 usage(argv[0]);
711                 exit(1);
712         }
713
714         strupper(global_myname);
715         fstrcpy(cli_info.myhostname, global_myname);
716
717         DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
718
719         if (!lp_load(servicesf,True, False, False))
720         {
721                 fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
722         }
723
724         codepage_initialise(lp_client_code_page());
725
726         if (*smb_cli->domain == 0) pstrcpy(smb_cli->domain,lp_workgroup());
727
728         load_interfaces();
729
730         if (cli_action == CLIENT_IPC)
731         {
732                 pstrcpy(cli_info.share, "IPC$");
733                 pstrcpy(cli_info.svc_type, "IPC");
734         }
735
736         fstrcpy(cli_info.mach_acct, cli_info.myhostname);
737         strupper(cli_info.mach_acct);
738         fstrcat(cli_info.mach_acct, "$");
739
740         /* set the password cache info */
741         if (got_pass)
742         {
743                 if (password[0] == 0)
744                 {
745                         pwd_set_nullpwd(&(smb_cli->pwd));
746                 }
747                 else
748                 {
749                         /* generate 16 byte hashes */
750                         pwd_make_lm_nt_16(&(smb_cli->pwd), password);
751                 }
752         }
753         else 
754         {
755                 pwd_read(&(smb_cli->pwd), "Enter Password:", True);
756         }
757
758         /* paranoia: destroy the local copy of the password */
759         bzero(password, sizeof(password)); 
760
761         /* establish connections.  nothing to stop these being re-established. */
762         rpcclient_connect(&cli_info);
763
764         DEBUG(5,("rpcclient_connect: smb_cli->fd:%d\n", smb_cli->fd));
765         if (smb_cli->fd <= 0)
766         {
767                 fprintf(stderr, "warning: connection could not be established to %s<%02x>\n",
768                                  cli_info.dest_host, cli_info.name_type);
769                 fprintf(stderr, "this version of smbclient may crash if you proceed\n");
770                 exit(-1);
771         }
772
773         switch (cli_action)
774         {
775                 case CLIENT_IPC:
776                 {
777                         process(&cli_info, cmd_str);
778                         break;
779                 }
780
781                 default:
782                 {
783                         fprintf(stderr, "unknown client action requested\n");
784                         break;
785                 }
786         }
787
788         rpcclient_stop();
789
790         return(0);
791 }