[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-430-g4ea46d6

Günther Deschner gd at samba.org
Tue Mar 17 11:02:10 GMT 2009


The branch, master has been updated
       via  4ea46d69bbb7651b213c5b0674f4f9fb05059acd (commit)
       via  628c12e53b68e34fa3744f57619aa5351d2519c9 (commit)
       via  f9871a846dcac079e33a9478fad5e3491a51e168 (commit)
       via  4234969df7fa973ee798bb656883a75d794006d6 (commit)
       via  b8a3e5ea0c8cc6b6b3ad6eda088673e1c8027caf (commit)
      from  6dca80518dda120753112204eaaae7961938bb9e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4ea46d69bbb7651b213c5b0674f4f9fb05059acd
Author: Günther Deschner <gd at samba.org>
Date:   Tue Mar 17 12:01:29 2009 +0100

    s3-net: temporary disable net_spoolss_setprinterdata.
    
    Guenther

commit 628c12e53b68e34fa3744f57619aa5351d2519c9
Author: Günther Deschner <gd at samba.org>
Date:   Sat Mar 14 02:26:08 2009 +0100

    s3-spoolss: remove old spoolss_SetPrinterData.
    
    Guenther

commit f9871a846dcac079e33a9478fad5e3491a51e168
Author: Günther Deschner <gd at samba.org>
Date:   Sat Mar 14 02:24:47 2009 +0100

    s3-spoolss: use pidl for _spoolss_SetPrinterData.
    
    Guenther

commit 4234969df7fa973ee798bb656883a75d794006d6
Author: Günther Deschner <gd at samba.org>
Date:   Sat Mar 14 02:22:59 2009 +0100

    s3-spoolss: remove old rpccli_spoolss_setprinterdata wrapper.
    
    Guenther

commit b8a3e5ea0c8cc6b6b3ad6eda088673e1c8027caf
Author: Günther Deschner <gd at samba.org>
Date:   Sat Mar 14 02:21:11 2009 +0100

    s3-rpcclient: use rpccli_spoolss_SetPrinterData.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h             |    7 --
 source3/include/rpc_spoolss.h       |   18 ------
 source3/rpc_client/cli_spoolss.c    |   26 --------
 source3/rpc_parse/parse_spoolss.c   |   80 -------------------------
 source3/rpc_server/srv_spoolss.c    |   22 +-------
 source3/rpc_server/srv_spoolss_nt.c |   92 +++++++++++++---------------
 source3/rpcclient/cmd_spoolss.c     |  111 +++++++++++++++--------------------
 source3/utils/net_rpc_printer.c     |    5 +-
 8 files changed, 95 insertions(+), 266 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 23a6c77..04f5997 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5540,8 +5540,6 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
 				     uint32_t offered,
 				     enum winreg_Type *type,
 				     union spoolss_PrinterData *data);
-WERROR rpccli_spoolss_setprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
-				  POLICY_HND *hnd, REGISTRY_VALUE *value);
 WERROR rpccli_spoolss_enumprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 				   POLICY_HND *hnd, uint32 ndx,
 				   uint32 value_offered, uint32 data_offered,
@@ -5856,10 +5854,6 @@ bool make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u,
 bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
 				      const POLICY_HND *hnd, const char *key,
 				      uint32 size);
-bool make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
-				   char* value, uint32 data_type, char* data, uint32 data_size);
-bool spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth);
 bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u, 
 				   POLICY_HND *hnd, const char *key, 
 				   uint32 size);
@@ -6067,7 +6061,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
 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_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u);
-WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u);
 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);
 
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index ef1cbd1..26fb032 100644
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -317,24 +317,6 @@ typedef struct spool_r_enumprinterdata
 }
 SPOOL_R_ENUMPRINTERDATA;
 
