[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Wed Jan 23 02:55:03 MST 2013


The branch, v4-0-test has been updated
       via  517cf18 BUG 9474: Downgrade v4 printer driver requests to v3.
       via  681f463 spoolss: add SPOOLSS_DRIVER_VERSION_2012 (4) define to IDL.
       via  6221480 BUG 9378: Add extra attributes for AD printer publishing.
       via  68bb358 printing: Remove invalid free from error path.
       via  61c00ee BUG 9574: Fix a possible null pointer dereference in spoolss.
       via  afbdb30 s3-rpc_server: Fix a possible null pointer dereference.
      from  0c29da8 samr: Fix bug 9541, make use of posix_openpt

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 517cf18601799d420b15b697d7b9e4564d819bc4
Author: Günther Deschner <gd at samba.org>
Date:   Fri Jan 18 00:22:31 2013 +0100

    BUG 9474: Downgrade v4 printer driver requests to v3.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Jan 21 16:11:02 CET 2013 on sn-devel-104
    (cherry picked from commit 58fadf2f48a2a409b4ee98fdc0166c7f801a7629)
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Wed Jan 23 10:54:31 CET 2013 on sn-devel-104

commit 681f463668f5b449bf7f96353a995cc279e93d93
Author: Günther Deschner <gd at samba.org>
Date:   Mon Jan 7 15:14:30 2013 +0100

    spoolss: add SPOOLSS_DRIVER_VERSION_2012 (4) define to IDL.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 638ed90620e3c6a35ef56a11c612c13d6b7d6ff5)

commit 6221480c23e7e85c3aa54c450882636588e46e45
Author: David Disseldorp <ddiss at samba.org>
Date:   Thu Jan 17 13:21:25 2013 +0100

    BUG 9378: Add extra attributes for AD printer publishing.
    
    Currently attempting to publish a printer in AD fails with "Object class
    violation", due to a number of missing attributes in the LDAP request.
    
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Jan 18 17:27:35 CET 2013 on sn-devel-104

commit 68bb3587e39d141568c4828d5faf3aa697f57a1d
Author: David Disseldorp <ddiss at samba.org>
Date:   Fri Jan 18 11:48:20 2013 +0100

    printing: Remove invalid free from error path.
    
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 61c00ee7158332b0090619633251526bd6f5b34b
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jan 18 18:04:17 2013 +0100

    BUG 9574: Fix a possible null pointer dereference in spoolss.
    
    If the the client enumerates the printers and didn't specify a
    servername we have a null pointer dereference, so the process serving
    the connection crashes.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Mon Jan 21 13:30:11 CET 2013 on sn-devel-104
    (cherry picked from commit c38fb0b106b62e42a5b75b1c78386bb8912c7d7e)

commit afbdb30e0ca9f473672e43d1db115fb42cb80c82
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Dec 17 15:31:21 2012 +0100

    s3-rpc_server: Fix a possible null pointer dereference.
    
    This variable can be set to NULL in an earlier function call.
    
    Found by Coverity.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 72e02c73b64f1ff56b2d53ec63d68486a4f1ff90)

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

Summary of changes:
 librpc/idl/spoolss.idl                      |    3 +-
 source3/printing/nt_printing_ads.c          |   87 ++++++++++++++++++++++++++-
 source3/rpc_server/spoolss/srv_spoolss_nt.c |   15 ++++-
 3 files changed, 99 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index d888a79..4f706e2 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -1303,7 +1303,8 @@ cpp_quote("#define spoolss_security_descriptor security_descriptor")
 		SPOOLSS_DRIVER_VERSION_9X	= 0,
 		SPOOLSS_DRIVER_VERSION_NT35	= 1,
 		SPOOLSS_DRIVER_VERSION_NT4	= 2,
-		SPOOLSS_DRIVER_VERSION_200X	= 3
+		SPOOLSS_DRIVER_VERSION_200X	= 3,
+		SPOOLSS_DRIVER_VERSION_2012	= 4
 	} spoolss_DriverOSVersion;
 
 	typedef struct {
diff --git a/source3/printing/nt_printing_ads.c b/source3/printing/nt_printing_ads.c
index 87cab63..b99a972 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -87,6 +87,86 @@ done:
 	talloc_free(tmp_ctx);
 }
 
