summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-04-22 19:30:11 -0400
committerGünther Deschner <gd@samba.org>2010-05-18 15:52:28 +0200
commitd6a73ad85bff4867b48d12fa68479812f682ec0a (patch)
treeda855b5dd3f37e98875556e5a41a2fc7fc97f4c7 /source3/printing
parent007b9962676efef4cf2230f304ce263ce1e75555 (diff)
downloadsamba-d6a73ad85bff4867b48d12fa68479812f682ec0a.tar.gz
samba-d6a73ad85bff4867b48d12fa68479812f682ec0a.tar.bz2
samba-d6a73ad85bff4867b48d12fa68479812f682ec0a.zip
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@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c378
1 files changed, 0 insertions, 378 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 5b68d0b810..c27ef69ecf 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