diff options
author | Gerald Carter <jerry@samba.org> | 2005-06-15 19:28:14 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2005-06-15 19:28:14 +0000 |
commit | 63edf489985db44c57d2b35aef59c33fb8173add (patch) | |
tree | 791958a1aad15b72e616e34af1d29c95316aeddb | |
parent | 77fd0dc08bc7e10c3bde6311598dadac786bd64f (diff) | |
download | samba-63edf489985db44c57d2b35aef59c33fb8173add.tar.gz samba-63edf489985db44c57d2b35aef59c33fb8173add.tar.xz samba-63edf489985db44c57d2b35aef59c33fb8173add.zip |
r7620: when adding a new printer driver, we should copy the files
(not move) to the W32X86/{2,3}/ directory. Printmig.exe
copies the driver files for all drivers to print$/W32X86
and the calls AddPrinterDriver() for each driver. If we
move the file, then adding a driver which shares a file with
a previous driver will fail.
I can now restore drivers in bulk to a Samba 3 server.
-rw-r--r-- | source/printing/nt_printing.c | 62 | ||||
-rw-r--r-- | source/smbd/reply.c | 2 |
2 files changed, 23 insertions, 41 deletions
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 6b037689a21..8fd28d8cfec 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -1307,10 +1307,16 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_ driver_unix_convert(driverpath,conn,NULL,&bad_path,&st); + if ( !vfs_file_exist( conn, driverpath, &st ) ) { + *perr = WERR_BADFILE; + goto error_exit; + } + fsp = open_file_shared(conn, driverpath, &st, - SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDONLY), - (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), - FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, &access_mode, &action); + SET_DENY_MODE(DENY_NONE)|SET_OPEN_MODE(DOS_OPEN_RDONLY), + (FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), + FILE_ATTRIBUTE_NORMAL, INTERNAL_OPEN_ONLY, &access_mode, &action); + if (!fsp) { DEBUG(3,("get_correct_cversion: Can't open file [%s], errno = %d\n", driverpath, errno)); @@ -1351,8 +1357,8 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_ driverpath, major, minor)); } - DEBUG(10,("get_correct_cversion: Driver file [%s] cversion = %d\n", - driverpath, cversion)); + DEBUG(10,("get_correct_cversion: Driver file [%s] cversion = %d\n", + driverpath, cversion)); close_file(fsp, True); close_cnum(conn, user->vuid); @@ -1429,9 +1435,8 @@ static WERROR clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *dri * NT 4: cversion=2 * NT2K: cversion=3 */ - if ((driver->cversion = get_correct_cversion( architecture, - driver->driverpath, user, &err)) == -1) - return err; + if ((driver->cversion = get_correct_cversion( architecture, driver->driverpath, user, &err)) == -1) + return err; return WERR_OK; } @@ -1493,8 +1498,9 @@ static WERROR clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *dri * NT 4: cversion=2 * NT2K: cversion=3 */ + if ((driver->version = get_correct_cversion(architecture, driver->driverpath, user, &err)) == -1) - return err; + return err; return WERR_OK; } @@ -1580,6 +1586,7 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract SMB_STRUCT_STAT st; int ver = 0; int i; + int err; memset(inbuf, '\0', sizeof(inbuf)); memset(outbuf, '\0', sizeof(outbuf)); @@ -1657,18 +1664,13 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) { NTSTATUS status; driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - status = rename_internals(conn, new_name, old_name, 0, True); - if (!NT_STATUS_IS_OK(status)) { + if ( !copy_file(new_name, old_name, conn, FILE_EXISTS_TRUNCATE|FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); *perr = ntstatus_to_werror(status); - unlink_internals(conn, 0, new_name); ver = -1; } - } else { - driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - unlink_internals(conn, 0, new_name); - } + } } if (driver->datafile && strlen(driver->datafile)) { @@ -1678,17 +1680,12 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) { NTSTATUS status; driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - status = rename_internals(conn, new_name, old_name, 0, True); - if (!NT_STATUS_IS_OK(status)) { + if ( !copy_file(new_name, old_name, conn, FILE_EXISTS_TRUNCATE|FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); *perr = ntstatus_to_werror(status); - unlink_internals(conn, 0, new_name); ver = -1; } - } else { - driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - unlink_internals(conn, 0, new_name); } } } @@ -1701,17 +1698,12 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) { NTSTATUS status; driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - status = rename_internals(conn, new_name, old_name, 0, True); - if (!NT_STATUS_IS_OK(status)) { + if ( !copy_file(new_name, old_name, conn, FILE_EXISTS_TRUNCATE|FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); *perr = ntstatus_to_werror(status); - unlink_internals(conn, 0, new_name); ver = -1; } - } else { - driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - unlink_internals(conn, 0, new_name); } } } @@ -1725,17 +1717,12 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) { NTSTATUS status; driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - status = rename_internals(conn, new_name, old_name, 0, True); - if (!NT_STATUS_IS_OK(status)) { + if ( !copy_file(new_name, old_name, conn, FILE_EXISTS_TRUNCATE|FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); *perr = ntstatus_to_werror(status); - unlink_internals(conn, 0, new_name); ver = -1; } - } else { - driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - unlink_internals(conn, 0, new_name); } } } @@ -1758,17 +1745,12 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) { NTSTATUS status; driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - status = rename_internals(conn, new_name, old_name, 0, True); - if (!NT_STATUS_IS_OK(status)) { + if ( !copy_file(new_name, old_name, conn, FILE_EXISTS_TRUNCATE|FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); *perr = ntstatus_to_werror(status); - unlink_internals(conn, 0, new_name); ver = -1; } - } else { - driver_unix_convert(new_name, conn, NULL, &bad_path, &st); - unlink_internals(conn, 0, new_name); } } NextDriver: ; diff --git a/source/smbd/reply.c b/source/smbd/reply.c index 95de3a3469d..d49823bea5c 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -4482,7 +4482,7 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, Copy a file as part of a reply_copy. ******************************************************************/ -static BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun, +BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun, int count,BOOL target_is_directory, int *err_ret) { int Access,action; |