[PATCH 5/6] s3-spoolss: Support opening ports via OpenPrinterEx

David Disseldorp ddiss at suse.de
Sun Oct 30 19:12:18 MDT 2011


On Wed, 31 Aug 2011 15:03:13 -0400
Justin Chevrier <jchevrier at gmail.com> wrote:

...
>  static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
...
> +			/* Ensure there isn't a second backslash */
> +			if ( *aprinter == '\\' ) {
> +				*aprinter = '\0';
> +				aprinter++;
> +			}

Is this needed, I.e. have you seen Windows clients send
\\server\\printer UNCs?

>  		}
>  		if (!is_myname_or_ipaddr(servername)) {
>  			return WERR_INVALID_PRINTER_NAME;
> @@ -627,7 +634,36 @@ static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
>  		fstrcpy(sname, SPL_XCV_MONITOR_LOCALMON);
>  		found = true;
>  	}
> +	else if ( strstr(aprinter, SPL_XCV_PORT) ) {
> +		if ((portname = strchr_m(aprinter, ' ')) != NULL ) {
> +			portname++;
> +			/* Don't bother searching the registry for 
> +			   dummy port name: "Samba Printer Port" */
> +			if (!strequal(portname, SAMBA_PRINTER_PORT_NAME)) {
> +
> +				result = winreg_get_port_internal(mem_ctx,
> +								  session_info,
> +								  msg_ctx,
> +								  portname,
> +								  &data1);
> +				if (!W_ERROR_IS_OK(result)) {
> +					DEBUG(2,("set_printer_hnd_name: failed to lookup port [%s] -- result [%s]\n",
> +						portname, win_errstr(result)));
> +					return WERR_INVALID_PRINTER_NAME;
> +				}
>  
> +				DEBUG(4, ("Found Port: [%s]\n", portname));
> +				fstrcpy(sname, portname);
> +				Printer->printer_type = SPLHND_PORTMON_TCP;
> +
> +				TALLOC_FREE(data1);
> +				goto done;
> +			}
> +		}
> +
> +		DEBUGADD(4,("Port %s not found\n", portname));
> +		return WERR_INVALID_PRINTER_NAME;
> +	}

This doesn't appear right to me. If I understand this correctly lookup of
the printer name is skipped if the port is found. Also, in the case of
the default printer port (SAMBA_PRINTER_PORT_NAME) an error is returned
immediately.


More information about the samba-technical mailing list