s3-spoolss: Make spoolss client os_major,os_minor and os_build configurable.
authorGünther Deschner <gd@samba.org>
Fri, 31 Aug 2018 15:36:19 +0000 (17:36 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 7 Sep 2018 23:43:27 +0000 (01:43 +0200)
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 <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
docs-xml/smbdotconf/printing/spoolssosversion.xml
source3/rpc_client/cli_spoolss.c
source3/rpc_client/init_spoolss.c
source3/rpc_client/init_spoolss.h

index 0ef4489a6571b8508ea4df1fdf619f64da1325e3..1b57b692705aa5eeedd351f67b4a71fd89e2af95 100644 (file)
 <value type="default">2195</value>
 <value type="example">7601</value>
 </samba:parameter>
+
+<samba:parameter name="spoolss_client: os_major"
+                 context="G"
+                 type="integer"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+       <para>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).
+       </para>
+</description>
+<value type="default">6</value>
+</samba:parameter>
+
+<samba:parameter name="spoolss_client: os_minor"
+                context="G"
+                type="integer"
+                xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+       <para>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).
+       </para>
+</description>
+<value type="default">1</value>
+</samba:parameter>
+
+<samba:parameter name="spoolss_client: os_build"
+                context="G"
+                type="integer"
+                xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+<description>
+       <para>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).
+       </para>
+</description>
+<value type="default">7007</value>
+</samba:parameter>
index 7f6ed8e3c91f347bdd0733ca97bc1f7717e2fd7b..36ca806f531bcca6492922195906e0ad9154cb4f 100644 (file)
@@ -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;
index 9a4dab6d417176cde4626946b5f203036ad76cec..1996465ee9f4accdf17f9d8cc1afadea3a9619b1 100644 (file)
@@ -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;
+}
index 376eaefe9144d9e81ba6d34000a7acd14962d57f..062e37b97e4fdcabb47c0cd0806548afaf13759e 100644 (file)
@@ -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_ */