Vista: Adding a printer connection fails

brucefal brucefal at yahoo.com
Sat Jul 7 14:49:34 GMT 2007


Jerry-

I am trying to run your patch because I have the same problem with an Epson
Stylus Photo 820 printer, but it doesn't run.  The saved extensions are
tar.tar. from the site
http://www.samba.org/~jerry/patches/vista_quilt_patchset.tar.gz

Your work is far beyond my comprehension, but is the patch available in an
.exe program?

Bruce


Gerald (Jerry) Carter wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Gerald (Jerry) Carter wrote:
> 
>> In any case, I don't see an objectGUID stored in DsSpooler
>> on any client (2K, XP, or Vista).  We store it after
>> first publishing the printer so we can later refresh
>> the printer info (in the PRINTER_INFO_7).  I'm tempted to
>> convert it to a REG_SZ like you suggest.
>> 
>> What I might try doing is just converting the REG_BINARY
>> to a REG_SZ for just this one instance in unpack_values().
> 
> OK.  Fixed.  I can connect and print from Windows 2000, XP,
> & Vista.  I've attached the complete Spoolss/Vista patch.
> I've also updated the patchset at
> 
>   http://www.samba.org/~jerry/patches/vista_quilt_patchset.tar.gz
> 
> And I'm done after a 14 hour bug smashing day with 5 minutes
> to spare.  Just enough to run svn commit :-)
> 
> 
> 
> 
> 
> cheers, jerry
> =====================================================================
> Samba                                    ------- http://www.samba.org
> Centeris                         -----------  http://www.centeris.com
> "What man is a man who does not make the world better?"      --Balian
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFFy9ReIR7qMdg1EfYRAp1qAJ9wPnCXIgGwNMEdK+ITBqfVQBzOnwCgz0OU
> BMbsEW8LeKri91wEsIt3hL0=
> =ONIa
> -----END PGP SIGNATURE-----
> 
> Index: samba-3.0.24/source/rpc_server/srv_spoolss_nt.c
> ===================================================================
> --- samba-3.0.24.orig/source/rpc_server/srv_spoolss_nt.c	2007-02-08
> 19:50:19.000000000 -0600
> +++ samba-3.0.24/source/rpc_server/srv_spoolss_nt.c	2007-02-08
> 19:51:29.000000000 -0600
> @@ -5848,6 +5848,12 @@
>  		goto done;
>  	}
>  	
> +	if (!secdesc_ctr) {
> +		DEBUG(10,("update_printer_sec: secdesc_ctr is NULL !\n"));
> +		result = WERR_INVALID_PARAM;
> +		goto done;
> +	}
> +
>  	/* Check the user has permissions to change the security
>  	   descriptor.  By experimentation with two NT machines, the user
>  	   requires Full Access to the printer to change security
> @@ -9378,6 +9384,15 @@
>  	
>  	/* housekeeping information in the reply */
>  	
> +	/* Fix from Martin Zielinski <mz at seh.de> - ensure
> +	 * the hand marshalled container size is a multiple
> +	 * of 4 bytes for RPC alignment.
> +	 */
> +
> +	if (needed % 4) {
> +		needed += 4-(needed % 4);
> +	}
> +
>  	r_u->needed 	= needed;
>  	r_u->returned 	= num_entries;
>  
> Index: samba-3.0.24/source/printing/nt_printing.c
> ===================================================================
> --- samba-3.0.24.orig/source/printing/nt_printing.c	2007-02-08
> 19:50:19.000000000 -0600
> +++ samba-3.0.24/source/printing/nt_printing.c	2007-02-08
> 19:51:29.000000000 -0600
> @@ -2984,11 +2984,15 @@
>  	return True;
>  }
>  
> +/*****************************************************************
> + ****************************************************************/
> +
>  static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, 
>  			       struct uuid guid)
>  {
>  	int i;
>  	REGVAL_CTR *ctr=NULL;
> +	UNISTR2 unistr_guid;
>  
>  	/* find the DsSpooler key */
>  	if ((i = lookup_printerkey(info2->data, SPOOL_DSSPOOLER_KEY)) < 0)
> @@ -2996,8 +3000,18 @@
>  	ctr = info2->data->keys[i].values;
>  
>  	regval_ctr_delvalue(ctr, "objectGUID");
> -	regval_ctr_addvalue(ctr, "objectGUID", REG_BINARY, 
> -			    (char *) &guid, sizeof(struct uuid));	
> +
> +	/* We used to store this as a REG_BINARY but that causes
> +	   Vista to whine */
> +
> +	ZERO_STRUCT( unistr_guid );	
> +	init_unistr2( &unistr_guid, smb_uuid_string_static(guid),
> +		      UNI_STR_TERMINATE );
> +
> +	regval_ctr_addvalue(ctr, "objectGUID", REG_SZ, 
> +			    (char *)unistr_guid.buffer, 
> +			    unistr_guid.uni_max_len*2);
> +	
>  }
>  
>  static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
> @@ -3254,6 +3268,7 @@
>  	REGISTRY_VALUE *guid_val;
>  	WERROR win_rc;
>  	int i;
> +	BOOL ret = False;
>  
>  	win_rc = get_a_printer(print_hnd, &printer, 2, lp_servicename(snum));
>  
> @@ -3267,12 +3282,36 @@
>  		return False;
>  	}
>  
> -	/* fetching printer guids really ought to be a separate function.. */
> -	if (guid && regval_size(guid_val) == sizeof(struct uuid))
> -		memcpy(guid, regval_data_p(guid_val), sizeof(struct uuid));
> +	/* fetching printer guids really ought to be a separate function. */
> +
> +	if ( guid ) {	
> +		fstring guid_str;
> +		
> +		/* We used to store the guid as REG_BINARY, then swapped 
> +		   to REG_SZ for Vista compatibility so check for both */
> +
> +		switch ( regval_type(guid_val) ){
> +		case REG_SZ:		
> +			rpcstr_pull( guid_str, regval_data_p(guid_val), 
> +				     sizeof(guid_str)-1, -1, STR_TERMINATE );
> +			ret = smb_string_to_uuid( guid_str, guid );
> +			break;			
> +		case REG_BINARY:
> +			if ( regval_size(guid_val) != sizeof(struct uuid) ) {
> +				ret = False;
> +				break;
> +			}
> +			memcpy(guid, regval_data_p(guid_val), sizeof(struct uuid));
> +			break;
> +		default:
> +			DEBUG(0,("is_printer_published: GUID value stored as "
> +				 "invaluid type (%d)\n", regval_type(guid_val) ));			
> +			break;
> +		}
> +	}
>  
>  	free_a_printer(&printer, 2);
> -	return True;
> +	return ret;
>  }
>  #else
>  WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
> @@ -3539,13 +3578,43 @@
>  			break;
>  		}
>  		
> -		/* add the new value */
> +		DEBUG(8,("specific: [%s:%s], len: %d\n", keyname, valuename, size));
> +
> +		/* Vista doesn't like unknown REG_BINARY values in DsSpooler.  
> +		   Thanks to Martin Zielinski for the hint. */
> +
> +		if ( type == REG_BINARY && 
> +		     strequal( keyname, SPOOL_DSSPOOLER_KEY ) && 
> +		     strequal( valuename, "objectGUID" ) ) 
> +		{
> +			struct uuid guid;
> +			UNISTR2 unistr_guid;
> +
> +			ZERO_STRUCT( unistr_guid );
> +			
> +			/* convert the GUID to a UNICODE string */
> +			
> +			memcpy( &guid, data_p, sizeof(struct uuid) );
> +			
> +			init_unistr2( &unistr_guid, smb_uuid_string_static(guid), 
> +				      UNI_STR_TERMINATE );
> +			
> +			regval_ctr_addvalue( printer_data->keys[key_index].values, 
> +					     valuename, REG_SZ, 
> +					     (const char *)unistr_guid.buffer, 
> +					     unistr_guid.uni_str_len*2 );
> +
> +		} else {
> +			/* add the value */
> +
> +			regval_ctr_addvalue( printer_data->keys[key_index].values, 
> +					     valuename, type, (const char *)data_p, 
> +					     size );
> +		}
>  		
> -		regval_ctr_addvalue( printer_data->keys[key_index].values, valuename,
> type, (const char *)data_p, size );
>  
>  		SAFE_FREE(data_p); /* 'B' option to tdbpack does a malloc() */
>  
> -		DEBUG(8,("specific: [%s:%s], len: %d\n", keyname, valuename, size));
>  	}
>  
>  	return len;
> 
> 

-- 
View this message in context: http://www.nabble.com/Vista%3A-Adding-a-printer-connection-fails-tf3179380.html#a11479174
Sent from the Samba - samba-technical mailing list archive at Nabble.com.



More information about the samba-technical mailing list