-typedef struct spool_q_setprinterdata
-{
-	POLICY_HND handle;
-	UNISTR2 value;
-	uint32 type;
-	uint32 max_len;
-	uint8 *data;
-	uint32 real_len;
-	uint32 numeric_data;
-}
-SPOOL_Q_SETPRINTERDATA;
-
-typedef struct spool_r_setprinterdata
-{
-	WERROR status;
-}
-SPOOL_R_SETPRINTERDATA;
-
 typedef struct spool_q_enumprinterkey
 {
 	POLICY_HND handle;
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 3f8e966..d7458dc 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -753,32 +753,6 @@ WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
 /**********************************************************************
 **********************************************************************/
 
-WERROR rpccli_spoolss_setprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
-				  POLICY_HND *hnd, REGISTRY_VALUE *value)
-{
-	prs_struct qbuf, rbuf;
-	SPOOL_Q_SETPRINTERDATA in;
-	SPOOL_R_SETPRINTERDATA out;
-
-	ZERO_STRUCT(in);
-	ZERO_STRUCT(out);
-
-        make_spoolss_q_setprinterdata( &in, hnd, value->valuename, 
-		value->type, (char *)value->data_p, value->size);
-
-	CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_SETPRINTERDATA,
-	            in, out, 
-	            qbuf, rbuf,
-	            spoolss_io_q_setprinterdata,
-	            spoolss_io_r_setprinterdata, 
-	            WERR_GENERAL_FAILURE );
-		    
-	return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
 WERROR rpccli_spoolss_enumprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
 				   POLICY_HND *hnd, uint32 ndx,
 				   uint32 value_offered, uint32 data_offered,
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index a7d69f6..673526d 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -419,86 +419,6 @@ bool make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
 }
 
 /*******************************************************************
-********************************************************************/  
-bool make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd,
-				   char* value, uint32 data_type, char* data, uint32 data_size)
-{
-	memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
-	q_u->type = data_type;
-	init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
-
-	q_u->max_len = q_u->real_len = data_size;
-	q_u->data = (unsigned char *)data;
-	
-	return True;
-}
-
-/*******************************************************************
-********************************************************************/  
-
-bool spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth)
-{
-	prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata");
-	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->value, True, ps, depth))
-		return False;
-
-	if(!prs_align(ps))
-		return False;
-
-	if(!prs_uint32("type", ps, depth, &q_u->type))
-		return False;
-
-	if(!prs_uint32("max_len", ps, depth, &q_u->max_len))
-		return False;
-
-	switch (q_u->type)
-	{
-		case REG_SZ:
-		case REG_BINARY:
-		case REG_DWORD:
-		case REG_MULTI_SZ:
-			if (q_u->max_len) {
-				if (UNMARSHALLING(ps))
-					q_u->data=PRS_ALLOC_MEM(ps, uint8, q_u->max_len);
-				if(q_u->data == NULL)
-					return False;
-				if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len))
-					return False;
-			}
-			if(!prs_align(ps))
-				return False;
-			break;
-	}	
-	
-	if(!prs_uint32("real_len", ps, depth, &q_u->real_len))
-		return False;
-
-	return True;
-}
-
-/*******************************************************************
-********************************************************************/  
-
-bool spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth)
-{
-	prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata");
-	depth++;
-
-	if(!prs_align(ps))
-		return False;
-	if(!prs_werror("status",     ps, depth, &r_u->status))
-		return False;
-
-	return True;
-}
-
-/*******************************************************************
  * read a structure.
  ********************************************************************/  
 bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u, 
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index c7ca223..1da15ae 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -378,27 +378,7 @@ static bool api_spoolss_enumprinterdata(pipes_struct *p)
 
 static bool api_spoolss_setprinterdata(pipes_struct *p)
 {
-	SPOOL_Q_SETPRINTERDATA q_u;
-	SPOOL_R_SETPRINTERDATA 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_setprinterdata("", &q_u, data, 0)) {
-		DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
-		return False;
-	}
-	
-	r_u.status = _spoolss_setprinterdata(p, &q_u, &r_u);
-				
-	if(!spoolss_io_r_setprinterdata("", &r_u, rdata, 0)) {
-		DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_SETPRINTERDATA.\n"));
-		return False;
-	}
-
-	return True;
+	return proxy_spoolss_call(p, NDR_SPOOLSS_SETPRINTERDATA);
 }
 
 /****************************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index aee9aa1..31cb030 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -8101,37 +8101,36 @@ done:
 	return result;
 }
 
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_SetPrinterData
+****************************************************************/
 
-WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u)
+WERROR _spoolss_SetPrinterData(pipes_struct *p,
+			       struct spoolss_SetPrinterData *r)
 {
-	POLICY_HND 		*handle = &q_u->handle;
-	UNISTR2 		*value = &q_u->value;
-	uint32 			type = q_u->type;
-	uint8 			*data = q_u->data;
-	uint32 			real_len = q_u->real_len;
-
-	NT_PRINTER_INFO_LEVEL 	*printer = NULL;
-	int 			snum=0;
-	WERROR 			status = WERR_OK;
-	Printer_entry 		*Printer=find_printer_index_by_hnd(p, handle);
-	fstring			valuename;
+	NT_PRINTER_INFO_LEVEL *printer = NULL;
+	int snum=0;
+	WERROR result = WERR_OK;
+	Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
+	DATA_BLOB blob;
 
-	DEBUG(5,("spoolss_setprinterdata\n"));
+	DEBUG(5,("_spoolss_SetPrinterData\n"));
 
 	if (!Printer) {
-		DEBUG(2,("_spoolss_setprinterdata: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle)));
+		DEBUG(2,("_spoolss_SetPrinterData: Invalid handle (%s:%u:%u).\n",
+			OUR_HANDLE(r->in.handle)));
 		return WERR_BADFID;
 	}
 
-	if ( Printer->printer_type == SPLHND_SERVER ) {
-		DEBUG(10,("_spoolss_setprinterdata: Not implemented for server handles yet\n"));
+	if (Printer->printer_type == SPLHND_SERVER) {
+		DEBUG(10,("_spoolss_SetPrinterData: "
+			"Not implemented for server handles yet\n"));
 		return WERR_INVALID_PARAM;
 	}
 
-	if (!get_printer_snum(p,handle, &snum, NULL))
+	if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
 		return WERR_BADFID;
+	}
 
 	/*
 	 * Access check : NT returns "access denied" if you make a
@@ -8141,43 +8140,49 @@ WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SP
 	 * when connecting to a printer  --jerry
 	 */
 
-	if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER)
-	{
-		DEBUG(3, ("_spoolss_setprinterdata: change denied by handle access permissions\n"));
-		status = WERR_ACCESS_DENIED;
+	if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) {
+		DEBUG(3,("_spoolss_SetPrinterData: "
+			"change denied by handle access permissions\n"));
+		result = WERR_ACCESS_DENIED;
 		goto done;
 	}
 
-	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;
+	}
 
-	unistr2_to_ascii(valuename, value, sizeof(valuename));
+	result = push_spoolss_PrinterData(p->mem_ctx, &blob,
+					  r->in.type, &r->in.data);
+	if (!W_ERROR_IS_OK(result)) {
+		goto done;
+	}
 
 	/*
 	 * When client side code sets a magic printer data key, detect it and save
 	 * the current printer data and the magic key's data (its the DEVMODE) for
 	 * future printer/driver initializations.
 	 */
-	if ( (type == REG_BINARY) && strequal( valuename, PHANTOM_DEVMODE_KEY))
-	{
+	if ((r->in.type == REG_BINARY) && strequal(r->in.value_name, PHANTOM_DEVMODE_KEY)) {
 		/* Set devmode and printer initialization info */
-		status = save_driver_init( printer, 2, data, real_len );
+		result = save_driver_init(printer, 2, blob.data, blob.length);
+
+		srv_spoolss_reset_printerdata(printer->info_2->drivername);
 
-		srv_spoolss_reset_printerdata( printer->info_2->drivername );
+		goto done;
 	}
-	else
-	{
-	status = set_printer_dataex( printer, SPOOL_PRINTERDATA_KEY, valuename,
-					type, data, real_len );
-		if ( W_ERROR_IS_OK(status) )
-			status = mod_a_printer(printer, 2);
+
+	result = set_printer_dataex(printer, SPOOL_PRINTERDATA_KEY,
+				    r->in.value_name, r->in.type,
+				    blob.data, blob.length);
+	if (W_ERROR_IS_OK(result)) {
+		result = mod_a_printer(printer, 2);
 	}
 
 done:
 	free_a_printer(&printer, 2);
 
-	return status;
+	return result;
 }
 
 /****************************************************************
@@ -9939,17 +9944,6 @@ WERROR _spoolss_ReadPrinter(pipes_struct *p,
 }
 
 /****************************************************************
- _spoolss_SetPrinterData
-****************************************************************/
-
-WERROR _spoolss_SetPrinterData(pipes_struct *p,
-			       struct spoolss_SetPrinterData *r)
-{
-	p->rng_fault_state = true;
-	return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
  _spoolss_WaitForPrinterChange
 ****************************************************************/
 
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index f4802f7..7a077fd 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -2114,11 +2114,12 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
 					    int argc, const char **argv)
 {
 	WERROR result;
+	NTSTATUS status;
 	const char *printername;
 	POLICY_HND pol;
 	union spoolss_PrinterInfo info;
-	REGISTRY_VALUE value;
-	TALLOC_CTX *tmp_ctx = talloc_stackframe();
+	enum winreg_Type type;
+	union spoolss_PrinterData data;
 
 	/* parse the command arguments */
 	if (argc < 5) {
@@ -2131,25 +2132,25 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
 
 	RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
 
-	value.type = REG_NONE;
+	type = REG_NONE;
 
 	if (strequal(argv[2], "string")) {
-		value.type = REG_SZ;
+		type = REG_SZ;
 	}
 
 	if (strequal(argv[2], "binary")) {
-		value.type = REG_BINARY;
+		type = REG_BINARY;
 	}
 
 	if (strequal(argv[2], "dword")) {
-		value.type = REG_DWORD;
+		type = REG_DWORD;
 	}
 
 	if (strequal(argv[2], "multistring")) {
-		value.type = REG_MULTI_SZ;
+		type = REG_MULTI_SZ;
 	}
 
-	if (value.type == REG_NONE) {
+	if (type == REG_NONE) {
 		printf("Unknown data type: %s\n", argv[2]);
 		result =  WERR_INVALID_PARAM;
 		goto done;
@@ -2161,92 +2162,73 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
 					       printername,
 					       SEC_FLAG_MAXIMUM_ALLOWED,
 					       &pol);
-	if (!W_ERROR_IS_OK(result))
+	if (!W_ERROR_IS_OK(result)) {
 		goto done;
+	}
 
 	result = rpccli_spoolss_getprinter(cli, mem_ctx,
 					   &pol,
 					   0,
 					   0,
 					   &info);
-        if (!W_ERROR_IS_OK(result))
+        if (!W_ERROR_IS_OK(result)) {
                 goto done;
+	}
 
-	printf("%s\n", current_timestring(tmp_ctx, True));
+	printf("%s\n", current_timestring(mem_ctx, true));
 	printf("\tchange_id (before set)\t:[0x%x]\n", info.info0.change_id);
 
 	/* Set the printer data */
 
-	fstrcpy(value.valuename, argv[3]);
-
-	switch (value.type) {
-	case REG_SZ: {
-		UNISTR2 data;
-		init_unistr2(&data, argv[4], UNI_STR_TERMINATE);
-		value.size = data.uni_str_len * 2;
-		if (value.size) {
-			value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, data.buffer,
-						      value.size);
-		} else {
-			value.data_p = NULL;
-		}
+	switch (type) {
+	case REG_SZ:
+		data.string = talloc_strdup(mem_ctx, argv[4]);
+		W_ERROR_HAVE_NO_MEMORY(data.string);
 		break;
-	}
-	case REG_DWORD: {
-		uint32 data = strtoul(argv[4], NULL, 10);
-		value.size = sizeof(data);
-		if (sizeof(data)) {
-			value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, &data,
-						      sizeof(data));
-		} else {
-			value.data_p = NULL;
-		}
+	case REG_DWORD:
+		data.value = strtoul(argv[4], NULL, 10);
 		break;
-	}
-	case REG_BINARY: {
-		DATA_BLOB data = strhex_to_data_blob(mem_ctx, argv[4]);
-		value.data_p = data.data;
-		value.size = data.length;
+	case REG_BINARY:
+		data.binary = strhex_to_data_blob(mem_ctx, argv[4]);
 		break;
-	}
 	case REG_MULTI_SZ: {
-		int i;
-		size_t len = 0;
-		char *p;
+		int i, num_strings;
+		const char **strings = NULL;
 
 		for (i=4; i<argc; i++) {
 			if (strcmp(argv[i], "NULL") == 0) {
 				argv[i] = "";
 			}
-			len += strlen(argv[i])+1;
+			if (!add_string_to_array(mem_ctx, argv[i],
+						 &strings,
+						 &num_strings)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list