[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Mon Nov 23 04:20:29 MST 2009


The branch, master has been updated
       via  6364c27... s3-printing: remove unused NT_PRINTER_DRIVER_INFO_LEVEL structs.
       via  ec56895... s3-printing: use spoolss types and structs while getting and deleting drivers.
       via  68cc116... s3-printing: use spoolss types and structs while adding drivers.
      from  d66b7d8... s4-smbtorture: add tests for spoolss_EnumPrinterKey to RPC-SPOOLSS-PRINTER.

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


- Log -----------------------------------------------------------------
commit 6364c271c4daff94c641eb9e7030f3c9a7ff1ced
Author: Günther Deschner <gd at samba.org>
Date:   Tue Nov 17 12:55:45 2009 +0100

    s3-printing: remove unused NT_PRINTER_DRIVER_INFO_LEVEL structs.
    
    Guenther

commit ec56895bdec90cc671a0d562749b3caf161dbdf8
Author: Günther Deschner <gd at samba.org>
Date:   Tue Nov 17 12:54:02 2009 +0100

    s3-printing: use spoolss types and structs while getting and deleting drivers.
    
    Guenther

commit 68cc1166d96ac81abce78a7eb60b7b86d0eb4eda
Author: Günther Deschner <gd at samba.org>
Date:   Mon Nov 16 15:52:31 2009 +0100

    s3-printing: use spoolss types and structs while adding drivers.
    
    Guenther

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

Summary of changes:
 source3/include/nt_printing.h           |   41 --
 source3/include/proto.h                 |   27 +-
 source3/printing/nt_printing.c          |  763 +++++++++++++------------------
 source3/registry/reg_backend_printing.c |   31 +-
 source3/rpc_server/srv_spoolss_nt.c     |  521 +++++++---------------
 source3/smbd/lanman.c                   |   61 ++--
 6 files changed, 545 insertions(+), 899 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/nt_printing.h b/source3/include/nt_printing.h
index 12096c8..c074c8e 100644
--- a/source3/include/nt_printing.h
+++ b/source3/include/nt_printing.h
@@ -22,47 +22,6 @@
 #ifndef NT_PRINTING_H_
 #define NT_PRINTING_H_
 
-typedef struct nt_printer_driver_info_level_3
-{
-	uint32 cversion;
-
-	fstring name;
-	fstring environment;
-	fstring driverpath;
-	fstring datafile;
-	fstring configfile;
-	fstring helpfile;
-	fstring monitorname;
-	fstring defaultdatatype;
-	fstring *dependentfiles;
-} NT_PRINTER_DRIVER_INFO_LEVEL_3;
-
-/* SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure */
-typedef struct {
-	uint32	version;
-	fstring	name;
-	fstring	environment;
-	fstring	driverpath;
-	fstring	datafile;
-	fstring	configfile;
-	fstring	helpfile;
-	fstring	monitorname;
-	fstring	defaultdatatype;
-	fstring	mfgname;
-	fstring	oemurl;
-	fstring	hardwareid;
-	fstring	provider;
-	fstring *dependentfiles;
-	fstring *previousnames;
-} NT_PRINTER_DRIVER_INFO_LEVEL_6;
-
-
-typedef struct nt_printer_driver_info_level
-{
-	NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3;
-	NT_PRINTER_DRIVER_INFO_LEVEL_6 *info_6;
-} NT_PRINTER_DRIVER_INFO_LEVEL;
-
 /* predefined registry key names for printer data */
 
 #define SPOOL_PRINTERDATA_KEY		"PrinterDriverData"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 970c8af..b708c26 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4839,11 +4839,10 @@ void update_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, in
 int get_ntdrivers(fstring **list, const char *architecture, uint32 version);
 const char *get_short_archi(const char *long_archi);
 WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
-			      NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-			      uint32 level);
+			      struct spoolss_AddDriverInfoCtr *r);
 WERROR move_driver_to_download_area(struct pipes_struct *p,
-				    NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-				    uint32 level, WERROR *perr);
+				    struct spoolss_AddDriverInfoCtr *r,
+				    WERROR *perr);
 int pack_devicemode(NT_DEVICEMODE *nt_devmode, uint8 *buf, int buflen);
 uint32 del_a_printer(const char *sharename);
 NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
