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