[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-449-g338c610
Günther Deschner
gd at samba.org
Tue Mar 17 11:20:14 GMT 2009
The branch, master has been updated
via 338c61060b0af1a959cfd77e4d015853a7f09bfb (commit)
via 63d78712bc11df175bc8cb3b53f1e413211d7248 (commit)
via 846b93f54f551a03dcca73c808751900e405e304 (commit)
via e0c50aafce59ad4f4275ff91defb14ea44f42a65 (commit)
via bc95ec04e6b555b1dd2ce9d253c5a3fc3f095443 (commit)
via 86c25b353381179ee392841618c9ae34dca1d992 (commit)
from 87d97ad0422c771ea575e9a5e68d0d2e5bfe25be (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 338c61060b0af1a959cfd77e4d015853a7f09bfb
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 23:10:35 2009 +0100
s3-spoolss: remove old spoolss_EnumPrinterKey.
Guenther
commit 63d78712bc11df175bc8cb3b53f1e413211d7248
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 23:09:15 2009 +0100
s3-spoolss: use pidl for _spoolss_EnumPrinterKey.
Guenther
commit 846b93f54f551a03dcca73c808751900e405e304
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 22:09:22 2009 +0100
s3-spoolss: remove old rpccli_spoolss_enumprinterkey wrapper.
Guenther
commit e0c50aafce59ad4f4275ff91defb14ea44f42a65
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 23:38:05 2009 +0100
s3-net: use rpccli_spoolss_enumprinterkey wrapper.
Guenther
commit bc95ec04e6b555b1dd2ce9d253c5a3fc3f095443
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 22:07:00 2009 +0100
s3-rpcclient: use rpccli_spoolss_enumprinterkey wrapper.
Guenther
commit 86c25b353381179ee392841618c9ae34dca1d992
Author: Günther Deschner <gd at samba.org>
Date: Mon Mar 16 21:41:11 2009 +0100
s3-spoolss: add rpccli_spoolss_enumprinterkey convenience wrapper.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/include/proto.h | 15 ++---
source3/include/rpc_spoolss.h | 16 ------
source3/rpc_client/cli_spoolss.c | 94 ++++++++++++++--------------------
source3/rpc_parse/parse_spoolss.c | 69 -------------------------
source3/rpc_server/srv_spoolss.c | 22 +--------
source3/rpc_server/srv_spoolss_nt.c | 95 ++++++++++++++++++-----------------
source3/rpcclient/cmd_spoolss.c | 45 ++++++++--------
source3/utils/net_rpc_printer.c | 23 ++------
8 files changed, 122 insertions(+), 257 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e73237d..3669144 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5540,12 +5540,15 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
uint32_t offered,
enum winreg_Type *type,
union spoolss_PrinterData *data);
+WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ const char *key_name,
+ const char ***key_buffer,
+ uint32_t offered);
WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *keyname,
REGVAL_CTR *ctr);
-WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, const char *keyname,
- uint16 **keylist, uint32 *len);
/* The following definitions come from rpc_client/init_spoolss.c */
@@ -5844,11 +5847,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16
bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
const POLICY_HND *hnd, const char *key,
uint32 size);
-bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
- POLICY_HND *hnd, const char *key,
- uint32 size);
-bool spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth);
@@ -6050,7 +6048,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/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 7c14e73..0ad684d 100644
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -295,22 +295,6 @@ SYSTEMTIME;
/********************************************/
-typedef struct spool_q_enumprinterkey
-{
- POLICY_HND handle;
- UNISTR2 key;
- uint32 size;
-}
-SPOOL_Q_ENUMPRINTERKEY;
-
-typedef struct spool_r_enumprinterkey
-{
- BUFFER5 keys;
- uint32 needed; /* in bytes */
- WERROR status;
-}
-SPOOL_R_ENUMPRINTERKEY;
-
typedef struct printer_enum_values
{
UNISTR valuename;
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 66e760c..9ca3ab6 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -746,6 +746,45 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
return werror;
}
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_EnumPrinterKey
+**********************************************************************/
+
+WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ const char *key_name,
+ const char ***key_buffer,
+ uint32_t offered)
+{
+ NTSTATUS status;
+ WERROR werror;
+ uint32_t needed;
+
+ status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
+ handle,
+ key_name,
+ key_buffer,
+ offered,
+ &needed,
+ &werror);
+
+ if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
+ offered = needed;
+
+ status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
+ handle,
+ key_name,
+ key_buffer,
+ offered,
+ &needed,
+ &werror);
+ }
+
+ return werror;
+}
+
+
/*********************************************************************
Decode various spoolss rpc's and info levels
********************************************************************/
@@ -807,59 +846,4 @@ WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli, TALLOC_CTX
return out.status;
}
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, const char *keyname,
- uint16 **keylist, uint32 *len)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ENUMPRINTERKEY in;
- SPOOL_R_ENUMPRINTERKEY out;
- uint32 offered = 0;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- make_spoolss_q_enumprinterkey( &in, hnd, keyname, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERKEY,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinterkey,
- spoolss_io_r_enumprinterkey,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- make_spoolss_q_enumprinterkey( &in, hnd, keyname, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ENUMPRINTERKEY,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_enumprinterkey,
- spoolss_io_r_enumprinterkey,
- WERR_GENERAL_FAILURE );
- }
-
- if ( !W_ERROR_IS_OK(out.status) )
- return out.status;
-
- if (keylist) {
- *keylist = SMB_MALLOC_ARRAY(uint16, out.keys.buf_len);
- if (!*keylist) {
- return WERR_NOMEM;
- }
- memcpy(*keylist, out.keys.buffer, out.keys.buf_len * 2);
- if (len)
- *len = out.keys.buf_len * 2;
- }
-
- return out.status;
-}
/** @} **/
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 91cb40e..ae73c35 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -327,75 +327,6 @@ bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
/*******************************************************************
* read a structure.
********************************************************************/
-bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
- POLICY_HND *hnd, const char *key,
- uint32 size)
-{
- DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
-
- memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
- q_u->size = size;
-
- return True;
-}
-
-/*******************************************************************
- * read a structure.
- ********************************************************************/
-
-bool spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey");
- depth++;
-
- if(!prs_align(ps))
- return False;
- if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth))
- return False;
-
- if(!smb_io_unistr2("", &q_u->key, True, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("size", ps, depth, &q_u->size))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * write a structure.
- ********************************************************************/
-
-bool spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if (!smb_io_buffer5("", &r_u->keys, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("needed", ps, depth, &r_u->needed))
- return False;
-
- if(!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * read a structure.
- ********************************************************************/
bool spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth)
{
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index ced4ed5..1b9cdb3 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 9cde7d2..84064a3 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
****************************************************************/
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 1043a78..aba2939 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -2592,25 +2592,27 @@ done:
/****************************************************************************
****************************************************************************/
-static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
+static WERROR cmd_spoolss_enum_printerkey(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
{
WERROR result;
const char *printername;
const char *keyname = NULL;
POLICY_HND hnd;
- uint16 *keylist = NULL, *curkey;
+ const char **key_buffer = NULL;
+ int i;
if (argc < 2 || argc > 3) {
printf("Usage: %s printername [keyname]\n", argv[0]);
return WERR_OK;
}
- if (argc == 3)
+ if (argc == 3) {
keyname = argv[2];
- else
+ } else {
keyname = "";
+ }
/* Open printer handle */
@@ -2620,34 +2622,31 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
printername,
SEC_FLAG_MAXIMUM_ALLOWED,
&hnd);
- if (!W_ERROR_IS_OK(result))
+ if (!W_ERROR_IS_OK(result)) {
goto done;
+ }
/* Enumerate subkeys */
- result = rpccli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, &keylist, NULL);
+ result = rpccli_spoolss_enumprinterkey(cli, mem_ctx,
+ &hnd,
+ keyname,
+ &key_buffer,
+ 0);
- if (!W_ERROR_IS_OK(result))
+ if (!W_ERROR_IS_OK(result)) {
goto done;
-
--
Samba Shared Repository
More information about the samba-cvs
mailing list