diff options
-rw-r--r-- | source3/include/rpcclient.h | 1 | ||||
-rw-r--r-- | source3/lib/cmd_interp.c | 114 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 21 |
3 files changed, 103 insertions, 33 deletions
diff --git a/source3/include/rpcclient.h b/source3/include/rpcclient.h index f322724217..ec7690a98a 100644 --- a/source3/include/rpcclient.h +++ b/source3/include/rpcclient.h @@ -132,6 +132,7 @@ struct client_info struct nt_client_info dom; BOOL reuse; + BOOL show_prompt; }; diff --git a/source3/lib/cmd_interp.c b/source3/lib/cmd_interp.c index 84fb28049a..0030710052 100644 --- a/source3/lib/cmd_interp.c +++ b/source3/lib/cmd_interp.c @@ -404,30 +404,31 @@ static uint32 process(struct client_info *info, char *cmd_str) #endif pstring pline; BOOL at_sym = False; + pline[0] = 0; - safe_strcat(pline, "[", sizeof(pline) - 1); - if (usr.ntc.domain[0] != 0) + if (info->show_prompt) { - safe_strcat(pline, usr.ntc.domain, - sizeof(pline) - 1); - safe_strcat(pline, "\\", sizeof(pline) - 1); - at_sym = True; - } - if (usr.ntc.user_name[0] != 0) - { - safe_strcat(pline, usr.ntc.user_name, + safe_strcat(pline, "[", sizeof(pline) - 1); + if (usr.ntc.domain[0] != 0) + { + safe_strcat(pline, usr.ntc.domain, + sizeof(pline) - 1); + safe_strcat(pline, "\\", sizeof(pline) - 1); + at_sym = True; + } + if (usr.ntc.user_name[0] != 0) + { + safe_strcat(pline, usr.ntc.user_name, + sizeof(pline) - 1); + at_sym = True; + } + if (at_sym) + safe_strcat(pline, "@", sizeof(pline) - 1); + + safe_strcat(pline, cli_info.dest_host, sizeof(pline) - 1); - at_sym = True; - } - if (at_sym) - { - safe_strcat(pline, "@", sizeof(pline) - 1); + safe_strcat(pline, "]$ ", sizeof(pline) - 1); } - - safe_strcat(pline, cli_info.dest_host, - sizeof(pline) - 1); - safe_strcat(pline, "]$ ", sizeof(pline) - 1); - #ifndef HAVE_LIBREADLINE /* display a prompt */ @@ -491,7 +492,7 @@ static void usage(char *pname) fprintf(out_hnd, "\nVersion %s\n", VERSION); fprintf(out_hnd, "\t-d debuglevel set the debuglevel\n"); fprintf(out_hnd, - "\t-S <\\>server Server to connect to (\\. or . for localhost)\n"); + "\t-S <\\>server Server to connect to\n"); fprintf(out_hnd, "\t-l log basename. Basename for log/debug files\n"); fprintf(out_hnd, @@ -505,6 +506,10 @@ static void usage(char *pname) fprintf(out_hnd, "\t-E write messages to stderr instead of stdout\n"); fprintf(out_hnd, + "\t-A filename file from which to read the authentication credentials\n"); + fprintf(out_hnd, + "\t-P hide prompt (used for shell scripts)\n"); + fprintf(out_hnd, "\t-U username set the network username\n"); fprintf(out_hnd, "\t-U username%%pass set the network username and password\n"); @@ -942,7 +947,7 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[]) } while ((opt = getopt(argc, argv, - "Rs:O:M:S:i:Nn:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != + "PRs:O:M:S:i:Nn:d:l:hI:EB:U:L:t:m:W:T:D:c:A:")) != EOF) { switch (opt) @@ -995,6 +1000,63 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[]) } break; } + case 'A': + { + FILE *auth; + fstring buf; + uint16 len = 0; + char *ptr, *val, *param; + + if ((auth=sys_fopen(optarg, "r")) == NULL) + { + /* fail if we can't open the credentials file */ + DEBUG(0,("ERROR: Unable to open credentials file!\n")); + exit (-1); + } + + while (!feof(auth)) + { + /* get a line from the file */ + if (!fgets (buf, sizeof(buf), auth)) + continue; + len = strlen(buf); + + if ((len) && (buf[len-1]=='\n')) + { + buf[len-1] = '\0'; + len--; + } + if (len == 0) + continue; + + /* break up the line into parameter & value. + will need to eat a little whitespace possibly */ + param = buf; + if (!(ptr = strchr (buf, '='))) + continue; + val = ptr+1; + *ptr = '\0'; + + /* eat leading white space */ + while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) + val++; + + if (strwicmp("password", param) == 0) + { + pstrcpy(password, val); + cmd_set_options |= CMD_PASS; + } + else if (strwicmp("username", param) == 0) + { + pstrcpy(usr.ntc.user_name, val); + cmd_set_options |= CMD_USER; + } + + memset(buf, 0, sizeof(buf)); + } + fclose(auth); + break; + } case 'W': { @@ -1002,6 +1064,12 @@ static uint32 cmd_set(struct client_info *info, int argc, char *argv[]) pstrcpy(usr.ntc.domain, optarg); break; } + + case 'P': + { /* optarg == prompt string ? */ + info->show_prompt = False; + break; + } case 'E': { @@ -1268,6 +1336,8 @@ int command_main(int argc, char *argv[]) pstrcpy(cli_info.myhostname, ""); pstrcpy(cli_info.dest_host, ""); cli_info.dest_ip.s_addr = 0; + + cli_info.show_prompt = True; ZERO_STRUCT(cli_info.dom.level3_sid); ZERO_STRUCT(cli_info.dom.level5_sid); diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index ba6d55cebe..b3e7554663 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -95,49 +95,47 @@ uint32 cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[ strupper(srv_name); flags=PRINTER_ENUM_LOCAL; - + report (out_hnd, "Flags = PRINTER_ENUM_LOCAL\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); -#if 0 /* JERRY */ flags=PRINTER_ENUM_NAME; - + report (out_hnd, "Flags = PRINTER_ENUM_NAME\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); flags=PRINTER_ENUM_SHARED|PRINTER_ENUM_NAME; - + report (out_hnd, "Flags = PRINTER_ENUM_SHARED|PRINTER_ENUM_NAME\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); flags=PRINTER_ENUM_CONNECTIONS; - + report (out_hnd, "Flags = PRINTER_ENUM_CONNECTIONS\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); flags=PRINTER_ENUM_NETWORK; - + report (out_hnd, "Flags = PRINTER_ENUM_NETWORK\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); flags=PRINTER_ENUM_REMOTE; - + report (out_hnd, "Flags = PRINTER_ENUM_REMOTE\n"); if (msrpc_spoolss_enum_printers(srv_name, flags, level, ctr)) DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n")); else report(out_hnd, "FAILED\n"); -#endif return NT_STATUS_NOPROBLEMO; } @@ -646,11 +644,8 @@ uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[] init_unistr( &print_info_2.portname, port_name); init_unistr( &print_info_2.drivername, driver_name); init_unistr( &print_info_2.comment, "Created by rpcclient"); - /* init_unistr( &print_info_2.location, ""); - init_unistr( &print_info_2.sepfile, ""); */ init_unistr( &print_info_2.printprocessor, "winprint"); init_unistr( &print_info_2.datatype, "RAW"); - /* init_unistr( &print_info_2.parameters, ""); */ print_info_2.devmode = NULL; print_info_2.secdesc = NULL; print_info_2.attributes = PRINTER_ATTRIBUTE_SHARED; @@ -658,9 +653,13 @@ uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[] print_info_2.defaultpriority = 0; print_info_2.starttime = 0; print_info_2.untiltime = 0; + + /* These three fields must not be used by AddPrinter() + as defined in the MS Platform SDK documentation.. --jerry print_info_2.status = 0; print_info_2.cjobs = 0; print_info_2.averageppm = 0; + */ /* if successful, spoolss_addprinterex() should return True and hnd |