r6369: update release notes
[Samba.git] / source / rpcclient / rpcclient.c
blobc02a279db9ebd8fe7f909965fcce3bf48fec2699
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Tim Potter 2000-2001
6 Copyright (C) Martin Pool 2003
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "includes.h"
24 #include "rpcclient.h"
26 DOM_SID domain_sid;
29 /* List to hold groups of commands.
31 * Commands are defined in a list of arrays: arrays are easy to
32 * statically declare, and lists are easier to dynamically extend.
35 static struct cmd_list {
36 struct cmd_list *prev, *next;
37 struct cmd_set *cmd_set;
38 } *cmd_list;
40 /****************************************************************************
41 handle completion of commands for readline
42 ****************************************************************************/
43 static char **completion_fn(const char *text, int start, int end)
45 #define MAX_COMPLETIONS 100
46 char **matches;
47 int i, count=0;
48 struct cmd_list *commands = cmd_list;
50 #if 0 /* JERRY */
51 /* FIXME!!! -- what to do when completing argument? */
52 /* for words not at the start of the line fallback
53 to filename completion */
54 if (start)
55 return NULL;
56 #endif
58 /* make sure we have a list of valid commands */
59 if (!commands)
60 return NULL;
62 matches = SMB_MALLOC_ARRAY(char *, MAX_COMPLETIONS);
63 if (!matches) return NULL;
65 matches[count++] = SMB_STRDUP(text);
66 if (!matches[0]) return NULL;
68 while (commands && count < MAX_COMPLETIONS-1)
70 if (!commands->cmd_set)
71 break;
73 for (i=0; commands->cmd_set[i].name; i++)
75 if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
76 (( commands->cmd_set[i].returntype == RPC_RTYPE_NTSTATUS &&
77 commands->cmd_set[i].ntfn ) ||
78 ( commands->cmd_set[i].returntype == RPC_RTYPE_WERROR &&
79 commands->cmd_set[i].wfn)))
81 matches[count] = SMB_STRDUP(commands->cmd_set[i].name);
82 if (!matches[count])
83 return NULL;
84 count++;
88 commands = commands->next;
92 if (count == 2) {
93 SAFE_FREE(matches[0]);
94 matches[0] = SMB_STRDUP(matches[1]);
96 matches[count] = NULL;
97 return matches;
100 static char* next_command (char** cmdstr)
102 static pstring command;
103 char *p;
105 if (!cmdstr || !(*cmdstr))
106 return NULL;
108 p = strchr_m(*cmdstr, ';');
109 if (p)
110 *p = '\0';
111 pstrcpy(command, *cmdstr);
112 if (p)
113 *cmdstr = p + 1;
114 else
115 *cmdstr = NULL;
117 return command;
120 /* Fetch the SID for this computer */
122 static void fetch_machine_sid(struct cli_state *cli)
124 POLICY_HND pol;
125 NTSTATUS result = NT_STATUS_OK;
126 uint32 info_class = 5;
127 char *domain_name = NULL;
128 static BOOL got_domain_sid;
129 TALLOC_CTX *mem_ctx;
130 DOM_SID *dom_sid = NULL;
132 if (got_domain_sid) return;
134 if (!(mem_ctx=talloc_init("fetch_machine_sid")))
136 DEBUG(0,("fetch_machine_sid: talloc_init returned NULL!\n"));
137 goto error;
141 if (!cli_nt_session_open (cli, PI_LSARPC)) {
142 fprintf(stderr, "could not initialise lsa pipe\n");
143 goto error;
146 result = cli_lsa_open_policy(cli, mem_ctx, True,
147 SEC_RIGHTS_MAXIMUM_ALLOWED,
148 &pol);
149 if (!NT_STATUS_IS_OK(result)) {
150 goto error;
153 result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class,
154 &domain_name, &dom_sid);
155 if (!NT_STATUS_IS_OK(result)) {
156 goto error;
159 got_domain_sid = True;
160 sid_copy( &domain_sid, dom_sid );
162 cli_lsa_close(cli, mem_ctx, &pol);
163 cli_nt_session_close(cli);
164 talloc_destroy(mem_ctx);
166 return;
168 error:
169 fprintf(stderr, "could not obtain sid for domain %s\n", cli->domain);
171 if (!NT_STATUS_IS_OK(result)) {
172 fprintf(stderr, "error: %s\n", nt_errstr(result));
175 exit(1);
178 /* List the available commands on a given pipe */
180 static NTSTATUS cmd_listcommands(struct cli_state *cli, TALLOC_CTX *mem_ctx,
181 int argc, const char **argv)
183 struct cmd_list *tmp;
184 struct cmd_set *tmp_set;
185 int i;
187 /* Usage */
189 if (argc != 2) {
190 printf("Usage: %s <pipe>\n", argv[0]);
191 return NT_STATUS_OK;
194 /* Help on one command */
196 for (tmp = cmd_list; tmp; tmp = tmp->next)
198 tmp_set = tmp->cmd_set;
200 if (!StrCaseCmp(argv[1], tmp_set->name))
202 printf("Available commands on the %s pipe:\n\n", tmp_set->name);
204 i = 0;
205 tmp_set++;
206 while(tmp_set->name) {
207 printf("%20s", tmp_set->name);
208 tmp_set++;
209 i++;
210 if (i%4 == 0)
211 printf("\n");
214 /* drop out of the loop */
215 break;
218 printf("\n\n");
220 return NT_STATUS_OK;
223 /* Display help on commands */
225 static NTSTATUS cmd_help(struct cli_state *cli, TALLOC_CTX *mem_ctx,
226 int argc, const char **argv)
228 struct cmd_list *tmp;
229 struct cmd_set *tmp_set;
231 /* Usage */
233 if (argc > 2) {
234 printf("Usage: %s [command]\n", argv[0]);
235 return NT_STATUS_OK;
238 /* Help on one command */
240 if (argc == 2) {
241 for (tmp = cmd_list; tmp; tmp = tmp->next) {
243 tmp_set = tmp->cmd_set;
245 while(tmp_set->name) {
246 if (strequal(argv[1], tmp_set->name)) {
247 if (tmp_set->usage &&
248 tmp_set->usage[0])
249 printf("%s\n", tmp_set->usage);
250 else
251 printf("No help for %s\n", tmp_set->name);
253 return NT_STATUS_OK;
256 tmp_set++;
260 printf("No such command: %s\n", argv[1]);
261 return NT_STATUS_OK;
264 /* List all commands */
266 for (tmp = cmd_list; tmp; tmp = tmp->next) {
268 tmp_set = tmp->cmd_set;
270 while(tmp_set->name) {
272 printf("%15s\t\t%s\n", tmp_set->name,
273 tmp_set->description ? tmp_set->description:
274 "");
276 tmp_set++;
280 return NT_STATUS_OK;
283 /* Change the debug level */
285 static NTSTATUS cmd_debuglevel(struct cli_state *cli, TALLOC_CTX *mem_ctx,
286 int argc, const char **argv)
288 if (argc > 2) {
289 printf("Usage: %s [debuglevel]\n", argv[0]);
290 return NT_STATUS_OK;
293 if (argc == 2) {
294 DEBUGLEVEL = atoi(argv[1]);
297 printf("debuglevel is %d\n", DEBUGLEVEL);
299 return NT_STATUS_OK;
302 static NTSTATUS cmd_quit(struct cli_state *cli, TALLOC_CTX *mem_ctx,
303 int argc, const char **argv)
305 exit(0);
306 return NT_STATUS_OK; /* NOTREACHED */
309 static NTSTATUS cmd_sign(struct cli_state *cli, TALLOC_CTX *mem_ctx,
310 int argc, const char **argv)
312 if (cli->pipe_auth_flags == (AUTH_PIPE_NTLMSSP|AUTH_PIPE_SIGN)) {
313 return NT_STATUS_OK;
314 } else {
315 /* still have session, just need to use it again */
316 cli->pipe_auth_flags = AUTH_PIPE_NTLMSSP;
317 cli->pipe_auth_flags |= AUTH_PIPE_SIGN;
318 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
319 cli_nt_session_close(cli);
322 return NT_STATUS_OK;
325 static NTSTATUS cmd_seal(struct cli_state *cli, TALLOC_CTX *mem_ctx,
326 int argc, const char **argv)
328 if (cli->pipe_auth_flags == (AUTH_PIPE_NTLMSSP|AUTH_PIPE_SIGN|AUTH_PIPE_SEAL)) {
329 return NT_STATUS_OK;
330 } else {
331 /* still have session, just need to use it again */
332 cli->pipe_auth_flags = AUTH_PIPE_NTLMSSP;
333 cli->pipe_auth_flags |= AUTH_PIPE_SIGN;
334 cli->pipe_auth_flags |= AUTH_PIPE_SEAL;
335 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
336 cli_nt_session_close(cli);
338 return NT_STATUS_OK;
341 static NTSTATUS cmd_none(struct cli_state *cli, TALLOC_CTX *mem_ctx,
342 int argc, const char **argv)
344 if (cli->pipe_auth_flags == 0) {
345 return NT_STATUS_OK;
346 } else {
347 /* still have session, just need to use it again */
348 cli->pipe_auth_flags = 0;
349 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
350 cli_nt_session_close(cli);
352 cli->pipe_auth_flags = 0;
354 return NT_STATUS_OK;
357 static NTSTATUS setup_schannel(struct cli_state *cli, int pipe_auth_flags,
358 int argc, const char **argv)
360 NTSTATUS ret;
361 static uchar zeros[16];
362 uchar trust_password[16];
363 uint32 sec_channel_type;
364 if (argc == 2) {
365 strhex_to_str((char *)cli->auth_info.sess_key,
366 strlen(argv[1]),
367 argv[1]);
368 memcpy(cli->sess_key, cli->auth_info.sess_key, sizeof(cli->sess_key));
370 cli->pipe_auth_flags = pipe_auth_flags;
371 return NT_STATUS_OK;
374 /* Cleanup */
376 if ((memcmp(cli->auth_info.sess_key, zeros, sizeof(cli->auth_info.sess_key)) != 0)) {
377 if (cli->pipe_auth_flags == pipe_auth_flags) {
378 /* already in this mode nothing to do */
379 return NT_STATUS_OK;
380 } else {
381 /* schannel is setup, just need to use it again with new flags */
382 cli->pipe_auth_flags = pipe_auth_flags;
384 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
385 cli_nt_session_close(cli);
386 return NT_STATUS_OK;
390 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
391 cli_nt_session_close(cli);
393 if (!secrets_fetch_trust_account_password(lp_workgroup(),
394 trust_password,
395 NULL, &sec_channel_type)) {
396 return NT_STATUS_UNSUCCESSFUL;
399 ret = cli_nt_setup_netsec(cli, sec_channel_type, pipe_auth_flags, trust_password);
400 if (NT_STATUS_IS_OK(ret)) {
401 char *hex_session_key;
402 hex_encode(cli->auth_info.sess_key,
403 sizeof(cli->auth_info.sess_key),
404 &hex_session_key);
405 printf("Got Session key: %s\n", hex_session_key);
406 SAFE_FREE(hex_session_key);
408 return ret;
412 static NTSTATUS cmd_schannel(struct cli_state *cli, TALLOC_CTX *mem_ctx,
413 int argc, const char **argv)
415 d_printf("Setting schannel - sign and seal\n");
416 return setup_schannel(cli, AUTH_PIPE_NETSEC | AUTH_PIPE_SIGN | AUTH_PIPE_SEAL,
417 argc, argv);
420 static NTSTATUS cmd_schannel_sign(struct cli_state *cli, TALLOC_CTX *mem_ctx,
421 int argc, const char **argv)
423 d_printf("Setting schannel - sign only\n");
424 return setup_schannel(cli, AUTH_PIPE_NETSEC | AUTH_PIPE_SIGN,
425 argc, argv);
429 /* Built in rpcclient commands */
431 static struct cmd_set rpcclient_commands[] = {
433 { "GENERAL OPTIONS" },
435 { "help", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" },
436 { "?", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" },
437 { "debuglevel", RPC_RTYPE_NTSTATUS, cmd_debuglevel, NULL, -1, "Set debug level", "level" },
438 { "list", RPC_RTYPE_NTSTATUS, cmd_listcommands, NULL, -1, "List available commands on <pipe>", "pipe" },
439 { "exit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" },
440 { "quit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" },
441 { "sign", RPC_RTYPE_NTSTATUS, cmd_sign, NULL, -1, "Force RPC pipe connections to be signed", "" },
442 { "seal", RPC_RTYPE_NTSTATUS, cmd_seal, NULL, -1, "Force RPC pipe connections to be sealed", "" },
443 { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL, -1, "Force RPC pipe connections to be sealed with 'schannel' (NETSEC). Assumes valid machine account to this domain controller.", "" },
444 { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL, -1, "Force RPC pipe connections to be signed (not sealed) with 'schannel' (NETSEC). Assumes valid machine account to this domain controller.", "" },
445 { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL, -1, "Force RPC pipe connections to have no special properties", "" },
447 { NULL }
450 static struct cmd_set separator_command[] = {
451 { "---------------", MAX_RPC_RETURN_TYPE, NULL, NULL, -1, "----------------------" },
452 { NULL }
456 /* Various pipe commands */
458 extern struct cmd_set lsarpc_commands[];
459 extern struct cmd_set samr_commands[];
460 extern struct cmd_set spoolss_commands[];
461 extern struct cmd_set netlogon_commands[];
462 extern struct cmd_set srvsvc_commands[];
463 extern struct cmd_set dfs_commands[];
464 extern struct cmd_set reg_commands[];
465 extern struct cmd_set ds_commands[];
466 extern struct cmd_set echo_commands[];
467 extern struct cmd_set shutdown_commands[];
469 static struct cmd_set *rpcclient_command_list[] = {
470 rpcclient_commands,
471 lsarpc_commands,
472 ds_commands,
473 samr_commands,
474 spoolss_commands,
475 netlogon_commands,
476 srvsvc_commands,
477 dfs_commands,
478 reg_commands,
479 echo_commands,
480 shutdown_commands,
481 NULL
484 static void add_command_set(struct cmd_set *cmd_set)
486 struct cmd_list *entry;
488 if (!(entry = SMB_MALLOC_P(struct cmd_list))) {
489 DEBUG(0, ("out of memory\n"));
490 return;
493 ZERO_STRUCTP(entry);
495 entry->cmd_set = cmd_set;
496 DLIST_ADD(cmd_list, entry);
501 * Call an rpcclient function, passing an argv array.
503 * @param cmd Command to run, as a single string.
505 static NTSTATUS do_cmd(struct cli_state *cli,
506 struct cmd_set *cmd_entry,
507 int argc, char **argv)
509 NTSTATUS ntresult;
510 WERROR wresult;
511 uchar trust_password[16];
513 TALLOC_CTX *mem_ctx;
515 /* Create mem_ctx */
517 if (!(mem_ctx = talloc_init("do_cmd"))) {
518 DEBUG(0, ("talloc_init() failed\n"));
519 return NT_STATUS_NO_MEMORY;
522 /* Open pipe */
524 if (cmd_entry->pipe_idx != -1
525 && cmd_entry->pipe_idx != cli->pipe_idx) {
526 if (cli->nt_pipe_fnum[cli->pipe_idx] != 0)
527 cli_nt_session_close(cli);
529 if (!cli_nt_session_open(cli, cmd_entry->pipe_idx)) {
530 DEBUG(0, ("Could not initialise %s\n",
531 get_pipe_name_from_index(cmd_entry->pipe_idx)));
532 return NT_STATUS_UNSUCCESSFUL;
536 /* some of the DsXXX commands use the netlogon pipe */
538 if (lp_client_schannel() && (cmd_entry->pipe_idx == PI_NETLOGON) && !(cli->pipe_auth_flags & AUTH_PIPE_NETSEC)) {
539 uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS;
540 uint32 sec_channel_type;
542 if (!secrets_fetch_trust_account_password(lp_workgroup(),
543 trust_password,
544 NULL, &sec_channel_type)) {
545 return NT_STATUS_UNSUCCESSFUL;
548 ntresult = cli_nt_setup_creds(cli, sec_channel_type,
549 trust_password,
550 &neg_flags, 2);
551 if (!NT_STATUS_IS_OK(ntresult)) {
552 ZERO_STRUCT(cli->auth_info.sess_key);
553 printf("nt_setup_creds failed with %s\n", nt_errstr(ntresult));
554 return ntresult;
559 /* Run command */
561 if ( cmd_entry->returntype == RPC_RTYPE_NTSTATUS ) {
562 ntresult = cmd_entry->ntfn(cli, mem_ctx, argc, (const char **) argv);
563 if (!NT_STATUS_IS_OK(ntresult)) {
564 printf("result was %s\n", nt_errstr(ntresult));
566 } else {
567 wresult = cmd_entry->wfn( cli, mem_ctx, argc, (const char **) argv);
568 /* print out the DOS error */
569 if (!W_ERROR_IS_OK(wresult)) {
570 printf( "result was %s\n", dos_errstr(wresult));
572 ntresult = W_ERROR_IS_OK(wresult)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL;
576 /* Cleanup */
578 talloc_destroy(mem_ctx);
580 return ntresult;
585 * Process a command entered at the prompt or as part of -c
587 * @returns The NTSTATUS from running the command.
589 static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
591 struct cmd_list *temp_list;
592 NTSTATUS result = NT_STATUS_OK;
593 int ret;
594 int argc;
595 char **argv = NULL;
597 if ((ret = poptParseArgvString(cmd, &argc, (const char ***) &argv)) != 0) {
598 fprintf(stderr, "rpcclient: %s\n", poptStrerror(ret));
599 return NT_STATUS_UNSUCCESSFUL;
603 /* Walk through a dlist of arrays of commands. */
604 for (temp_list = cmd_list; temp_list; temp_list = temp_list->next) {
605 struct cmd_set *temp_set = temp_list->cmd_set;
607 while (temp_set->name) {
608 if (strequal(argv[0], temp_set->name)) {
609 if (!(temp_set->returntype == RPC_RTYPE_NTSTATUS && temp_set->ntfn ) &&
610 !(temp_set->returntype == RPC_RTYPE_WERROR && temp_set->wfn )) {
611 fprintf (stderr, "Invalid command\n");
612 goto out_free;
615 result = do_cmd(cli, temp_set, argc, argv);
617 goto out_free;
619 temp_set++;
623 if (argv[0]) {
624 printf("command not found: %s\n", argv[0]);
627 out_free:
628 /* moved to do_cmd()
629 if (!NT_STATUS_IS_OK(result)) {
630 printf("result was %s\n", nt_errstr(result));
634 if (argv) {
635 /* NOTE: popt allocates the whole argv, including the
636 * strings, as a single block. So a single free is
637 * enough to release it -- we don't free the
638 * individual strings. rtfm. */
639 free(argv);
642 return result;
646 /* Main function */
648 int main(int argc, char *argv[])
650 BOOL interactive = True;
651 int opt;
652 static char *cmdstr = NULL;
653 const char *server;
654 struct cli_state *cli;
655 static char *opt_ipaddr=NULL;
656 struct cmd_set **cmd_set;
657 struct in_addr server_ip;
658 NTSTATUS nt_status;
659 static int opt_port = 0;
661 /* make sure the vars that get altered (4th field) are in
662 a fixed location or certain compilers complain */
663 poptContext pc;
664 struct poptOption long_options[] = {
665 POPT_AUTOHELP
666 {"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds", "COMMANDS"},
667 {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address", "IP"},
668 {"port", 'p', POPT_ARG_INT, &opt_port, 'p', "Specify port number", "PORT"},
669 POPT_COMMON_SAMBA
670 POPT_COMMON_CONNECTION
671 POPT_COMMON_CREDENTIALS
672 POPT_TABLEEND
675 ZERO_STRUCT(server_ip);
677 setlinebuf(stdout);
679 /* the following functions are part of the Samba debugging
680 facilities. See lib/debug.c */
681 setup_logging("rpcclient", interactive);
682 if (!interactive)
683 reopen_logs();
685 /* Load smb.conf file */
687 if (!lp_load(dyn_CONFIGFILE,True,False,False))
688 fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
690 /* Parse options */
692 pc = poptGetContext("rpcclient", argc, (const char **) argv,
693 long_options, 0);
695 if (argc == 1) {
696 poptPrintHelp(pc, stderr, 0);
697 return 0;
700 while((opt = poptGetNextOpt(pc)) != -1) {
701 switch (opt) {
703 case 'I':
704 if ( (server_ip.s_addr=inet_addr(opt_ipaddr)) == INADDR_NONE ) {
705 fprintf(stderr, "%s not a valid IP address\n",
706 opt_ipaddr);
707 return 1;
712 /* Get server as remaining unparsed argument. Print usage if more
713 than one unparsed argument is present. */
715 server = poptGetArg(pc);
717 if (!server || poptGetArg(pc)) {
718 poptPrintHelp(pc, stderr, 0);
719 return 1;
722 poptFreeContext(pc);
724 load_interfaces();
726 if (!init_names())
727 return 1;
730 * Get password
731 * from stdin if necessary
734 if (!cmdline_auth_info.got_pass) {
735 char *pass = getpass("Password:");
736 if (pass) {
737 pstrcpy(cmdline_auth_info.password, pass);
741 nt_status = cli_full_connection(&cli, global_myname(), server,
742 opt_ipaddr ? &server_ip : NULL, opt_port,
743 "IPC$", "IPC",
744 cmdline_auth_info.username,
745 lp_workgroup(),
746 cmdline_auth_info.password,
747 cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0,
748 cmdline_auth_info.signing_state,NULL);
750 if (!NT_STATUS_IS_OK(nt_status)) {
751 DEBUG(0,("Cannot connect to server. Error was %s\n", nt_errstr(nt_status)));
752 return 1;
755 memset(cmdline_auth_info.password,'X',sizeof(cmdline_auth_info.password));
757 /* Load command lists */
759 cmd_set = rpcclient_command_list;
761 while(*cmd_set) {
762 add_command_set(*cmd_set);
763 add_command_set(separator_command);
764 cmd_set++;
767 fetch_machine_sid(cli);
769 /* Do anything specified with -c */
770 if (cmdstr && cmdstr[0]) {
771 char *cmd;
772 char *p = cmdstr;
773 int result = 0;
775 while((cmd=next_command(&p)) != NULL) {
776 NTSTATUS cmd_result = process_cmd(cli, cmd);
777 result = NT_STATUS_IS_ERR(cmd_result);
780 cli_shutdown(cli);
781 return result;
784 /* Loop around accepting commands */
786 while(1) {
787 pstring prompt;
788 char *line;
790 slprintf(prompt, sizeof(prompt) - 1, "rpcclient $> ");
792 line = smb_readline(prompt, NULL, completion_fn);
794 if (line == NULL)
795 break;
797 if (line[0] != '\n')
798 process_cmd(cli, line);
801 cli_shutdown(cli);
802 return 0;