diff options
author | Günther Deschner <gd@samba.org> | 2009-04-30 01:07:31 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-04-30 11:22:23 +0200 |
commit | a2a155bee59c7e849a492933d1ea5769e409bac5 (patch) | |
tree | d98d7e9fb04fe308b2e6fb11161006e79851f0c6 | |
parent | 370e7209dbafce147a5e9f283d9dcc53c72bce99 (diff) | |
download | samba-a2a155bee59c7e849a492933d1ea5769e409bac5.tar.gz samba-a2a155bee59c7e849a492933d1ea5769e409bac5.tar.bz2 samba-a2a155bee59c7e849a492933d1ea5769e409bac5.zip |
s3-printing: add move_driver_file_to_download_area().
Guenther
-rw-r--r-- | source3/printing/nt_printing.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index cfef4fe623..9508e472be 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -1802,6 +1802,46 @@ 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, + uint32_t version) +{ + char *old_name = NULL; + char *new_name = NULL; + 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); + W_ERROR_HAVE_NO_MEMORY(old_name); + + if (version != -1 && (version = file_version_is_newer(conn, new_name, old_name)) > 0) { + + new_name = driver_unix_convert(conn, new_name, &st); + W_ERROR_HAVE_NO_MEMORY(new_name); + + status = copy_file(mem_ctx, conn, new_name, old_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)); + return WERR_ACCESS_DENIED; + } + } + + return WERR_OK; +} + WERROR move_driver_to_download_area(struct pipes_struct *p, NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, WERROR *perr) |