[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Tue May 18 07:53:00 MDT 2010


The branch, master has been updated
       via  d6a73ad... s3-spoolss: Removed the Phantom DeviceMode.
      from  007b996... s3-net: also dump security descriptors from ntprinters.tdb in "net printing dump".

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


- Log -----------------------------------------------------------------
commit d6a73ad85bff4867b48d12fa68479812f682ec0a
Author: Simo Sorce <idra at samba.org>
Date:   Thu Apr 22 19:30:11 2010 -0400

    s3-spoolss: Removed the Phantom DeviceMode.
    
    This was a hack that required a special client from HP.
    The client code has never been released and was discontinued,
    so this code was just dead weight.
    
    Signed-off-by: Günther Deschner <gd at samba.org>

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

Summary of changes:
 source3/include/proto.h             |    3 -
 source3/printing/nt_printing.c      |  378 -----------------------------------
 source3/rpc_server/srv_spoolss_nt.c |  175 +----------------
 3 files changed, 1 insertions(+), 555 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index c197608..9a2320b 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4765,9 +4765,6 @@ WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const cha
                            uint32 type, uint8 *data, int real_len );
 struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
 WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-bool del_driver_init(const char *drivername);
-WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *data, uint32 data_len);
 WERROR get_a_printer( Printer_entry *print_hnd,
 			NT_PRINTER_INFO_LEVEL **pp_printer,
 			uint32 level,
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 5b68d0b..c27ef69 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -30,7 +30,6 @@ static TDB_CONTEXT *tdb_printers; /* used for printers files */
 
 #define FORMS_PREFIX "FORMS/"
 #define DRIVERS_PREFIX "DRIVERS/"
-#define DRIVER_INIT_PREFIX "DRIVER_INIT/"
 #define PRINTERS_PREFIX "PRINTERS/"
 #define SECDESC_PREFIX "SECDESC/"
 #define GLOBAL_C_SETPRINTER "GLOBALS/c_setprinter"
@@ -611,14 +610,6 @@ bool nt_printing_init(struct messaging_context *msg_ctx)
 	messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE,
 			   do_drv_upgrade_printer);
 
-	/*
-	 * register callback to handle updating printer data
-	 * when a driver is initialized
-	 */
-
-	messaging_register(msg_ctx, NULL, MSG_PRINTERDATA_INIT_RESET,
-			   reset_all_printerdata);
-
 	/* of course, none of the message callbacks matter if you don't
 	   tell messages.c that you interested in receiving PRINT_GENERAL
 	   msgs.  This is done in serverid_register() */
