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