summaryrefslogtreecommitdiff
path: root/source3
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
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')
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/printing/nt_printing.c378
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c175
3 files changed, 1 insertions, 555 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c1976082e0..9a2320b935 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 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
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 749108f416..a993515015 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) ) {
- DEBUG(5,("reset_all_printerdata: Error resetting printer data for printer [%s], driver [%s]!\n",
- printer->info_2->printername, printer->info_2->drivername));
- }
-
- result = mod_a_printer( printer, 2 );
- if ( !W_ERROR_IS_OK(result) ) {
- DEBUG(3,("reset_all_printerdata: mod_a_printer() failed! (%s)\n",
- get_dos_error_msg(result)));
- }
- }
-
- free_a_printer( &printer, 2 );
- }
- }
-
- /* all done */
-
- return;
-}
/****************************************************************
_spoolss_OpenPrinter
@@ -5786,12 +5699,6 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
*/
if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername))
{
- if (!set_driver_init(printer, 2))
- {
- DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n",
- printer->info_2->drivername));
- }
-
DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n",
printer->info_2->drivername));
@@ -7340,11 +7247,7 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
* bound to the new printer, simulating what happens in the Windows arch.
*/
- if (!devmode)
- {
- set_driver_init(printer, 2);
- }
- else
+ if (devmode)
{
/* A valid devmode was included, convert and link it
*/
@@ -7499,68 +7402,6 @@ WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p,
fn, driver_name));
}
- /*
- * Based on the version (e.g. driver destination dir: 0=9x,2=Nt/2k,3=2k/Xp),
- * decide if the driver init data should be deleted. The rules are:
- * 1) never delete init data if it is a 9x driver, they don't use it anyway
- * 2) delete init data only if there is no 2k/Xp driver
- * 3) always delete init data
- * The generalized rule is always use init data from the highest order driver.
- * It is necessary to follow the driver install by an initialization step to
- * finish off this process.
- */
-
- switch (version) {
- /*
- * 9x printer driver - never delete init data
- */
- case 0:
- DEBUG(10,("%s: init data not deleted for 9x driver [%s]\n",
- fn, driver_name));
- break;
-
- /*
- * Nt or 2k (compatiblity mode) printer driver - only delete init data if
- * there is no 2k/Xp driver init data for this driver name.
- */
- case 2:
- {
- struct spoolss_DriverInfo8 *driver1;
-
- if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &driver1, driver_name, "Windows NT x86", 3))) {
- /*
- * No 2k/Xp driver found, delete init data (if any) for the new Nt driver.
- */
- if (!del_driver_init(driver_name))
- DEBUG(6,("%s: del_driver_init(%s) Nt failed!\n",
- fn, driver_name));
- } else {
- /*
- * a 2k/Xp driver was found, don't delete init data because Nt driver will use it.
- */
- free_a_printer_driver(driver1);
- DEBUG(10,("%s: init data not deleted for Nt driver [%s]\n",
- fn, driver_name));
- }
- }
- break;
-
- /*
- * 2k or Xp printer driver - always delete init data
- */
- case 3:
- if (!del_driver_init(driver_name))
- DEBUG(6,("%s: del_driver_init(%s) 2k/Xp failed!\n",
- fn, driver_name));
- break;
-
- default:
- DEBUG(0,("%s: invalid level=%d\n", fn,
- r->in.info_ctr->level));
- break;
- }
-
-
done:
return err;
}
@@ -8903,20 +8744,6 @@ WERROR _spoolss_SetPrinterDataEx(pipes_struct *p,
oid_string++;
}
- /*
- * 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 ((r->in.type == REG_BINARY) && strequal(r->in.value_name, PHANTOM_DEVMODE_KEY)) {
- /* Set devmode and printer initialization info */
- result = save_driver_init(printer, 2, r->in.data, r->in.offered);
-
- srv_spoolss_reset_printerdata(printer->info_2->drivername);
-
- goto done;
- }
-
/* save the registry data */
result = set_printer_dataex(printer, r->in.key_name, r->in.value_name,