diff options
-rwxr-xr-x | source3/include/rpc_spoolss.h | 2 | ||||
-rw-r--r-- | source3/rpc_client/cli_connect.c | 4 | ||||
-rw-r--r-- | source3/rpc_client/cli_spoolss.c | 18 | ||||
-rw-r--r-- | source3/rpc_parse/parse_misc.c | 17 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 13 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 84 |
6 files changed, 74 insertions, 64 deletions
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index ead4c6cbc1..6781dc6aea 100755 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -355,7 +355,7 @@ /* thanks to the ddk ... */ typedef struct spool_user_1 { - uint32 size; + uint32 size; /* length of user_name & client_name + 2? */ uint32 client_name_ptr; uint32 user_name_ptr; uint32 build; diff --git a/source3/rpc_client/cli_connect.c b/source3/rpc_client/cli_connect.c index 6dcf92c57d..0eceda4c4c 100644 --- a/source3/rpc_client/cli_connect.c +++ b/source3/rpc_client/cli_connect.c @@ -295,7 +295,7 @@ void cli_connection_unlink(struct cli_connection *con) /**************************************************************************** init client state ****************************************************************************/ -BOOL cli_connection_init(const char *srv_name, const char *pipe_name, +BOOL cli_connection_init(const char *srv_name, char *pipe_name, struct cli_connection **con) { return cli_connection_init_auth(srv_name, pipe_name, con, NULL, NULL); @@ -304,7 +304,7 @@ BOOL cli_connection_init(const char *srv_name, const char *pipe_name, /**************************************************************************** init client state ****************************************************************************/ -BOOL cli_connection_init_auth(const char *srv_name, const char *pipe_name, +BOOL cli_connection_init_auth(const char *srv_name, char *pipe_name, struct cli_connection **con, cli_auth_fns * auth, void *auth_creds) { diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 1bfdf6a468..7417e0c0fc 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -558,9 +558,6 @@ BOOL spoolss_addprinterex(POLICY_HND *hnd, const char* srv_name, PRINTER_INFO_2 - /* memset(srv_name, 0, sizeof(srv_name)); - unistr_to_ascii(srv_name, info2->servername.buffer, sizeof(srv_name)); */ - if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con)) return NT_STATUS_ACCESS_DENIED; @@ -584,7 +581,9 @@ BOOL spoolss_addprinterex(POLICY_HND *hnd, const char* srv_name, PRINTER_INFO_2 make_spoolss_q_addprinterex(&q_o, srv_name, client_name, - "Administrator", 2, info2); + /* "Administrator", */ + con->pCli_state->user_name, + 2, info2); /* turn parameters into data stream and send the request */ if (spoolss_io_q_addprinterex("", &q_o, &buf, 0) && @@ -592,11 +591,14 @@ BOOL spoolss_addprinterex(POLICY_HND *hnd, const char* srv_name, PRINTER_INFO_2 { ZERO_STRUCT(r_o); - if(!spoolss_io_r_addprinterex("", &r_o, &rbuf, 0)) + if(spoolss_io_r_addprinterex("", &r_o, &rbuf, 0)) { - /* report error code */ - DEBUG(5,("SPOOLSS_ADDPRINTEREX: %s\n", get_nt_error_msg(r_o.status))); - valid_pol = False; + if (r_o.status != NT_STATUS_NO_PROBLEMO) + { + /* report error code */ + DEBUG(0,("SPOOLSS_ADDPRINTEREX: %s\n", get_nt_error_msg(r_o.status))); + valid_pol = False; + } } if (valid_pol) diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 617552009c..02ab707a40 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -473,21 +473,32 @@ BOOL smb_io_unihdr2(char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth) void init_unistr(UNISTR *str, const char *buf) { - size_t len = strlen(buf) + 1; + size_t len; - if (!parse_misc_talloc) + if (buf == NULL) + { + str->buffer = NULL; + return; + } + + + len = strlen(buf) + 1; + + if (!parse_misc_talloc) parse_misc_talloc = talloc_init(); if (len < MAX_UNISTRLEN) len = MAX_UNISTRLEN; len *= sizeof(uint16); - str->buffer = (uint16 *)talloc(parse_misc_talloc, len); + str->buffer = (uint16 *)talloc(parse_misc_talloc, len); if (str->buffer == NULL) smb_panic("init_unistr2: malloc fail\n"); /* store the string (null-terminated copy) */ dos_struni2((char *)str->buffer, buf, len); + + return; } /******************************************************************* diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 8ebdd55473..20660a9710 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -711,15 +711,15 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, q_u->user_switch=1; q_u->user_ctr.level=1; q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+8; + q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10; q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; q_u->user_ctr.user1.build=1381; q_u->user_ctr.user1.major=2; q_u->user_ctr.user1.minor=0; q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)); + init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1); + init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1); return True; } @@ -760,15 +760,16 @@ BOOL make_spoolss_q_addprinterex(SPOOL_Q_ADDPRINTEREX *q_u, const char *srv_name q_u->user_ctr.level=1; q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+8; q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; q_u->user_ctr.user1.build=1381; q_u->user_ctr.user1.major=2; q_u->user_ctr.user1.minor=0; q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)); + init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1); + init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1); + q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len + + q_u->user_ctr.user1.client_name.uni_str_len + 2; return True; } diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5751c1e227..2844df8dd8 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -778,6 +778,30 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch) return; } +/************************************************************************** + wrapper for strtok to get the next parameter from a delimited list. + Needed to handle the empty parameter string denoted by "NULL" + *************************************************************************/ +static char* get_driver_3_param (char* str, char* delim, UNISTR* dest) +{ + char *ptr; + + /* get the next token */ + ptr = strtok(str, delim); + + /* a string of 'NULL' is used to represent an empty + parameter because two consecutive delimiters + will not return an empty string. See man strtok(3) + for details */ + if (StrCaseCmp(ptr, "NULL") == 0) + ptr = NULL; + + if (dest != NULL) + init_unistr(dest, ptr); + + return ptr; +} + /******************************************************************************** fill in the members of a DRIVER_INFO_3 struct using a character string in the form of @@ -790,52 +814,21 @@ BOOL init_drv_info_3_members (DRIVER_INFO_3 *info, char *args) char *str, *str2; uint32 len, i; - /* <Long Printer Name> */ - if ((str = strtok(args, ":")) == NULL) - return False; - else - init_unistr(&info->name, str); - - /* <Driver File Name> */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->driverpath, str); - - /* <Data File Name > */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->datafile, str); - - /* <Config File Name> */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->configfile, str); - - /* <Help File Name> */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->helpfile, str); - - /* <Language Monitor Name> */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->monitorname, str); - - /* <Default Data Type> */ - if ((str = strtok(NULL, ":")) == NULL) - return False; - else - init_unistr(&info->defaultdatatype, str); + /* fill in the UNISTR fields */ + str = get_driver_3_param (args, ":", &info->name); + str = get_driver_3_param (NULL, ":", &info->driverpath); + str = get_driver_3_param (NULL, ":", &info->datafile); + str = get_driver_3_param (NULL, ":", &info->configfile); + str = get_driver_3_param (NULL, ":", &info->helpfile); + str = get_driver_3_param (NULL, ":", &info->monitorname); + str = get_driver_3_param (NULL, ":", &info->defaultdatatype); /* <Comma Separated List of Dependent Files> */ - str = strtok(NULL, ":"); /* get the list of dependent files */ - str2 = str; /* save the beginning of the string */ - str = strtok(str, ","); /* begin to strip out each filename */ + str2 = get_driver_3_param (NULL, ":", NULL); /* save the beginning of the string */ + str = str2; + + /* begin to strip out each filename */ + str = strtok(str, ","); len = 0; while (str != NULL) { @@ -874,3 +867,6 @@ void free_drv_info_3 (DRIVER_INFO_3 *info) return; } + + + |