@@ -4442,375 +4433,6 @@ WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
 }
 
 /****************************************************************************
- Initialize printer devmode & data with previously saved driver init values.
-****************************************************************************/
-
-static bool set_driver_init_2( NT_PRINTER_INFO_LEVEL_2 *info_ptr )
-{
-	int                     len = 0;
-	char *key = NULL;
-	TDB_DATA                dbuf;
-	NT_PRINTER_INFO_LEVEL_2 info;
-
-
-	ZERO_STRUCT(info);
-
-	/*
-	 * Delete any printer data 'values' already set. When called for driver
-	 * replace, there will generally be some, but during an add printer, there
-	 * should not be any (if there are delete them).
-	 */
-
-	if ( info_ptr->data )
-		delete_all_printer_data( info_ptr, "" );
-
-	if (asprintf(&key, "%s%s", DRIVER_INIT_PREFIX,
-				info_ptr->drivername) < 0) {
-		return false;
-	}
-
-	dbuf = tdb_fetch_bystring(tdb_drivers, key);
-	if (!dbuf.dptr) {
-		/*
-		 * When changing to a driver that has no init info in the tdb, remove
-		 * the previous drivers init info and leave the new on blank.
-		 */
-		free_nt_devicemode(&info_ptr->devmode);
-		SAFE_FREE(key);
-		return false;
-	}
-
-	SAFE_FREE(key);
-	/*
-	 * Get the saved DEVMODE..
-	 */
-
-	len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len);
-
-	/*
-	 * The saved DEVMODE contains the devicename from the printer used during
-	 * the initialization save. Change it to reflect the new printer.
-	 */
-
-	if ( info.devmode ) {
-		ZERO_STRUCT(info.devmode->devicename);
-		fstrcpy(info.devmode->devicename, info_ptr->printername);
-	}
-
-	/*
-	 * NT/2k does not change out the entire DeviceMode of a printer
-	 * when changing the driver.  Only the driverextra, private, &
-	 * driverversion fields.   --jerry  (Thu Mar 14 08:58:43 CST 2002)
-	 *
-	 * Later examination revealed that Windows NT/2k does reset the
-	 * the printer's device mode, bit **only** when you change a
-	 * property of the device mode such as the page orientation.
-	 * --jerry
-	 */
-
-
-	/* Bind the saved DEVMODE to the new the printer */
-
-	free_nt_devicemode(&info_ptr->devmode);
-	info_ptr->devmode = info.devmode;
-
-	DEBUG(10,("set_driver_init_2: Set printer [%s] init %s DEVMODE for driver [%s]\n",
-		info_ptr->printername, info_ptr->devmode?"VALID":"NULL", info_ptr->drivername));
-
-	/* Add the printer data 'values' to the new printer */
-
-	if ( !(info_ptr->data = TALLOC_ZERO_P( info_ptr, NT_PRINTER_DATA )) ) {
-		DEBUG(0,("set_driver_init_2: talloc() failed!\n"));
-		return False;
-	}
-
-	len += unpack_values( info_ptr->data, dbuf.dptr+len, dbuf.dsize-len );
-
-	SAFE_FREE(dbuf.dptr);
-
-	return true;
-}
-
-/****************************************************************************
- Initialize printer devmode & data with previously saved driver init values.
- When a printer is created using AddPrinter, the drivername bound to the
- printer is used to lookup previously saved driver initialization info, which
- is bound to the new printer.
-****************************************************************************/
-
-bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
-{
-	bool result = False;
-
-	switch (level) {
-		case 2:
-			result = set_driver_init_2(printer->info_2);
-			break;
-
-		default:
-			DEBUG(0,("set_driver_init: Programmer's error!  Unknown driver_init level [%d]\n",
-				level));
-			break;
-	}
-
-	return result;
-}
-
-/****************************************************************************
- Delete driver init data stored for a specified driver
-****************************************************************************/
-
-bool del_driver_init(const char *drivername)
-{
-	char *key;
-	bool ret;
-
-	if (!drivername || !*drivername) {
-		DEBUG(3,("del_driver_init: No drivername specified!\n"));
-		return false;
-	}
-
-	if (asprintf(&key, "%s%s", DRIVER_INIT_PREFIX, drivername) < 0) {
-		return false;
-	}
-
-	DEBUG(6,("del_driver_init: Removing driver init data for [%s]\n",
-				drivername));
-
-	ret = (tdb_delete_bystring(tdb_drivers, key) == 0);
-	SAFE_FREE(key);
-	return ret;
-}
-
-/****************************************************************************
- Pack up the DEVMODE and values for a printer into a 'driver init' entry
- in the tdb. Note: this is different from the driver entry and the printer
- entry. There should be a single driver init entry for each driver regardless
- of whether it was installed from NT or 2K. Technically, they should be
- different, but they work out to the same struct.
-****************************************************************************/
-
-static uint32 update_driver_init_2(NT_PRINTER_INFO_LEVEL_2 *info)
-{
-	char *key = NULL;
-	uint8 *buf;
-	int buflen, len, ret;
-	int retlen;
-	TDB_DATA dbuf;
-
-	buf = NULL;
-	buflen = 0;
-
- again:
-	len = 0;
-	len += pack_devicemode(info->devmode, buf+len, buflen-len);
-
-	retlen = pack_values( info->data, buf+len, buflen-len );
-	if (retlen == -1) {
-		ret = -1;
-		goto done;
-	}
-	len += retlen;
-
-	if (buflen < len) {
-		buf = (uint8 *)SMB_REALLOC(buf, len);
-		if (!buf) {
-			DEBUG(0, ("update_driver_init_2: failed to enlarge buffer!\n"));
-			ret = -1;
-			goto done;
-		}
-		buflen = len;
-		goto again;
-	}
-
-	SAFE_FREE(key);
-	if (asprintf(&key, "%s%s", DRIVER_INIT_PREFIX, info->drivername) < 0) {
-		ret = (uint32)-1;
-		goto done;
-	}
-
-	dbuf.dptr = buf;
-	dbuf.dsize = len;
-
-	ret = tdb_store_bystring(tdb_drivers, key, dbuf, TDB_REPLACE);
-
-done:
-	if (ret == -1)
-		DEBUG(8, ("update_driver_init_2: error updating printer init to tdb on disk\n"));
-
-	SAFE_FREE(buf);
-
-	DEBUG(10,("update_driver_init_2: Saved printer [%s] init DEVMODE & values for driver [%s]\n",
-		 info->sharename, info->drivername));
-
-	return ret;
-}
-
-/****************************************************************************
- Update (i.e. save) the driver init info (DEVMODE and values) for a printer
-****************************************************************************/
-
-static uint32 update_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
-{
-	uint32 result;
-
-	dump_a_printer(printer, level);
-
-	switch (level) {
-		case 2:
-			result = update_driver_init_2(printer->info_2);
-			break;
-		default:
-			result = 1;
-			break;
-	}
-
-	return result;
-}
-
-/****************************************************************************
- Convert the printer data value, a REG_BINARY array, into an initialization
- DEVMODE. Note: the array must be parsed as if it was a DEVMODE in an rpc...
- got to keep the endians happy :).
-****************************************************************************/
-
-static bool convert_driver_init(TALLOC_CTX *mem_ctx, NT_DEVICEMODE *nt_devmode,
-				const uint8_t *data, uint32_t data_len)
-{
-	struct spoolss_DeviceMode devmode;
-	enum ndr_err_code ndr_err;
-	DATA_BLOB blob;
-
-	ZERO_STRUCT(devmode);
-
-	blob = data_blob_const(data, data_len);
-
-	ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, &devmode,
-			(ndr_pull_flags_fn_t)ndr_pull_spoolss_DeviceMode);
-	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-		DEBUG(10,("convert_driver_init: error parsing spoolss_DeviceMode\n"));
-		return false;
-	}
-
-	return convert_devicemode("", &devmode, &nt_devmode);
-}
-
-/****************************************************************************
- Set the DRIVER_INIT info in the tdb. Requires Win32 client code that:
-
- 1. Use the driver's config DLL to this UNC printername and:
-    a. Call DrvPrintEvent with PRINTER_EVENT_INITIALIZE
-    b. Call DrvConvertDevMode with CDM_DRIVER_DEFAULT to get default DEVMODE
- 2. Call SetPrinterData with the 'magic' key and the DEVMODE as data.
-
- The last step triggers saving the "driver initialization" information for
- this printer into the tdb. Later, new printers that use this driver will
- have this initialization information bound to them. This simulates the
- driver initialization, as if it had run on the Samba server (as it would
- have done on NT).
-
- The Win32 client side code requirement sucks! But until we can run arbitrary
- Win32 printer driver code on any Unix that Samba runs on, we are stuck with it.
-
- It would have been easier to use SetPrinter because all the UNMARSHALLING of
- the DEVMODE is done there, but 2K/XP clients do not set the DEVMODE... think
- about it and you will realize why.  JRR 010720
-****************************************************************************/
-
-static WERROR save_driver_init_2(NT_PRINTER_INFO_LEVEL *printer, uint8 *data, uint32 data_len )
-{
-	WERROR        status       = WERR_OK;
-	TALLOC_CTX    *ctx         = NULL;
-	NT_DEVICEMODE *nt_devmode  = NULL;
-	NT_DEVICEMODE *tmp_devmode = printer->info_2->devmode;
-
-	/*
-	 * When the DEVMODE is already set on the printer, don't try to unpack it.
-	 */
-	DEBUG(8,("save_driver_init_2: Enter...\n"));
-
-	if ( !printer->info_2->devmode && data_len ) {
-		/*
-		 * Set devmode on printer info, so entire printer initialization can be
-		 * saved to tdb.
-		 */
-
-		if ((ctx = talloc_init("save_driver_init_2")) == NULL)
-			return WERR_NOMEM;
-
-		if ((nt_devmode = SMB_MALLOC_P(NT_DEVICEMODE)) == NULL) {
-			status = WERR_NOMEM;
-			goto done;
-		}
-
-		ZERO_STRUCTP(nt_devmode);
-
-		/*
-		 * The DEVMODE is held in the 'data' component of the param in raw binary.
-		 * Convert it to to a devmode structure
-		 */
-		if ( !convert_driver_init( ctx, nt_devmode, data, data_len )) {
-			DEBUG(10,("save_driver_init_2: error converting DEVMODE\n"));
-			status = WERR_INVALID_PARAM;
-			goto done;
-		}
-
-		printer->info_2->devmode = nt_devmode;
-	}
-
-	/*
-	 * Pack up and add (or update) the DEVMODE and any current printer data to
-	 * a 'driver init' element in the tdb
-	 *
-	 */
-
-	if ( update_driver_init(printer, 2) != 0 ) {
-		DEBUG(10,("save_driver_init_2: error updating DEVMODE\n"));
-		status = WERR_NOMEM;
-		goto done;
-	}
-
-	/*
-	 * If driver initialization info was successfully saved, set the current
-	 * printer to match it. This allows initialization of the current printer
-	 * as well as the driver.
-	 */
-	status = mod_a_printer(printer, 2);
-	if (!W_ERROR_IS_OK(status)) {
-		DEBUG(10,("save_driver_init_2: error setting DEVMODE on printer [%s]\n",
-				  printer->info_2->printername));
-	}
-
-  done:
-	talloc_destroy(ctx);
-	free_nt_devicemode( &nt_devmode );
-
-	printer->info_2->devmode = tmp_devmode;
-
-	return status;
-}
-
-/****************************************************************************
- Update the driver init info (DEVMODE and specifics) for a printer
-****************************************************************************/
-
-WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *data, uint32 data_len)
-{
-	WERROR status = WERR_OK;
-
-	switch (level) {
-		case 2:
-			status = save_driver_init_2( printer, data, data_len );
-			break;
-		default:
-			status = WERR_UNKNOWN_LEVEL;
-			break;
-	}
-
-	return status;
-}
-
-/****************************************************************************
  Get a NT_PRINTER_INFO_LEVEL struct. It returns malloced memory.
 
  Previously the code had a memory allocation problem because it always
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 749108f..a993515 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -55,7 +55,6 @@ extern userdom_struct current_user_info;
 #endif
 
 #define MAGIC_DISPLAY_FREQUENCY 0xfade2bad
-#define PHANTOM_DEVMODE_KEY "_p_f_a_n_t_0_m_"
 
 static Printer_entry *printers_list;
 
@@ -1351,92 +1350,6 @@ void update_monitored_printq_cache( void )
 
 	return;
 }
-/********************************************************************
- Send a message to ourself about new driver being installed
- so we can upgrade the information for each printer bound to this
- driver
- ********************************************************************/
-
-static bool srv_spoolss_reset_printerdata(char* drivername)
-{
-	int len = strlen(drivername);
-
-	if (!len)
-		return false;
-
-	DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n",
-		drivername));
-
-	messaging_send_buf(smbd_messaging_context(), procid_self(),
-			   MSG_PRINTERDATA_INIT_RESET,
-			   (uint8_t *)drivername, len+1);
-
-	return true;
-}
-
-/**********************************************************************
- callback to receive a MSG_PRINTERDATA_INIT_RESET message and interate
- over all printers, resetting printer data as neessary
- **********************************************************************/
-
-void reset_all_printerdata(struct messaging_context *msg,
-			   void *private_data,
-			   uint32_t msg_type,
-			   struct server_id server_id,
-			   DATA_BLOB *data)
-{
-	fstring drivername;
-	int snum;
-	int n_services = lp_numservices();
-	size_t len;
-
-	len = MIN( data->length, sizeof(drivername)-1 );
-	strncpy( drivername, (const char *)data->data, len );
-
-	DEBUG(10,("reset_all_printerdata: Got message for new driver [%s]\n", drivername ));
-
-	/* Iterate the printer list */
-
-	for ( snum=0; snum<n_services; snum++ )
-	{
-		if ( lp_snum_ok(snum) && lp_print_ok(snum) )
-		{
-			WERROR result;
-			NT_PRINTER_INFO_LEVEL *printer = NULL;
-
-			result = get_a_printer( NULL, &printer, 2, lp_const_servicename(snum) );
-			if ( !W_ERROR_IS_OK(result) )
-				continue;
-
-			/*
-			 * if the printer is bound to the driver,
-			 * then reset to the new driver initdata
-			 */
-
-			if ( printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername) )
-			{
-				DEBUG(6,("reset_all_printerdata: Updating printer [%s]\n", printer->info_2->printername));
-
-				if ( !set_driver_init(printer, 2) ) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list