diff options
author | Günther Deschner <gd@samba.org> | 2009-03-16 23:09:15 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-03-17 12:18:57 +0100 |
commit | 63d78712bc11df175bc8cb3b53f1e413211d7248 (patch) | |
tree | 4916943aa651c35f265661e396a104abf5077e3c | |
parent | 846b93f54f551a03dcca73c808751900e405e304 (diff) | |
download | samba-63d78712bc11df175bc8cb3b53f1e413211d7248.tar.gz samba-63d78712bc11df175bc8cb3b53f1e413211d7248.tar.bz2 samba-63d78712bc11df175bc8cb3b53f1e413211d7248.zip |
s3-spoolss: use pidl for _spoolss_EnumPrinterKey.
Guenther
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss.c | 22 | ||||
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 95 |
3 files changed, 49 insertions, 69 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 57d9a99269..d1e20db4b6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6050,7 +6050,6 @@ struct spoolss_DeviceMode *construct_dev_mode_new(TALLOC_CTX *mem_ctx, WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri ); bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer); WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines ); -WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u); WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u); /* The following definitions come from rpc_server/srv_srvsvc_nt.c */ diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index ced4ed53f4..1b9cdb3438 100644 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -456,27 +456,7 @@ static bool api_spoolss_setprinterdataex(pipes_struct *p) static bool api_spoolss_enumprinterkey(pipes_struct *p) { - SPOOL_Q_ENUMPRINTERKEY q_u; - SPOOL_R_ENUMPRINTERKEY r_u; - prs_struct *data = &p->in_data.data; - prs_struct *rdata = &p->out_data.rdata; - - ZERO_STRUCT(q_u); - ZERO_STRUCT(r_u); - - if(!spoolss_io_q_enumprinterkey("", &q_u, data, 0)) { - DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n")); - return False; - } - - r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u); - - if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) { - DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n")); - return False; - } - - return True; + return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERKEY); } /**************************************************************************** diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 9cde7d2e01..84064a308f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -9206,76 +9206,88 @@ WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p, return status; } -/******************************************************************** - * spoolss_enumprinterkey - ********************************************************************/ - +/**************************************************************** + _spoolss_EnumPrinterKey +****************************************************************/ -WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u) +WERROR _spoolss_EnumPrinterKey(pipes_struct *p, + struct spoolss_EnumPrinterKey *r) { - fstring key; fstring *keynames = NULL; - uint16 *enumkeys = NULL; int num_keys; - int printerkey_len; - POLICY_HND *handle = &q_u->handle; - Printer_entry *Printer = find_printer_index_by_hnd(p, handle); + Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle); NT_PRINTER_DATA *data; NT_PRINTER_INFO_LEVEL *printer = NULL; int snum = 0; - WERROR status = WERR_BADFILE; + WERROR result = WERR_BADFILE; + int i; + const char **array = NULL; - DEBUG(4,("_spoolss_enumprinterkey\n")); + DEBUG(4,("_spoolss_EnumPrinterKey\n")); if (!Printer) { - DEBUG(2,("_spoolss_enumprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle))); + DEBUG(2,("_spoolss_EnumPrinterKey: Invalid handle (%s:%u:%u).\n", + OUR_HANDLE(r->in.handle))); return WERR_BADFID; } - if ( !get_printer_snum(p,handle, &snum, NULL) ) + if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { return WERR_BADFID; + } - status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); - if (!W_ERROR_IS_OK(status)) - return status; + result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum)); + if (!W_ERROR_IS_OK(result)) { + return result; + } /* get the list of subkey names */ - unistr2_to_ascii(key, &q_u->key, sizeof(key)); data = printer->info_2->data; - num_keys = get_printer_subkeys( data, key, &keynames ); - - if ( num_keys == -1 ) { - status = WERR_BADFILE; + num_keys = get_printer_subkeys(data, r->in.key_name, &keynames); + if (num_keys == -1) { + result = WERR_BADFILE; goto done; } - printerkey_len = init_unistr_array( &enumkeys, keynames, NULL ); - - r_u->needed = printerkey_len*2; + *r->out.needed = 4; - if ( q_u->size < r_u->needed ) { - status = WERR_MORE_DATA; + array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 1); + if (!array) { + result = WERR_NOMEM; goto done; } - if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) { - status = WERR_NOMEM; + for (i=0; i < num_keys; i++) { + array[i] = talloc_strdup(array, keynames[i]); + if (!array[i]) { + result = WERR_NOMEM; + goto done; + } + + *r->out.needed += strlen_m_term(keynames[i]) * 2; + } + + if (r->in.offered < *r->out.needed) { + result = WERR_MORE_DATA; goto done; } - status = WERR_OK; + result = WERR_OK; - if ( q_u->size < r_u->needed ) - status = WERR_MORE_DATA; + *r->out.key_buffer = array; -done: - free_a_printer( &printer, 2 ); - SAFE_FREE( keynames ); + done: + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(array); + ZERO_STRUCTP(r->out.key_buffer); + } - return status; + free_a_printer(&printer, 2); + SAFE_FREE(keynames); + + return result; } /**************************************************************** @@ -10270,17 +10282,6 @@ WERROR _spoolss_EnumPrinterDataEx(pipes_struct *p, } /**************************************************************** - _spoolss_EnumPrinterKey -****************************************************************/ - -WERROR _spoolss_EnumPrinterKey(pipes_struct *p, - struct spoolss_EnumPrinterKey *r) -{ - p->rng_fault_state = true; - return WERR_NOT_SUPPORTED; -} - -/**************************************************************** _spoolss_53 ****************************************************************/ |