[PATCH] Fix GetPrinterDriver2 on a newly crated printer

Jeremy Allison jra at samba.org
Wed Nov 16 23:34:47 UTC 2016


On Wed, Nov 16, 2016 at 06:01:25PM +0100, Andreas Schneider wrote:
> Hello,
> 
> the attached patches fix an issue when we have a printer without a printer 
> driver assigned yet. We should not end up trying to parse an empty driver 
> structure and fail.
> 
> The second patch improves debug output.
> 
> 
> Please review and push!

LGTM - pushed !

> 
> 
> 
> 	Andreas
> 
> -- 
> Andreas Schneider                   GPG-ID: CC014E3D
> Samba Team                             asn at samba.org
> www.samba.org

> From bfd2493c995819f2e5c1c311aedf58432cf16b41 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 16 Nov 2016 15:29:34 +0100
> Subject: [PATCH 1/2] s3:spoolss: Return error when there is no driver assigned
> 
> If you create a new printer in Samba, there is no driver assinged.
> Detect that early and return the right error code.
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> Reviewed-by: Guenther Deschner <gd at samba.org>
> ---
>  source3/rpc_server/spoolss/srv_spoolss_nt.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
> index c80d760..c820cf0 100644
> --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
> +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
> @@ -5683,6 +5683,14 @@ static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
>  		goto done;
>  	}
>  
> +	if (pinfo2->drivername == NULL || pinfo2->drivername[0] == '\0') {
> +		return WERR_UNKNOWN_PRINTER_DRIVER;
> +	}
> +
> +	DBG_INFO("Construct printer driver [%s] for [%s]\n",
> +		 pinfo2->drivername,
> +		 pinfo2->sharename);
> +
>  	result = winreg_get_driver(tmp_ctx, b,
>  				   architecture,
>  				   pinfo2->drivername, version, &driver);
> -- 
> 2.10.2
> 
> 
> From e449491cbdbe63b54723d38f7e838a90abc119f9 Mon Sep 17 00:00:00 2001
> From: Andreas Schneider <asn at samba.org>
> Date: Wed, 16 Nov 2016 15:31:16 +0100
> Subject: [PATCH 2/2] s3:spoolss: Improve debug messages in
>  construct_printer_driver
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> Reviewed-by: Guenther Deschner <gd at samba.org>
> ---
>  source3/rpc_server/spoolss/srv_spoolss_nt.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
> index c820cf0..d4e568b 100644
> --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
> +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
> @@ -5674,11 +5674,9 @@ static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
>  	result = winreg_get_printer(tmp_ctx, b,
>  				    lp_const_servicename(snum),
>  				    &pinfo2);
> -
> -	DEBUG(8,("construct_printer_driver_info_level: status: %s\n",
> -		win_errstr(result)));
> -
>  	if (!W_ERROR_IS_OK(result)) {
> +		DBG_ERR("Failed to get printer info2 for [%s]: %s\n",
> +			lp_const_servicename(snum), win_errstr(result));
>  		result = WERR_INVALID_PRINTER_NAME;
>  		goto done;
>  	}
> @@ -5695,8 +5693,8 @@ static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
>  				   architecture,
>  				   pinfo2->drivername, version, &driver);
>  
> -	DEBUG(8,("construct_printer_driver_info_level: status: %s\n",
> -		win_errstr(result)));
> +	DBG_INFO("winreg_get_driver() status: %s\n",
> +		 win_errstr(result));
>  
>  	if (!W_ERROR_IS_OK(result)) {
>  		/*
> -- 
> 2.10.2
> 




More information about the samba-technical mailing list