summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2012-01-11 19:50:36 +0100
committerKarolin Seeger <kseeger@samba.org>2012-01-23 21:31:00 +0100
commitcdd7799ebfa96c16e96ca402eee20d7cd0beae01 (patch)
treee4581290ddd7d5df7b7d6964abb4bdb1c88e01a9
parent4bb3a17a66f8e8fbf0d9ba9c47ff8d75019bd39a (diff)
downloadsamba-cdd7799ebfa96c16e96ca402eee20d7cd0beae01.tar.gz
s3-spoolss: prefix print$ path on driver file deletion
Driver file paths stored in the registry do not include the server path prefix. delete_driver_files() incorrectly assumes such a prefix. https://bugzilla.samba.org/show_bug.cgi?id=8697 (cherry picked from commit c14586647451a878fdc911ee4be699b3e6485b83)
-rw-r--r--source3/printing/nt_printing.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index d6b8bb10ea2..b0d4e81fa12 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1493,20 +1493,30 @@ bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
}
static NTSTATUS driver_unlink_internals(connection_struct *conn,
- const char *name)
+ const char *short_arch,
+ int vers,
+ const char *fname)
{
+ TALLOC_CTX *tmp_ctx = talloc_new(conn);
struct smb_filename *smb_fname = NULL;
- NTSTATUS status;
+ char *print_dlr_path;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ print_dlr_path = talloc_asprintf(tmp_ctx, "%s/%d/%s",
+ short_arch, vers, fname);
+ if (print_dlr_path == NULL) {
+ goto err_out;
+ }
- status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
- &smb_fname);
+ status = create_synthetic_smb_fname(tmp_ctx, print_dlr_path,
+ NULL, NULL, &smb_fname);
if (!NT_STATUS_IS_OK(status)) {
- return status;
+ goto err_out;
}
status = unlink_internals(conn, NULL, 0, smb_fname, false);
-
- TALLOC_FREE(smb_fname);
+err_out:
+ talloc_free(tmp_ctx);
return status;
}
@@ -1519,9 +1529,7 @@ static NTSTATUS driver_unlink_internals(connection_struct *conn,
bool delete_driver_files(const struct auth_serversupplied_info *session_info,
const struct spoolss_DriverInfo8 *r)
{
- int i = 0;
- char *s;
- const char *file;
+ const char *short_arch;
connection_struct *conn;
NTSTATUS nt_status;
char *oldcwd;
@@ -1572,55 +1580,40 @@ bool delete_driver_files(const struct auth_serversupplied_info *session_info,
goto err_out;
}
- /* now delete the files; must strip the '\print$' string from
- fron of path */
+ short_arch = get_short_archi(r->architecture);
+ if (short_arch == NULL) {
+ DEBUG(0, ("bad architecture %s\n", r->architecture));
+ ret = false;
+ goto err_out;
+ }
+
+ /* now delete the files */
if (r->driver_path && r->driver_path[0]) {
- if ((s = strchr(&r->driver_path[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting driverfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting driverfile [%s]\n", r->driver_path));
+ driver_unlink_internals(conn, short_arch, r->version, r->driver_path);
}
if (r->config_file && r->config_file[0]) {
- if ((s = strchr(&r->config_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting configfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting configfile [%s]\n", r->config_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->config_file);
}
if (r->data_file && r->data_file[0]) {
- if ((s = strchr(&r->data_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting datafile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting datafile [%s]\n", r->data_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->data_file);
}
if (r->help_file && r->help_file[0]) {
- if ((s = strchr(&r->help_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting helpfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting helpfile [%s]\n", r->help_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->help_file);
}
- /* check if we are done removing files */
-
if (r->dependent_files) {
+ int i = 0;
while (r->dependent_files[i] && r->dependent_files[i][0]) {
- char *p;
-
- /* bypass the "\print$" portion of the path */
-
- if ((p = strchr(r->dependent_files[i]+1, '\\')) != NULL) {
- file = p;
- DEBUG(10,("deleting dependent file [%s]\n", file));
- driver_unlink_internals(conn, file);
- }
-
+ DEBUG(10,("deleting dependent file [%s]\n", r->dependent_files[i]));
+ driver_unlink_internals(conn, short_arch, r->version, r->dependent_files[i]);
i++;
}
}