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