diff options
author | Jeremy Allison <jra@samba.org> | 2009-02-24 15:28:06 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-02-24 15:28:06 -0800 |
commit | ca1653e830f8340f6188bbfa9fb2cb00e9e84fca (patch) | |
tree | bb1c6741f8a1788acb9fa74d2aa3b026085675e0 /source3 | |
parent | a028e9640b54554f4ae036f46cc16ae73f00884e (diff) | |
parent | 28fb708ba0bf3c81e54b1f99a8f56d671e62a047 (diff) | |
download | samba-ca1653e830f8340f6188bbfa9fb2cb00e9e84fca.tar.gz samba-ca1653e830f8340f6188bbfa9fb2cb00e9e84fca.tar.bz2 samba-ca1653e830f8340f6188bbfa9fb2cb00e9e84fca.zip |
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 7 | ||||
-rw-r--r-- | source3/lib/fault.c | 1 | ||||
-rw-r--r-- | source3/rpc_client/cli_spoolss.c | 30 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 103 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 119 |
5 files changed, 69 insertions, 191 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 08840bd7cc..6edad71a99 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5492,9 +5492,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, uint32 level, const char *env, uint32 *num_drivers, PRINTER_DRIVER_CTR *ctr); -WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, uint32 level, - PRINTER_DRIVER_CTR *ctr); WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, PRINTER_INFO_CTR*ctr); WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -5941,9 +5938,6 @@ bool spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_I bool make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name, uint32 level, PRINTER_DRIVER_CTR *info); -bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx, - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info, - DRIVER_INFO_3 *info3); bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src); bool spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth); bool spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth); @@ -6239,7 +6233,6 @@ bool init_service_op_table( void ); /* The following definitions come from rpcclient/cmd_spoolss.c */ -void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch); /* The following definitions come from rpcclient/cmd_srvsvc.c */ diff --git a/source3/lib/fault.c b/source3/lib/fault.c index a1530987f3..8c4a45bbc9 100644 --- a/source3/lib/fault.c +++ b/source3/lib/fault.c @@ -157,7 +157,6 @@ void dump_core_setup(const char *progname) return; } - SAFE_FREE(corepath); SAFE_FREE(logbase); #ifdef HAVE_GETRLIMIT diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 8a8dabeba4..19e9aae0f8 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -886,36 +886,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli, /********************************************************************** **********************************************************************/ -WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli, - TALLOC_CTX *mem_ctx, uint32 level, - PRINTER_DRIVER_CTR *ctr) -{ - prs_struct qbuf, rbuf; - SPOOL_Q_ADDPRINTERDRIVER in; - SPOOL_R_ADDPRINTERDRIVER out; - fstring server; - - ZERO_STRUCT(in); - ZERO_STRUCT(out); - - slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost); - strupper_m(server); - - make_spoolss_q_addprinterdriver( mem_ctx, &in, server, level, ctr ); - - CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ADDPRINTERDRIVER, - in, out, - qbuf, rbuf, - spoolss_io_q_addprinterdriver, - spoolss_io_r_addprinterdriver, - WERR_GENERAL_FAILURE ); - - return out.status; -} - -/********************************************************************** -**********************************************************************/ - WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, uint32 level, PRINTER_INFO_CTR*ctr) { diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 4ffa121e1c..9c69dd2659 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -3383,109 +3383,6 @@ bool spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_I } /******************************************************************* - init a SPOOL_Q_ADDPRINTERDRIVER struct - ******************************************************************/ - -bool make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx, - SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name, - uint32 level, PRINTER_DRIVER_CTR *info) -{ - DEBUG(5,("make_spoolss_q_addprinterdriver\n")); - - if (!srv_name || !info) { - return False; - } - - q_u->server_name_ptr = 1; /* srv_name is != NULL, see above */ - init_unistr2(&q_u->server_name, srv_name, UNI_STR_TERMINATE); - - q_u->level = level; - - q_u->info.level = level; - q_u->info.ptr = 1; /* Info is != NULL, see above */ - switch (level) - { - /* info level 3 is supported by Windows 95/98, WinNT and Win2k */ - case 3 : - make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3); - break; - - default: - DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level)); - break; - } - - return True; -} - -bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx, - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info, - DRIVER_INFO_3 *info3) -{ - uint32 len = 0; - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf; - - if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3))) - return False; - - inf->cversion = info3->version; - inf->name_ptr = (info3->name.buffer!=NULL)?1:0; - inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0; - inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0; - inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0; - inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0; - inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0; - inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0; - inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0; - - init_unistr2_from_unistr(inf, &inf->name, &info3->name); - init_unistr2_from_unistr(inf, &inf->environment, &info3->architecture); - init_unistr2_from_unistr(inf, &inf->driverpath, &info3->driverpath); - init_unistr2_from_unistr(inf, &inf->datafile, &info3->datafile); - init_unistr2_from_unistr(inf, &inf->configfile, &info3->configfile); - init_unistr2_from_unistr(inf, &inf->helpfile, &info3->helpfile); - init_unistr2_from_unistr(inf, &inf->monitorname, &info3->monitorname); - init_unistr2_from_unistr(inf, &inf->defaultdatatype, &info3->defaultdatatype); - - if (info3->dependentfiles) { - bool done = False; - bool null_char = False; - uint16 *ptr = info3->dependentfiles; - - while (!done) { - switch (*ptr) { - case 0: - /* the null_char bool is used to help locate - two '\0's back to back */ - if (null_char) { - done = True; - } else { - null_char = True; - } - break; - - default: - null_char = False; - break; - } - len++; - ptr++; - } - } - - inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0; - inf->dependentfilessize = (info3->dependentfiles != NULL) ? len : 0; - if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles)) { - SAFE_FREE(inf); - return False; - } - - *spool_drv_info = inf; - - return True; -} - -/******************************************************************* make a BUFFER5 struct from a uint16* ******************************************************************/ diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 99838f6396..17ff818de6 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1289,7 +1289,9 @@ static WERROR cmd_spoolss_getdriverdir(struct rpc_pipe_client *cli, /**************************************************************************** ****************************************************************************/ -void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch) +static void set_drv_info_3_env(TALLOC_CTX *mem_ctx, + struct spoolss_AddDriverInfo3 *info, + const char *arch) { int i; @@ -1299,7 +1301,7 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch) if (strcmp(arch, archi_table[i].short_archi) == 0) { info->version = archi_table[i].version; - init_unistr (&info->architecture, archi_table[i].long_archi); + info->architecture = talloc_strdup(mem_ctx, archi_table[i].long_archi); break; } } @@ -1318,8 +1320,9 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch) Needed to handle the empty parameter string denoted by "NULL" *************************************************************************/ -static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest, - char **saveptr) +static char *get_driver_3_param(TALLOC_CTX *mem_ctx, char *str, + const char *delim, const char **dest, + char **saveptr) { char *ptr; @@ -1330,70 +1333,80 @@ static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest, parameter because two consecutive delimiters will not return an empty string. See man strtok(3) for details */ - if (ptr && (StrCaseCmp(ptr, "NULL") == 0)) + if (ptr && (StrCaseCmp(ptr, "NULL") == 0)) { ptr = NULL; + } - if (dest != NULL) - init_unistr(dest, ptr); + if (dest != NULL) { + *dest = talloc_strdup(mem_ctx, ptr); + } return ptr; } /******************************************************************************** - fill in the members of a DRIVER_INFO_3 struct using a character + fill in the members of a spoolss_AddDriverInfo3 struct using a character string in the form of <Long Printer Name>:<Driver File Name>:<Data File Name>:\ <Config File Name>:<Help File Name>:<Language Monitor Name>:\ <Default Data Type>:<Comma Separated list of Files> *******************************************************************************/ -static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info, - char *args ) + +static bool init_drv_info_3_members(TALLOC_CTX *mem_ctx, struct spoolss_AddDriverInfo3 *r, + char *args) { char *str, *str2; - uint32 len, i; + int count = 0; char *saveptr = NULL; + struct spoolss_StringArray *deps; + const char **file_array = NULL; + int i; /* fill in the UNISTR fields */ - str = get_driver_3_param (args, ":", &info->name, &saveptr); - str = get_driver_3_param (NULL, ":", &info->driverpath, &saveptr); - str = get_driver_3_param (NULL, ":", &info->datafile, &saveptr); - str = get_driver_3_param (NULL, ":", &info->configfile, &saveptr); - str = get_driver_3_param (NULL, ":", &info->helpfile, &saveptr); - str = get_driver_3_param (NULL, ":", &info->monitorname, &saveptr); - str = get_driver_3_param (NULL, ":", &info->defaultdatatype, &saveptr); + str = get_driver_3_param(mem_ctx, args, ":", &r->driver_name, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->driver_path, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->data_file, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->config_file, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->help_file, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->monitor_name, &saveptr); + str = get_driver_3_param(mem_ctx, NULL, ":", &r->default_datatype, &saveptr); /* <Comma Separated List of Dependent Files> */ /* save the beginning of the string */ - str2 = get_driver_3_param (NULL, ":", NULL, &saveptr); + str2 = get_driver_3_param(mem_ctx, NULL, ":", NULL, &saveptr); str = str2; /* begin to strip out each filename */ str = strtok_r(str, ",", &saveptr); - len = 0; - while (str != NULL) - { - /* keep a cumlative count of the str lengths */ - len += strlen(str)+1; + + /* no dependent files, we are done */ + if (!str) { + return true; + } + + deps = talloc_zero(mem_ctx, struct spoolss_StringArray); + if (!deps) { + return false; + } + + while (str != NULL) { + add_string_to_array(deps, str, &file_array, &count); str = strtok_r(NULL, ",", &saveptr); } - /* allocate the space; add one extra slot for a terminating NULL. - Each filename is NULL terminated and the end contains a double - NULL */ - if ((info->dependentfiles=TALLOC_ARRAY(mem_ctx, uint16, len+1)) == NULL) - { - DEBUG(0,("init_drv_info_3_members: Unable to malloc memory for dependenfiles\n")); - return False; + deps->string = talloc_zero_array(deps, const char *, count + 1); + if (!deps->string) { + return false; } - for (i=0; i<len; i++) - { - SSVAL(&info->dependentfiles[i], 0, str2[i]); + + for (i=0; i < count; i++) { + deps->string[i] = file_array[i]; } - info->dependentfiles[len] = '\0'; - return True; -} + r->dependent_files = deps; + return true; +} /**************************************************************************** ****************************************************************************/ @@ -1403,11 +1416,11 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli, int argc, const char **argv) { WERROR result; + NTSTATUS status; uint32 level = 3; - PRINTER_DRIVER_CTR ctr; - DRIVER_INFO_3 info3; + struct spoolss_AddDriverInfoCtr info_ctr; + struct spoolss_AddDriverInfo3 info3; const char *arch; - fstring driver_name; char *driver_args; /* parse the command arguments */ @@ -1422,15 +1435,16 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli, return WERR_OK; } - /* Fill in the DRIVER_INFO_3 struct */ + /* Fill in the spoolss_AddDriverInfo3 struct */ ZERO_STRUCT(info3); - if (!(arch = cmd_spoolss_get_short_archi(argv[1]))) - { + + arch = cmd_spoolss_get_short_archi(argv[1]); + if (!arch) { printf ("Error Unknown architechture [%s]\n", argv[1]); return WERR_INVALID_PARAM; } - else - set_drv_info_3_env(&info3, arch); + + set_drv_info_3_env(mem_ctx, &info3, arch); driver_args = talloc_strdup( mem_ctx, argv[2] ); if (!init_drv_info_3_members(mem_ctx, &info3, driver_args )) @@ -1448,14 +1462,19 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli, } - ctr.info3 = &info3; - result = rpccli_spoolss_addprinterdriver (cli, mem_ctx, level, &ctr); + info_ctr.level = level; + info_ctr.info.info3 = &info3; + status = rpccli_spoolss_AddPrinterDriver(cli, mem_ctx, + cli->srv_name_slash, + &info_ctr, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } if (W_ERROR_IS_OK(result)) { - rpcstr_pull(driver_name, info3.name.buffer, - sizeof(driver_name), -1, STR_TERMINATE); printf ("Printer Driver %s successfully installed.\n", - driver_name); + info3.driver_name); } return result; |