diff options
author | Günther Deschner <gd@samba.org> | 2009-04-30 16:49:50 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-04-30 17:33:07 +0200 |
commit | baf78506895b8bd50433058ba0f18e1aaf8aeee5 (patch) | |
tree | 7b7c9c660f88a98eaf9f8d8a7e43da0e7c40d0d2 /source3/printing | |
parent | af5a71d5280984a7d707e39fb522ecc7e1b71436 (diff) | |
download | samba-baf78506895b8bd50433058ba0f18e1aaf8aeee5.tar.gz samba-baf78506895b8bd50433058ba0f18e1aaf8aeee5.tar.bz2 samba-baf78506895b8bd50433058ba0f18e1aaf8aeee5.zip |
s3-printing: rework move_driver_file_to_download_area() a bit for clarity.
Guenther
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/nt_printing.c | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 88e210c31b..b6e7032ab8 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1806,8 +1806,8 @@ static char* ffmt(unsigned char *c){ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx, connection_struct *conn, const char *driver_file, - const char *architecture, - const char *new_dir, + const char *short_architecture, + uint32_t driver_version, uint32_t version) { char *old_name = NULL; @@ -1815,26 +1815,30 @@ static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx, SMB_STRUCT_STAT st; NTSTATUS status; - new_name = talloc_asprintf(mem_ctx, "%s/%s", - architecture, driver_file); - W_ERROR_HAVE_NO_MEMORY(new_name); - old_name = talloc_asprintf(mem_ctx, "%s/%s", - new_dir, driver_file); + short_architecture, driver_file); W_ERROR_HAVE_NO_MEMORY(old_name); - if (version != -1 && (version = file_version_is_newer(conn, new_name, old_name)) > 0) { + new_name = talloc_asprintf(mem_ctx, "%s/%d/%s", + short_architecture, driver_version, driver_file); + W_ERROR_HAVE_NO_MEMORY(new_name); + + if (version != -1 && (version = file_version_is_newer(conn, old_name, new_name)) > 0) { - new_name = driver_unix_convert(conn, new_name, &st); - W_ERROR_HAVE_NO_MEMORY(new_name); + old_name = driver_unix_convert(conn, old_name, &st); + W_ERROR_HAVE_NO_MEMORY(old_name); - status = copy_file(mem_ctx, conn, new_name, old_name, + DEBUG(10,("move_driver_file_to_download_area: copying '%s' to '%s'\n", + old_name, new_name)); + + status = copy_file(mem_ctx, conn, old_name, new_name, OPENX_FILE_EXISTS_TRUNCATE | OPENX_FILE_CREATE_IF_NOT_EXIST, 0, false); + if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("move_driver_file_to_download_area: Unable to rename [%s] to [%s]\n", - new_name, old_name)); + DEBUG(0,("move_driver_file_to_download_area: Unable to rename [%s] to [%s]: %s\n", + old_name, new_name, nt_errstr(status))); return WERR_ACCESS_DENIED; } } @@ -1848,7 +1852,7 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, { NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver; NT_PRINTER_DRIVER_INFO_LEVEL_3 converted_driver; - const char *architecture; + const char *short_architecture; char *new_dir = NULL; connection_struct *conn = NULL; NTSTATUS nt_status; @@ -1862,18 +1866,21 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = WERR_OK; - if (level==3) - driver=driver_abstract.info_3; - else if (level==6) { + switch (level) { + case 3: + driver = driver_abstract.info_3; + break; + case 6: convert_level_6_to_level3(&converted_driver, driver_abstract.info_6); driver = &converted_driver; - } else { + break; + default: DEBUG(0,("move_driver_to_download_area: Unknown info level (%u)\n", (unsigned int)level )); return WERR_UNKNOWN_LEVEL; } - architecture = get_short_archi(driver->environment); - if (!architecture) { + short_architecture = get_short_archi(driver->environment); + if (!short_architecture) { return WERR_UNKNOWN_PRINTER_DRIVER; } @@ -1895,10 +1902,9 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, return *perr; } - DEBUG(5,("Creating first directory\n")); new_dir = talloc_asprintf(ctx, "%s/%d", - architecture, + short_architecture, driver->cversion); if (!new_dir) { *perr = WERR_NOMEM; @@ -1910,6 +1916,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, goto err_exit; } + DEBUG(5,("Creating first directory: %s\n", new_dir)); + create_directory(conn, NULL, new_dir); /* For each driver file, archi\filexxx.yyy, if there is a duplicate file @@ -1936,8 +1944,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = move_driver_file_to_download_area(ctx, conn, driver->driverpath, - architecture, - new_dir, + short_architecture, + driver->cversion, ver); if (!W_ERROR_IS_OK(*perr)) { if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) { @@ -1953,8 +1961,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = move_driver_file_to_download_area(ctx, conn, driver->datafile, - architecture, - new_dir, + short_architecture, + driver->cversion, ver); if (!W_ERROR_IS_OK(*perr)) { if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) { @@ -1972,8 +1980,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = move_driver_file_to_download_area(ctx, conn, driver->configfile, - architecture, - new_dir, + short_architecture, + driver->cversion, ver); if (!W_ERROR_IS_OK(*perr)) { if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) { @@ -1992,8 +2000,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = move_driver_file_to_download_area(ctx, conn, driver->helpfile, - architecture, - new_dir, + short_architecture, + driver->cversion, ver); if (!W_ERROR_IS_OK(*perr)) { if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) { @@ -2020,8 +2028,8 @@ WERROR move_driver_to_download_area(struct pipes_struct *p, *perr = move_driver_file_to_download_area(ctx, conn, driver->dependentfiles[i], - architecture, - new_dir, + short_architecture, + driver->cversion, ver); if (!W_ERROR_IS_OK(*perr)) { if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) { |