[SCM] Samba Shared Repository - branch master updated
Björn Jacke
bjacke at samba.org
Mon Jan 28 18:35:03 UTC 2019
The branch, master has been updated
via 232273bfac3 s4:torture: Enforce Printer Class
via 669b135b49d s4:torture: Uninstall driver and cleanup
via 38967fd954b s4:torture: Add test_ValidatePrinterDriverInstalled
via c627b4e33b4 s4:torture: Add test_InstallPrinterDriverFromPackage
via a9f283c84ff s4:torture: Add test_UploadPrinterDriverPackage
via a9619abb95f s4:torture: Add test_CopyDriverFiles
via 01f1bd3ff1c s4:torture: Add test_init_driver_info function
via 1ac1b3e12fb s4:torture: Add driver parsing wrapper
via 7783c62bbf7 lib:printer_driver: Retrieve Class value
via 5442355cdb5 lib:printer_driver: Don't overwrite printprocessor
via 166380111ba lib:printer_driver: Parse SourceDisksNames section
via 04d92b00202 lib:printer_driver: Handle PrintProcessor string
via b6712ab902a lib:printer_driver: Add printer_driver library to parse printer driver inf files
via 7d42029ff79 utils:libgpo: re-add libgpo as library, it should not be part of gpext
via 7abf1d03394 util: Add file tree walk interface
via 5e97d3cda81 s4:torture: Use test client user and machine name defaults
via a9c50a71e6e s4:torture: Add iremotewinspool driver torture template
via 5c1514e677f librpc:idl: Fix pszDestInfPath winspool parameter type
via 8f240b12f95 s4:torture: Seperate out function calls inside params
via e2eadf9a926 s4:torture: Share test iremotewinspool functions
from ed209cfee37 s3:nmbd: small improvements in --help strings
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 232273bfac3e65e69c4b9f4527f93cdfe4724f6b
Author: Justin Stephenson <jstephen at redhat.com>
Date: Tue Nov 20 11:25:49 2018 -0500
s4:torture: Enforce Printer Class
Ensure that the provided inf defines Class=Printer for driver installation
to succeed.
Some driver packages(HP Universal Print Driver) include inf files with
other device types such as Class=USB. Attempting to install these will fail
when tested against Windows Server 2016 Print server using
iremotewinspool RPC calls.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
Autobuild-User(master): Björn Jacke <bjacke at samba.org>
Autobuild-Date(master): Mon Jan 28 19:34:41 CET 2019 on sn-devel-144
commit 669b135b49db0bb7e89dfe44073ae9dd70500f97
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Oct 15 17:02:03 2018 -0400
s4:torture: Uninstall driver and cleanup
Uninstall and remove the print driver packages to cleanup
after the install. Cleanup and remove smb directory created
inside print$.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 38967fd954bf143bc2496b03bd1fdbbefffc4421
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Oct 15 17:01:21 2018 -0400
s4:torture: Add test_ValidatePrinterDriverInstalled
Perform checks against the print driver registry information
to ensure the driver was installed as expected.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit c627b4e33b4dfde7cf79502fea4e58cbeecee7fa
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Sep 14 15:51:44 2018 -0400
s4:torture: Add test_InstallPrinterDriverFromPackage
Install a previous uploaded driver package.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit a9f283c84ff9c429620f9e7fdc28b063174e4605
Author: Justin Stephenson <jstephen at redhat.com>
Date: Tue Sep 11 15:57:14 2018 -0400
s4:torture: Add test_UploadPrinterDriverPackage
Add test to Upload Print Driver, a prerequisite RPC call before
installing the print driver. The inf driver file to use in this test
will be provided using torture option:inf_file
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit a9619abb95f5d87686cded5754e4c33f34244ac3
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Aug 27 11:32:29 2018 -0400
s4:torture: Add test_CopyDriverFiles
Add test to copy driver files from a torture option provided local driver_path
to the print$ share of //server/.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 01f1bd3ff1c8916c26e2fc833cedd7120cc76f6e
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Oct 15 13:55:37 2018 -0400
s4:torture: Add test_init_driver_info function
Validate torture options, obtain and retrieve driver information, and
call driver parsing function to retrieve driver info needed for
performing the test.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 1ac1b3e12fb5d981e94887e30669f7326ff5d6f7
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Oct 15 13:28:01 2018 -0400
s4:torture: Add driver parsing wrapper
Add wrapper function to parse inf driver file and get
validated driver information.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 7783c62bbf7d4237a3df02a02196c43d1152ed27
Author: Justin Stephenson <jstephen at redhat.com>
Date: Tue Nov 20 11:24:34 2018 -0500
lib:printer_driver: Retrieve Class value
Retrieve the Class value from the inf file [Version] section.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 5442355cdb527ddcaae509538c751b801a77a78c
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Nov 16 16:53:33 2018 -0500
lib:printer_driver: Don't overwrite printprocessor
If the printprocessor is parsed from the inf file in the codepath:
setup_driver_name
find_driver_files
process_driver_section_printprocessor
Don't overwrite the value later on in setup_driver_name with the default "winprint"
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 166380111ba3a82b087ab3a54687d0ecabe5e819
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Nov 16 16:11:02 2018 -0500
lib:printer_driver: Parse SourceDisksNames section
This allows a driver inf with a [SourceDisksNames] section
excluding the system architecture to be parsed.
https://docs.microsoft.com/en-us/windows-hardware/drivers/install/inf-sourcedisksnames-section?f=255&MSPPError=-2147217396
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 04d92b002024c5265c93ce7bd2a7064aaa187abc
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Nov 16 16:03:00 2018 -0500
lib:printer_driver: Handle PrintProcessor string
This fixes an issue parsing the section of a certain HP
driver inf file:
PrintProcessor=%PRINT_PROCESSOR%
where %PRINT_PROCESSOR% is a [Strings] substituted value,
gp_inifile_getstring_ext() performs the substitution correctly.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit b6712ab902ab160bc66a3040eba8fc5c7d921dde
Author: Guenther Deschner <gd at samba.org>
Date: Mon Oct 8 11:14:37 2018 -0400
lib:printer_driver: Add printer_driver library to parse printer driver inf files
Pair-Programmed-With: Justin Stephenson <jstephen at redhat.com>
Signed-off-by: Guenther Deschner <gd at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 7d42029ff79358684c1bfc51bde3cbd31ed840bd
Author: Günther Deschner <gd at samba.org>
Date: Fri Jun 8 16:13:22 2018 +0200
utils:libgpo: re-add libgpo as library, it should not be part of gpext
It was initially removed in 78fd02cf31dfe72d596030f342aebefba1e72263 but
is needed by the inf file parsing.
Guenther
Signed-off-by: Guenther Deschner <gd at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 7abf1d03394fb7a97b2f8ca58c95ab1916c7583f
Author: Andreas Schneider <asn at samba.org>
Date: Mon Sep 10 15:20:03 2018 +0200
util: Add file tree walk interface
Add tftw() utility to emulate nftw() behavior with a userdata pointer.
This is repurposed from the csync project custom file tree walker.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 5e97d3cda81628de8d23237d2f7d4ead55c729f6
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Sep 21 09:45:33 2018 -0400
s4:torture: Use test client user and machine name defaults
Use "testclient_machine" and "testclient_user" in open printer calls.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit a9c50a71e6ea9351c5dca902e123767b99dc31bf
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Aug 24 14:28:05 2018 -0400
s4:torture: Add iremotewinspool driver torture template
Add the template with setup and teardown functions
for the iremotewinspool_driver torture suite, and
add this to the list of torture tests
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 5c1514e677f9b6abc91be9dcf94375fbece9fdcc
Author: Justin Stephenson <jstephen at redhat.com>
Date: Mon Sep 17 11:19:02 2018 -0400
librpc:idl: Fix pszDestInfPath winspool parameter type
The in/out type of pszDestInfPath needs to be a string type for
RPC call UploadPrinterDriverPackage.
Per the Spec:
[in, out, unique, size_is(*pcchDestInfPath)] wchar_t* pszDestInfPath,
pszDestInfPath: A pointer to a buffer that receives a string that
specifies the full path of the directory to which the driver
installation control file was copied.
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit 8f240b12f95fa9a1cf91f7403347abec84997dd6
Author: Justin Stephenson <jstephen at redhat.com>
Date: Fri Aug 24 09:36:55 2018 -0400
s4:torture: Seperate out function calls inside params
Minor change to allow for easier debugging
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
commit e2eadf9a926b3d627ff8cda72a5a142655a210e6
Author: Justin Stephenson <jstephen at redhat.com>
Date: Thu Aug 23 13:16:40 2018 -0400
s4:torture: Share test iremotewinspool functions
Create iremotewinspool_common.c and iremotewinspool_common.h to make
test functions available for additional tests
Signed-off-by: Justin Stephenson <jstephen at redhat.com>
Reviewed-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Bjoern Jacke <bjacke at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/printer_driver/printer_driver.c | 1259 ++++++++++++++++++++
.../printer_driver/printer_driver.h | 18 +-
lib/printer_driver/wscript_build | 6 +
lib/util/tftw.c | 126 ++
lib/util/tftw.h | 32 +
lib/util/wscript_build | 3 +-
libgpo/wscript_build | 15 +-
librpc/idl/winspool.idl | 2 +-
source3/utils/wscript_build | 2 +-
source4/torture/rpc/iremotewinspool.c | 231 +---
source4/torture/rpc/iremotewinspool_common.c | 247 ++++
source4/torture/rpc/iremotewinspool_common.h | 101 ++
source4/torture/rpc/iremotewinspool_driver.c | 840 +++++++++++++
source4/torture/rpc/rpc.c | 1 +
source4/torture/wscript_build | 8 +
wscript_build | 1 +
16 files changed, 2661 insertions(+), 231 deletions(-)
create mode 100644 lib/printer_driver/printer_driver.c
copy librpc/ndr/ndr_cab.h => lib/printer_driver/printer_driver.h (60%)
create mode 100644 lib/printer_driver/wscript_build
create mode 100644 lib/util/tftw.c
create mode 100644 lib/util/tftw.h
create mode 100644 source4/torture/rpc/iremotewinspool_common.c
create mode 100644 source4/torture/rpc/iremotewinspool_common.h
create mode 100644 source4/torture/rpc/iremotewinspool_driver.c
Changeset truncated at 500 lines:
diff --git a/lib/printer_driver/printer_driver.c b/lib/printer_driver/printer_driver.c
new file mode 100644
index 00000000000..2176d4ae948
--- /dev/null
+++ b/lib/printer_driver/printer_driver.c
@@ -0,0 +1,1259 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Guenther Deschner 2016
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_spoolss.h"
+#include "rpc_client/init_spoolss.h"
+#include "libgpo/gpo_ini.h"
+#include "printer_driver.h"
+
+#define ADD_TO_ARRAY(mem_ctx, type, elem, array, num) \
+do { \
+ *(array) = talloc_realloc(mem_ctx, (*(array)), type, (*(num))+1); \
+ SMB_ASSERT((*(array)) != NULL); \
+ (*(array))[*(num)] = (elem); \
+ (*(num)) += 1; \
+} while (0)
+
+
+/* GetPrinterDriverDirectory -> drivers and dependent files */
+#define PRINTER_INF_DIRID_66000
+
+/* GetPrintProcessorDirectory -> print processors */
+#define PRINTER_INF_DIRID_66001
+
+/* GetColorDirectory -> color profiles */
+#define PRINTER_INF_DIRID_66003
+
+static const char *get_string_unquote(const char *s)
+{
+ bool ok;
+ size_t len;
+
+ if (s == NULL) {
+ return NULL;
+ }
+
+ len = strlen(s);
+ if (len < 2) {
+ return s;
+ }
+
+ if (s[0] == '"' && s[len-1] == '"') {
+ ok = trim_string(discard_const(s), "\"", "\"");
+ if (!ok) {
+ return NULL;
+ }
+ }
+
+ return s;
+}
+
+/*
+ * '%STRING%' indicates STRING is localized in the [Strings] section
+ */
+
+static const char *get_string_token(struct gp_inifile_context *ctx,
+ const char *s)
+{
+ NTSTATUS status;
+ bool ok;
+ char *key;
+ const char *s2;
+
+ if (s != NULL && s[0] != '%' && s[strlen(s)-1] != '%') {
+ return s;
+ }
+
+ ok = trim_string(discard_const(s), "%", "%");
+ if (!ok) {
+ return NULL;
+ }
+
+ key = talloc_asprintf(ctx, "Strings:%s", s);
+ if (key == NULL) {
+ return NULL;
+ }
+
+ status = gp_inifile_getstring(ctx, key, &s2);
+ talloc_free(key);
+ if (!NT_STATUS_IS_OK(status)) {
+ /* what can you do... */
+ return s;
+ }
+
+ return s2;
+}
+
+static NTSTATUS gp_inifile_getstring_ext(struct gp_inifile_context *ctx,
+ const char *key,
+ const char **ret)
+{
+ NTSTATUS status;
+ const char *s;
+
+ status = gp_inifile_getstring(ctx, key, &s);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ s = get_string_unquote(s);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ if (s[0] == '%' && s[strlen(s)-1] == '%') {
+ s = get_string_token(ctx, s);
+ }
+
+ s = get_string_unquote(s);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ *ret = s;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS find_manufacturer_name(struct gp_inifile_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *section_name,
+ const char **manufacturer_name)
+{
+ NTSTATUS status;
+ size_t num_keys = 0;
+ const char **keys = NULL;
+ const char **values = NULL;
+ const char *s;
+ char *p;
+
+ status = gp_inifile_enum_section(ctx, section_name, &num_keys, &keys, &values);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (num_keys < 1) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ s = talloc_strdup(mem_ctx, keys[0]);
+ if (s == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = strchr(s, ':');
+ if (p == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ *p = '\0';
+ p++;
+
+ s = get_string_unquote(p);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ s = get_string_token(ctx, s);
+
+ s = get_string_unquote(s);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ if (s != NULL) {
+ *manufacturer_name = talloc_strdup(mem_ctx, s);
+ if (*manufacturer_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ talloc_free(keys);
+ talloc_free(values);
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS find_manufacturer_url(struct gp_inifile_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *section_name,
+ const char *manufacturer_name,
+ const char **manufacturer_url)
+{
+ NTSTATUS status;
+ size_t num_keys = 0;
+ const char **keys = NULL;
+ const char **values = NULL;
+ const char *s;
+ char *p;
+
+ status = gp_inifile_enum_section(ctx, section_name, &num_keys, &keys, &values);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (num_keys < 1) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ p = strchr(keys[0], ':');
+ if (p == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ *p = '\0';
+ p++;
+
+ s = get_string_unquote(p);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ s = get_string_token(ctx, s);
+
+ s = get_string_unquote(s);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
+ if (strequal(s, manufacturer_name)) {
+ s = get_string_unquote(values[0]);
+ if (s == NULL) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ }
+
+ if (s != NULL) {
+ *manufacturer_url = talloc_strdup(mem_ctx, s);
+ if (*manufacturer_url == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ talloc_free(keys);
+ talloc_free(values);
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS add_string_to_spoolss_array(TALLOC_CTX *mem_ctx,
+ const char *s,
+ struct spoolss_StringArray **r)
+{
+ size_t count = 2;
+ struct spoolss_StringArray *a = *r;
+ bool ok;
+ int i;
+
+ if (a == NULL) {
+ a = talloc_zero(mem_ctx, struct spoolss_StringArray);
+ if (a == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ if (a->string == NULL) {
+ a->string = talloc_zero_array(a, const char *, count);
+ if (a->string == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ for (i = 0; a->string[i] != NULL; i++) { ;; }
+ count = i;
+
+ ok = add_string_to_array(mem_ctx, s, &a->string, &count);
+ if (!ok) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ a->string = talloc_realloc(mem_ctx, a->string, const char *, count + 1);
+ if (a->string == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ a->string[count] = NULL;
+
+ *r = a;
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS add_dependent_driver_file(TALLOC_CTX *mem_ctx,
+ const char *file,
+ struct spoolss_StringArray **r)
+{
+ char *p;
+
+ if (file == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (file[0] == '@') {
+ file++;
+ }
+
+ p = strchr(file, ',');
+ if (p != NULL) {
+ *p = '\0';
+ }
+
+ return add_string_to_spoolss_array(mem_ctx, file, r);
+}
+
+/*
+ * https://msdn.microsoft.com/de-de/windows/hardware/drivers/install/inf-manufacturer-section
+ *
+ * [Manufacturer]
+ * "Kyocera"=Kyocera,NTx86.5.1,NTx86.6.0,NTamd64.5.1,NTamd64.6.0
+ */
+
+static NTSTATUS enum_devices_in_toc(struct gp_inifile_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ size_t *pnum_devices,
+ const char ***pdevices,
+ const char ***pdevice_values)
+{
+ NTSTATUS status;
+ size_t num_manufacturers = 0;
+ const char **manufacturers = NULL;
+ const char **values = NULL;
+ char *p;
+ int i;
+ bool ok;
+
+ status = gp_inifile_enum_section(ctx, "Manufacturer", &num_manufacturers, &manufacturers, &values);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ for (i = 0; i < num_manufacturers; i++) {
+
+ const char *models_section_name;
+ const char *s;
+ char **decorations;
+ int j;
+
+ DEBUG(11,("processing manufacturer: %s\n", manufacturers[i]));
+
+ status = gp_inifile_getstring(ctx, manufacturers[i], &s);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ decorations = str_list_make_v3(mem_ctx, s, ",");
+ if (decorations == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ models_section_name = decorations[0];
+
+ for (j = 1; decorations[j] != NULL; j++) {
+
+ /*
+ * https://msdn.microsoft.com/de-de/windows/hardware/drivers/install/inf-models-section
+ */
+
+ const char *decorated_models_section_name;
+ size_t num_devices = 0;
+ const char **devices = NULL;
+ const char **device_values = NULL;
+ int d;
+ size_t c = 0;
+
+ decorated_models_section_name = talloc_asprintf(mem_ctx, "%s.%s",
+ models_section_name,
+ decorations[j]);
+ if (decorated_models_section_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ DEBUG(11,("processing decorated models_section_name: %s\n",
+ decorated_models_section_name));
+
+ status = gp_inifile_enum_section(ctx, decorated_models_section_name,
+ &num_devices, &devices,
+ &device_values);
+ for (d = 0; d < num_devices; d++) {
+
+ DEBUG(11,("processing device: %s\n",
+ devices[d]));
+
+ s = talloc_strdup(mem_ctx, devices[d]);
+ if (s == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = strchr(s, ':');
+ if (p == NULL) {
+ return NT_STATUS_DRIVER_INTERNAL_ERROR;
+ }
+
+ *p = '\0';
+ p++;
+
+ s = get_string_unquote(p);
+
+ ok = add_string_to_array(mem_ctx, s, pdevices, pnum_devices);
+ if (!ok) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ ok = add_string_to_array(mem_ctx, device_values[d], pdevice_values, &c);
+ if (!ok) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS find_device_in_toc(struct gp_inifile_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *device_description,
+ const char **value)
+{
+ NTSTATUS status;
+ size_t num_devices = 0;
+ const char **devices = NULL;
+ const char **device_values = NULL;
+ int d;
+
+ if (device_description == NULL) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ status = enum_devices_in_toc(ctx, mem_ctx,
+ &num_devices,
+ &devices,
+ &device_values);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ for (d = 0; d < num_devices; d++) {
+
+ if (strequal(device_description, devices[d])) {
+
+ DEBUG(10,("found device_description: %s\n",
+ device_description));
+
+ *value = talloc_strdup(mem_ctx, device_values[d]);
+ if (*value == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ DEBUGADD(10,("and returned: %s\n", *value));
+
+ return NT_STATUS_OK;
+ }
+ }
+
+ return NT_STATUS_DRIVER_INTERNAL_ERROR;
+}
+
+/*
+ * https://msdn.microsoft.com/de-de/windows/hardware/drivers/install/inf-copyfiles-directive
+ */
+
+static NTSTATUS process_driver_section_copyfiles(struct gp_inifile_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *driver_section,
+ struct spoolss_AddDriverInfo8 *r)
+{
+ NTSTATUS status;
+ size_t num_keys = 0;
+ char *p, *key;
+ const char **keys = NULL;
+ const char **values = NULL;
+ int i;
+ char *str;
+ const char *s;
+
+ key = talloc_asprintf(mem_ctx, "%s:%s", driver_section, "CopyFiles");
+ if (key == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ DEBUG(10,("Checking for CopyFiles entry in %s\n", driver_section));
+
--
Samba Shared Repository
More information about the samba-cvs
mailing list