+static WERROR nt_printer_info_to_mods(TALLOC_CTX *ctx,
+				      struct spoolss_PrinterInfo2 *info2,
+				      ADS_MODLIST *mods)
+{
+	char *info_str;
+
+	ads_mod_str(ctx, mods, SPOOL_REG_PRINTERNAME, info2->sharename);
+	ads_mod_str(ctx, mods, SPOOL_REG_SHORTSERVERNAME, lp_netbios_name());
+	ads_mod_str(ctx, mods, SPOOL_REG_SERVERNAME, get_mydnsfullname());
+
+	info_str = talloc_asprintf(ctx, "\\\\%s\\%s",
+				   get_mydnsfullname(), info2->sharename);
+	if (info_str == NULL) {
+		return WERR_NOMEM;
+	}
+	ads_mod_str(ctx, mods, SPOOL_REG_UNCNAME, info_str);
+
+	info_str = talloc_asprintf(ctx, "%d", 4);
+	if (info_str == NULL) {
+		return WERR_NOMEM;
+	}
+	ads_mod_str(ctx, mods, SPOOL_REG_VERSIONNUMBER, info_str);
+
+	/* empty strings in the mods list result in an attrubute error */
+	if (strlen(info2->drivername) != 0)
+		ads_mod_str(ctx, mods, SPOOL_REG_DRIVERNAME, info2->drivername);
+	if (strlen(info2->location) != 0)
+		ads_mod_str(ctx, mods, SPOOL_REG_LOCATION, info2->location);
+	if (strlen(info2->comment) != 0)
+		ads_mod_str(ctx, mods, SPOOL_REG_DESCRIPTION, info2->comment);
+	if (strlen(info2->portname) != 0)
+		ads_mod_str(ctx, mods, SPOOL_REG_PORTNAME, info2->portname);
+	if (strlen(info2->sepfile) != 0)
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTSEPARATORFILE, info2->sepfile);
+
+	info_str = talloc_asprintf(ctx, "%u", info2->starttime);
+	if (info_str == NULL) {
+		return WERR_NOMEM;
+	}
+	ads_mod_str(ctx, mods, SPOOL_REG_PRINTSTARTTIME, info_str);
+
+	info_str = talloc_asprintf(ctx, "%u", info2->untiltime);
+	if (info_str == NULL) {
+		return WERR_NOMEM;
+	}
+	ads_mod_str(ctx, mods, SPOOL_REG_PRINTENDTIME, info_str);
+
+	info_str = talloc_asprintf(ctx, "%u", info2->priority);
+	if (info_str == NULL) {
+		return WERR_NOMEM;
+	}
+	ads_mod_str(ctx, mods, SPOOL_REG_PRIORITY, info_str);
+
+	if (info2->attributes & PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS) {
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTKEEPPRINTEDJOBS, "TRUE");
+	} else {
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTKEEPPRINTEDJOBS, "FALSE");
+	}
+
+	switch (info2->attributes & 0x3) {
+	case 0:
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+			    SPOOL_REGVAL_PRINTWHILESPOOLING);
+		break;
+	case 1:
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+			    SPOOL_REGVAL_PRINTAFTERSPOOLED);
+		break;
+	case 2:
+		ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+			    SPOOL_REGVAL_PRINTDIRECT);
+		break;
+	default:
+		DEBUG(3, ("unsupported printer attributes %x\n",
+			  info2->attributes));
+	}
+
+	return WERR_OK;
+}
+
 static WERROR nt_printer_publish_ads(struct messaging_context *msg_ctx,
 				     ADS_STRUCT *ads,
 				     struct spoolss_PrinterInfo2 *pinfo2)
@@ -167,12 +247,15 @@ static WERROR nt_printer_publish_ads(struct messaging_context *msg_ctx,
 	mods = ads_init_mods(ctx);
 
 	if (mods == NULL) {
-		SAFE_FREE(prt_dn);
 		TALLOC_FREE(ctx);
 		return WERR_NOMEM;
 	}
 
-	ads_mod_str(ctx, &mods, SPOOL_REG_PRINTERNAME, printer);
+	win_rc = nt_printer_info_to_mods(ctx, pinfo2, &mods);
+	if (!W_ERROR_IS_OK(win_rc)) {
+		TALLOC_FREE(ctx);
+		return win_rc;
+	}
 
 	/* publish it */
 	ads_rc = ads_mod_printer_entry(ads, prt_dn, ctx, &mods);
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index b8ee9f4..1b3a16f 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -4428,7 +4428,8 @@ static WERROR enum_all_printers_info_1_name(TALLOC_CTX *mem_ctx,
 
 	DEBUG(4,("enum_all_printers_info_1_name\n"));
 
-	if ((servername[0] == '\\') && (servername[1] == '\\')) {
+	if (servername != NULL &&
+	    (servername[0] == '\\') && (servername[1] == '\\')) {
 		s = servername + 2;
 	}
 
@@ -4463,7 +4464,8 @@ static WERROR enum_all_printers_info_1_network(TALLOC_CTX *mem_ctx,
 	   listed. Windows responds to this call with a
 	   WERR_CAN_NOT_COMPLETE so we should do the same. */
 
-	if (servername[0] == '\\' && servername[1] == '\\') {
+	if (servername != NULL &&
+	    (servername[0] == '\\') && (servername[1] == '\\')) {
 		 s = servername + 2;
 	}
 
@@ -5602,6 +5604,7 @@ WERROR _spoolss_GetPrinterDriver2(struct pipes_struct *p,
 {
 	struct printer_handle *printer;
 	WERROR result;
+	uint32_t version = r->in.client_major_version;
 
 	int snum;
 
@@ -5626,13 +5629,19 @@ WERROR _spoolss_GetPrinterDriver2(struct pipes_struct *p,
 		return WERR_BADFID;
 	}
 
+	if (r->in.client_major_version == SPOOLSS_DRIVER_VERSION_2012) {
+		DEBUG(3,("_spoolss_GetPrinterDriver2: v4 driver requested, "
+			"downgrading to v3\n"));
+		version = SPOOLSS_DRIVER_VERSION_200X;
+	}
+
 	result = construct_printer_driver_info_level(p->mem_ctx,
 						     get_session_info_system(),
 						     p->msg_ctx,
 						     r->in.level, r->out.info,
 						     snum, printer->servername,
 						     r->in.architecture,
-						     r->in.client_major_version);
+						     version);
 	if (!W_ERROR_IS_OK(result)) {
 		TALLOC_FREE(r->out.info);
 		return result;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list