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