From b2cc66176d76cd3adff0918514903df68ea07ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Baumbach?= Date: Fri, 18 Nov 2011 18:54:56 +0100 Subject: [PATCH] s3-printing: fix migrate printer code (bug 8618) Removed path from driver files. We only the basenames. --- source3/printing/nt_printing_migrate.c | 70 +++++++++++++++++++++++++++++-- 1 files changed, 65 insertions(+), 5 deletions(-) diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c index e927a23..6037f4a 100644 --- a/source3/printing/nt_printing_migrate.c +++ b/source3/printing/nt_printing_migrate.c @@ -3,6 +3,7 @@ * RPC Pipe client / server routines * * Copyright (c) Andreas Schneider 2010. + * Copyright (C) Bjoern Baumbach 2011 * * 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 @@ -99,7 +100,13 @@ NTSTATUS printing_tdb_migrate_driver(TALLOC_CTX *mem_ctx, DATA_BLOB blob; WERROR result; const char *driver_name; + const char *driver_path; + const char *config_file; + const char *data_file; + const char *help_file; + const char **dependent_files; uint32_t driver_version; + int i; blob = data_blob_const(data, length); @@ -118,15 +125,68 @@ NTSTATUS printing_tdb_migrate_driver(TALLOC_CTX *mem_ctx, ZERO_STRUCT(d3); ZERO_STRUCT(a); - a.string = r.dependent_files; + /* remove path from dependent file names */ + if (r.dependent_files != NULL) { + /* count elements in r.dependent_files */ + for(i = 0 ; r.dependent_files[i] != NULL; i++) { } + + dependent_files = SMB_MALLOC_ARRAY(const char *, i); + if (dependent_files == NULL) { + DEBUG(2, ("Out of memory!\n")); + return NT_STATUS_NO_MEMORY; + } + + for (i = 0 ; r.dependent_files[i] != NULL; i++) { + dependent_files[i] = strrchr(r.dependent_files[i], '\\'); + if (dependent_files[i] == NULL) { + dependent_files[i] = r.dependent_files[i]; + } else { + dependent_files[i]++; + } + } + dependent_files[i] = NULL; + } + a.string = dependent_files; + + /* remove path from driver file name */ + driver_path = strrchr(r.driverpath, '\\'); + if (driver_path == NULL) { + driver_path = r.driverpath; + } else { + driver_path++; + } + + /* remove path from config file name */ + config_file = strrchr(r.configfile, '\\'); + if (config_file == NULL) { + config_file = r.configfile; + } else { + config_file++; + } + + /* remove path from data file name */ + data_file = strrchr(r.datafile, '\\'); + if (data_file == NULL) { + data_file = r.datafile; + } else { + data_file++; + } + + /* remove path from help file name */ + help_file = strrchr(r.helpfile, '\\'); + if (help_file == NULL) { + help_file = r.helpfile; + } else { + help_file++; + } d3.architecture = r.environment; - d3.config_file = r.configfile; - d3.data_file = r.datafile; + d3.config_file = config_file; + d3.data_file = data_file; d3.default_datatype = r.defaultdatatype; d3.dependent_files = &a; - d3.driver_path = r.driverpath; - d3.help_file = r.helpfile; + d3.driver_path = driver_path; + d3.help_file = help_file; d3.monitor_name = r.monitorname; d3.driver_name = r.name; d3.version = r.version; -- 1.7.3.4