@@ -4879,14 +4878,20 @@ WERROR get_a_printer_search( Printer_entry *print_hnd,
 			uint32 level,
 			const char *sharename);
 uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level);
-uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
-WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level,
-			    const char *drivername, const char *architecture, uint32_t version);
-uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
-bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 );
-bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info );
+uint32_t add_a_printer_driver(TALLOC_CTX *mem_ctx,
+			      struct spoolss_AddDriverInfoCtr *r,
+			      char **driver_name,
+			      uint32_t *version);
+WERROR get_a_printer_driver(TALLOC_CTX *mem_ctx,
+			    union spoolss_DriverInfo **driver_p, uint32_t level,
+			    const char *drivername, const char *architecture,
+			    uint32_t version);
+uint32_t free_a_printer_driver(union spoolss_DriverInfo *driver);
+bool printer_driver_in_use(const struct spoolss_DriverInfo3 *info_3);
+bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
+				 struct spoolss_DriverInfo3 *info);
 WERROR delete_printer_driver(struct pipes_struct *rpc_pipe,
-			     NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3,
+			     const struct spoolss_DriverInfo3 *info_3,
 			     uint32 version, bool delete_files );
 WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr);
 bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **secdesc_ctr);
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 9995dfe..8fa29aa 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1442,7 +1442,7 @@ Determine the correct cVersion associated with an architecture and driver
 ****************************************************************************/
 static uint32 get_correct_cversion(struct pipes_struct *p,
 				   const char *architecture,
-				   fstring driverpath_in,
+				   const char *driverpath_in,
 				   WERROR *perr)
 {
 	int               cversion;
@@ -1600,50 +1600,40 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
 
 /****************************************************************************
 ****************************************************************************/
+
+#define strip_driver_path(_mem_ctx, _element) do { \
+	if ((_p = strrchr(_element, '\\')) != NULL) { \
+		_element = talloc_asprintf(_mem_ctx, _p+1); \
+		W_ERROR_HAVE_NO_MEMORY(_element); \
+	} \
+} while (0);
+
 static WERROR clean_up_driver_struct_level_3(struct pipes_struct *rpc_pipe,
-					     NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver)
+					     struct spoolss_AddDriverInfo3 *driver)
 {
 	const char *architecture;
-	fstring new_name;
-	char *p;
 	int i;
 	WERROR err;
+	char *_p;
 
 	/* clean up the driver name.
 	 * we can get .\driver.dll
 	 * or worse c:\windows\system\driver.dll !
 	 */
 	/* using an intermediate string to not have overlaping memcpy()'s */
-	if ((p = strrchr(driver->driverpath,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->driverpath, new_name);
-	}
-
-	if ((p = strrchr(driver->datafile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->datafile, new_name);
-	}
 
-	if ((p = strrchr(driver->configfile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->configfile, new_name);
-	}
-
-	if ((p = strrchr(driver->helpfile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->helpfile, new_name);
-	}
+	strip_driver_path(driver, driver->driver_path);
+	strip_driver_path(driver, driver->data_file);
+	strip_driver_path(driver, driver->config_file);
+	strip_driver_path(driver, driver->help_file);
 
-	if (driver->dependentfiles) {
-		for (i=0; *driver->dependentfiles[i]; i++) {
-			if ((p = strrchr(driver->dependentfiles[i],'\\')) != NULL) {
-				fstrcpy(new_name, p+1);
-				fstrcpy(driver->dependentfiles[i], new_name);
-			}
+	if (driver->dependent_files && driver->dependent_files->string) {
+		for (i=0; driver->dependent_files->string[i]; i++) {
+			strip_driver_path(driver, driver->dependent_files->string[i]);
 		}
 	}
 
-	architecture = get_short_archi(driver->environment);
+	architecture = get_short_archi(driver->architecture);
 	if (!architecture) {
 		return WERR_UNKNOWN_PRINTER_DRIVER;
 	}
@@ -1659,8 +1649,9 @@ static WERROR clean_up_driver_struct_level_3(struct pipes_struct *rpc_pipe,
 	 *	NT 4: cversion=2
 	 *	NT2K: cversion=3
 	 */
-	if ((driver->cversion = get_correct_cversion(rpc_pipe, architecture,
-						     driver->driverpath,
+
+	if ((driver->version = get_correct_cversion(rpc_pipe, architecture,
+						     driver->driver_path,
 						     &err)) == -1)
 		return err;
 
@@ -1670,11 +1661,10 @@ static WERROR clean_up_driver_struct_level_3(struct pipes_struct *rpc_pipe,
 /****************************************************************************
 ****************************************************************************/
 static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
-					     NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver)
+					     struct spoolss_AddDriverInfo6 *driver)
 {
 	const char *architecture;
-	fstring new_name;
-	char *p;
+	char *_p;
 	int i;
 	WERROR err;
 
@@ -1683,36 +1673,19 @@ static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
 	 * or worse c:\windows\system\driver.dll !
 	 */
 	/* using an intermediate string to not have overlaping memcpy()'s */
-	if ((p = strrchr(driver->driverpath,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->driverpath, new_name);
-	}
 
-	if ((p = strrchr(driver->datafile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->datafile, new_name);
-	}
-
-	if ((p = strrchr(driver->configfile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->configfile, new_name);
-	}
+	strip_driver_path(driver, driver->driver_path);
+	strip_driver_path(driver, driver->data_file);
+	strip_driver_path(driver, driver->config_file);
+	strip_driver_path(driver, driver->help_file);
 
-	if ((p = strrchr(driver->helpfile,'\\')) != NULL) {
-		fstrcpy(new_name, p+1);
-		fstrcpy(driver->helpfile, new_name);
-	}
-
-	if (driver->dependentfiles) {
-		for (i=0; *driver->dependentfiles[i]; i++) {
-			if ((p = strrchr(driver->dependentfiles[i],'\\')) != NULL) {
-				fstrcpy(new_name, p+1);
-				fstrcpy(driver->dependentfiles[i], new_name);
-			}
+	if (driver->dependent_files && driver->dependent_files->string) {
+		for (i=0; driver->dependent_files->string[i]; i++) {
+			strip_driver_path(driver, driver->dependent_files->string[i]);
 		}
 	}
 
-	architecture = get_short_archi(driver->environment);
+	architecture = get_short_archi(driver->architecture);
 	if (!architecture) {
 		return WERR_UNKNOWN_PRINTER_DRIVER;
 	}
@@ -1730,7 +1703,7 @@ static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
 	 */
 
 	if ((driver->version = get_correct_cversion(rpc_pipe, architecture,
-						    driver->driverpath,
+						    driver->driver_path,
 						    &err)) == -1)
 			return err;
 
@@ -1740,26 +1713,15 @@ static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
 /****************************************************************************
 ****************************************************************************/
 WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
-			      NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-			      uint32 level)
+			      struct spoolss_AddDriverInfoCtr *r)
 {
-	switch (level) {
-		case 3:
-		{
-			NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
-			driver=driver_abstract.info_3;
-			return clean_up_driver_struct_level_3(rpc_pipe,
-							      driver);
-		}
-		case 6:
-		{
-			NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver;
-			driver=driver_abstract.info_6;
-			return clean_up_driver_struct_level_6(rpc_pipe,
-							      driver);
-		}
-		default:
-			return WERR_INVALID_PARAM;
+	switch (r->level) {
+	case 3:
+		return clean_up_driver_struct_level_3(rpc_pipe, r->info.info3);
+	case 6:
+		return clean_up_driver_struct_level_6(rpc_pipe, r->info.info6);
+	default:
+		return WERR_NOT_SUPPORTED;
 	}
 }
 
@@ -1767,39 +1729,23 @@ WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
  This function sucks and should be replaced. JRA.
 ****************************************************************************/
 
-static void convert_level_6_to_level3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *dst, NT_PRINTER_DRIVER_INFO_LEVEL_6 *src)
+static void convert_level_6_to_level3(struct spoolss_AddDriverInfo3 *dst,
+				      const struct spoolss_AddDriverInfo6 *src)
 {
-    dst->cversion  = src->version;
-
-    fstrcpy( dst->name, src->name);
-    fstrcpy( dst->environment, src->environment);
-    fstrcpy( dst->driverpath, src->driverpath);
-    fstrcpy( dst->datafile, src->datafile);
-    fstrcpy( dst->configfile, src->configfile);
-    fstrcpy( dst->helpfile, src->helpfile);
-    fstrcpy( dst->monitorname, src->monitorname);
-    fstrcpy( dst->defaultdatatype, src->defaultdatatype);
-    dst->dependentfiles = src->dependentfiles;
+	dst->version		= src->version;
+
+	dst->driver_name	= src->driver_name;
+	dst->architecture 	= src->architecture;
+	dst->driver_path	= src->driver_path;
+	dst->data_file		= src->data_file;
+	dst->config_file	= src->config_file;
+	dst->help_file		= src->help_file;
+	dst->monitor_name	= src->monitor_name;
+	dst->default_datatype	= src->default_datatype;
+	dst->_ndr_size_dependent_files = src->_ndr_size_dependent_files;
+	dst->dependent_files	= src->dependent_files;
 }
 
-#if 0 /* Debugging function */
-
-static char* ffmt(unsigned char *c){
-	int i;
-	static char ffmt_str[17];
-
-	for (i=0; i<16; i++) {
-		if ((c[i] < ' ') || (c[i] > '~'))
-			ffmt_str[i]='.';
-		else
-			ffmt_str[i]=c[i];
-	}
-    ffmt_str[16]='\0';
-	return ffmt_str;
-}
-
-#endif
-
 /****************************************************************************
 ****************************************************************************/
 
@@ -1872,11 +1818,11 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
 }
 
 WERROR move_driver_to_download_area(struct pipes_struct *p,
-				    NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-				    uint32 level, WERROR *perr)
+				    struct spoolss_AddDriverInfoCtr *r,
+				    WERROR *perr)
 {
-	NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
-	NT_PRINTER_DRIVER_INFO_LEVEL_3 converted_driver;
+	struct spoolss_AddDriverInfo3 *driver;
+	struct spoolss_AddDriverInfo3 converted_driver;
 	const char *short_architecture;
 	struct smb_filename *smb_dname = NULL;
 	char *new_dir = NULL;
@@ -1891,20 +1837,20 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 
 	*perr = WERR_OK;
 
-	switch (level) {
+	switch (r->level) {
 	case 3:
-		driver = driver_abstract.info_3;
+		driver = r->info.info3;
 		break;
 	case 6:
-		convert_level_6_to_level3(&converted_driver, driver_abstract.info_6);
+		convert_level_6_to_level3(&converted_driver, r->info.info6);
 		driver = &converted_driver;
 		break;
 	default:
-		DEBUG(0,("move_driver_to_download_area: Unknown info level (%u)\n", (unsigned int)level ));
+		DEBUG(0,("move_driver_to_download_area: Unknown info level (%u)\n", (unsigned int)r->level));
 		return WERR_UNKNOWN_LEVEL;
 	}
 
-	short_architecture = get_short_archi(driver->environment);
+	short_architecture = get_short_archi(driver->architecture);
 	if (!short_architecture) {
 		return WERR_UNKNOWN_PRINTER_DRIVER;
 	}
@@ -1930,7 +1876,7 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 	new_dir = talloc_asprintf(ctx,
 				"%s/%d",
 				short_architecture,
-				driver->cversion);
+				driver->version);
 	if (!new_dir) {
 		*perr = WERR_NOMEM;
 		goto err_exit;
@@ -1948,14 +1894,14 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 	/* For each driver file, archi\filexxx.yyy, if there is a duplicate file
 	 * listed for this driver which has already been moved, skip it (note:
 	 * drivers may list the same file name several times. Then check if the
-	 * file already exists in archi\cversion\, if so, check that the version
+	 * file already exists in archi\version\, if so, check that the version
 	 * info (or time stamps if version info is unavailable) is newer (or the
-	 * date is later). If it is, move it to archi\cversion\filexxx.yyy.
+	 * date is later). If it is, move it to archi\version\filexxx.yyy.
 	 * Otherwise, delete the file.
 	 *
-	 * If a file is not moved to archi\cversion\ because of an error, all the
+	 * If a file is not moved to archi\version\ because of an error, all the
 	 * rest of the 'unmoved' driver files are removed from archi\. If one or
-	 * more of the driver's files was already moved to archi\cversion\, it
+	 * more of the driver's files was already moved to archi\version\, it
 	 * potentially leaves the driver in a partially updated state. Version
 	 * trauma will most likely occur if an client attempts to use any printer
 	 * bound to the driver. Perhaps a rewrite to make sure the moves can be
@@ -1964,13 +1910,13 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 
 	DEBUG(5,("Moving files now !\n"));
 
-	if (driver->driverpath && strlen(driver->driverpath)) {
+	if (driver->driver_path && strlen(driver->driver_path)) {
 
 		*perr = move_driver_file_to_download_area(ctx,
 							  conn,
-							  driver->driverpath,
+							  driver->driver_path,
 							  short_architecture,
-							  driver->cversion,
+							  driver->version,
 							  ver);
 		if (!W_ERROR_IS_OK(*perr)) {
 			if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
@@ -1980,14 +1926,14 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 		}
 	}
 
-	if (driver->datafile && strlen(driver->datafile)) {
-		if (!strequal(driver->datafile, driver->driverpath)) {
+	if (driver->data_file && strlen(driver->data_file)) {
+		if (!strequal(driver->data_file, driver->driver_path)) {
 
 			*perr = move_driver_file_to_download_area(ctx,
 								  conn,
-								  driver->datafile,
+								  driver->data_file,
 								  short_architecture,
-								  driver->cversion,
+								  driver->version,
 								  ver);
 			if (!W_ERROR_IS_OK(*perr)) {
 				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
@@ -1998,15 +1944,15 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 		}
 	}
 
-	if (driver->configfile && strlen(driver->configfile)) {
-		if (!strequal(driver->configfile, driver->driverpath) &&
-		    !strequal(driver->configfile, driver->datafile)) {
+	if (driver->config_file && strlen(driver->config_file)) {
+		if (!strequal(driver->config_file, driver->driver_path) &&
+		    !strequal(driver->config_file, driver->data_file)) {
 
 			*perr = move_driver_file_to_download_area(ctx,
 								  conn,
-								  driver->configfile,
+								  driver->config_file,
 								  short_architecture,
-								  driver->cversion,
+								  driver->version,
 								  ver);
 			if (!W_ERROR_IS_OK(*perr)) {
 				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
@@ -2017,16 +1963,16 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 		}
 	}
 
-	if (driver->helpfile && strlen(driver->helpfile)) {
-		if (!strequal(driver->helpfile, driver->driverpath) &&
-		    !strequal(driver->helpfile, driver->datafile) &&
-		    !strequal(driver->helpfile, driver->configfile)) {
+	if (driver->help_file && strlen(driver->help_file)) {
+		if (!strequal(driver->help_file, driver->driver_path) &&
+		    !strequal(driver->help_file, driver->data_file) &&
+		    !strequal(driver->help_file, driver->config_file)) {
 
 			*perr = move_driver_file_to_download_area(ctx,
 								  conn,
-								  driver->helpfile,
+								  driver->help_file,
 								  short_architecture,
-								  driver->cversion,
+								  driver->version,
 								  ver);
 			if (!W_ERROR_IS_OK(*perr)) {
 				if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list