From a2aa7d6d65351a887b438d57ff509aaa05a28251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Fri, 31 Aug 2018 17:36:19 +0200 Subject: [PATCH 1/3] s3-spoolss: Make spoolss client os_major,os_minor and os_build configurable. Similar to spoolss server options, make the client advertised OS version values configurable to allow overriding the defaults provided to the print server. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13597 Signed-off-by: Guenther Deschner Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider --- .../smbdotconf/printing/spoolssosversion.xml | 39 +++++++++++++++++++ source3/rpc_client/cli_spoolss.c | 29 +++++++------- source3/rpc_client/init_spoolss.c | 30 ++++++++++++++ source3/rpc_client/init_spoolss.h | 3 ++ 4 files changed, 85 insertions(+), 16 deletions(-) diff --git a/docs-xml/smbdotconf/printing/spoolssosversion.xml b/docs-xml/smbdotconf/printing/spoolssosversion.xml index 0ef4489a657..1b57b692705 100644 --- a/docs-xml/smbdotconf/printing/spoolssosversion.xml +++ b/docs-xml/smbdotconf/printing/spoolssosversion.xml @@ -39,3 +39,42 @@ 2195 7601 + + + + Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + + +6 + + + + + Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + + +1 + + + + + Windows might require a new os version number. This option allows + to modify the build number. The complete default version number is: + 6.1.7007 (Windows 7 and Windows Server 2008 R2). + + +7007 + diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 7f6ed8e3c91..36ca806f531 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -28,6 +28,7 @@ #include "rpc_client/cli_spoolss.h" #include "auth/gensec/gensec.h" #include "auth/credentials/credentials.h" +#include "rpc_client/init_spoolss.h" /********************************************************************** convencience wrapper around rpccli_spoolss_OpenPrinterEx @@ -49,14 +50,12 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli, ZERO_STRUCT(devmode_ctr); - level1.size = 28; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); - level1.build = 1381; - level1.major = 2; - level1.minor = 0; - level1.processor = 0; + werror = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(werror)) { + return werror; + } userlevel_ctr.level = 1; userlevel_ctr.user_info.level1 = &level1; @@ -229,14 +228,12 @@ WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli, ZERO_STRUCT(devmode_ctr); ZERO_STRUCT(secdesc_ctr); - level1.size = 28; - level1.build = 1381; - level1.major = 2; - level1.minor = 0; - level1.processor = 0; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); + result = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(result)) { + return result; + } userlevel_ctr.level = 1; userlevel_ctr.user_info.level1 = &level1; diff --git a/source3/rpc_client/init_spoolss.c b/source3/rpc_client/init_spoolss.c index 9a4dab6d417..1996465ee9f 100644 --- a/source3/rpc_client/init_spoolss.c +++ b/source3/rpc_client/init_spoolss.c @@ -446,3 +446,33 @@ const char *spoolss_get_short_filesys_environment(const char *environment) return NULL; } } + +#define GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT 2 +#define GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT 0 +#define GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT 1381 + +WERROR spoolss_init_spoolss_UserLevel1(TALLOC_CTX *mem_ctx, + const char *username, + struct spoolss_UserLevel1 *r) +{ + ZERO_STRUCTP(r); + + r->size = 28; + r->client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); + W_ERROR_HAVE_NO_MEMORY(r->client); + r->user = talloc_strdup(mem_ctx, username); + W_ERROR_HAVE_NO_MEMORY(r->user); + r->processor = 0; + + r->major = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_major", + GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT); + r->minor = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_minor", + GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT); + r->build = lp_parm_int(GLOBAL_SECTION_SNUM, + "spoolss_client", "os_build", + GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT); + + return WERR_OK; +} diff --git a/source3/rpc_client/init_spoolss.h b/source3/rpc_client/init_spoolss.h index 376eaefe914..062e37b97e4 100644 --- a/source3/rpc_client/init_spoolss.h +++ b/source3/rpc_client/init_spoolss.h @@ -48,5 +48,8 @@ WERROR spoolss_create_default_devmode(TALLOC_CTX *mem_ctx, WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx, struct spoolss_security_descriptor **secdesc); const char *spoolss_get_short_filesys_environment(const char *environment); +WERROR spoolss_init_spoolss_UserLevel1(TALLOC_CTX *mem_ctx, + const char *username, + struct spoolss_UserLevel1 *r); #endif /* _RPC_CLIENT_INIT_SPOOLSS_H_ */ -- 2.17.1 From 1da770848753c172d0c790911b97dbe9c3ccee06 Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Fri, 31 Aug 2018 13:28:58 -0400 Subject: [PATCH 2/3] s3-rpc_client: Advertise Windows 7 client info Client printing operations currently fail against Windows Server 2016 with Access Denied if a client os build number lower than 6000 is advertised. Increase the default build number, major, and minor versions to values associated with client OS versoins Windows 7 and Windows Server 2008 R2. The build number value specifically needs to be increased to allow these operations to succeed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13597 Signed-off-by: Justin Stephenson Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider --- source3/rpc_client/init_spoolss.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source3/rpc_client/init_spoolss.c b/source3/rpc_client/init_spoolss.c index 1996465ee9f..c341b82b6ee 100644 --- a/source3/rpc_client/init_spoolss.c +++ b/source3/rpc_client/init_spoolss.c @@ -447,9 +447,10 @@ const char *spoolss_get_short_filesys_environment(const char *environment) } } -#define GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT 2 -#define GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT 0 -#define GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT 1381 +/* Windows 7 and Windows Server 2008 R2 */ +#define GLOBAL_SPOOLSS_CLIENT_OS_MAJOR_DEFAULT 6 +#define GLOBAL_SPOOLSS_CLIENT_OS_MINOR_DEFAULT 1 +#define GLOBAL_SPOOLSS_CLIENT_OS_BUILD_DEFAULT 7007 WERROR spoolss_init_spoolss_UserLevel1(TALLOC_CTX *mem_ctx, const char *username, -- 2.17.1 From b8279f6525b806d8f91aa8ce016bd528fff917f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Fri, 31 Aug 2018 18:22:04 +0200 Subject: [PATCH 3/3] s3-rpcclient: Use spoolss_init_spoolss_UserLevel1 in winspool cmds Use spoolss initialization function to set client version information for iremotewinspool printer operations Signed-off-by: Guenther Deschner Reviewed-by: Jeremy Allison Reviewed-by: Andreas Schneider --- source3/rpcclient/cmd_iremotewinspool.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source3/rpcclient/cmd_iremotewinspool.c b/source3/rpcclient/cmd_iremotewinspool.c index c6148ec02c7..7f0cecfaf01 100644 --- a/source3/rpcclient/cmd_iremotewinspool.c +++ b/source3/rpcclient/cmd_iremotewinspool.c @@ -24,6 +24,7 @@ #include "libsmb/libsmb.h" #include "auth/gensec/gensec.h" #include "auth/credentials/credentials.h" +#include "rpc_client/init_spoolss.h" /**************************************************************************** ****************************************************************************/ @@ -33,6 +34,7 @@ static WERROR cmd_iremotewinspool_async_open_printer(struct rpc_pipe_client *cli int argc, const char **argv) { NTSTATUS status; + WERROR werror; struct policy_handle hnd; struct spoolss_DevmodeContainer devmode_ctr; struct spoolss_UserLevelCtr client_info_ctr; @@ -59,13 +61,13 @@ static WERROR cmd_iremotewinspool_async_open_printer(struct rpc_pipe_client *cli ZERO_STRUCT(devmode_ctr); - level1.size = 40; - level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name()); - W_ERROR_HAVE_NO_MEMORY(level1.client); - level1.user = cli_credentials_get_username(creds); - level1.build = 1381; - level1.major = 3; - level1.minor = 0; + werror = spoolss_init_spoolss_UserLevel1(mem_ctx, + cli_credentials_get_username(creds), + &level1); + if (!W_ERROR_IS_OK(werror)) { + return werror; + } + level1.processor = PROCESSOR_ARCHITECTURE_AMD64; client_info_ctr.level = 1; -- 2.17.1