svn commit: samba r7620 - in branches/SAMBA_3_0/source: printing
smbd
jerry at samba.org
jerry at samba.org
Wed Jun 15 19:28:15 GMT 2005
Author: jerry
Date: 2005-06-15 19:28:14 +0000 (Wed, 15 Jun 2005)
New Revision: 7620
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7620
Log:
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.
Modified:
branches/SAMBA_3_0/source/printing/nt_printing.c
branches/SAMBA_3_0/source/smbd/reply.c
Changeset:
Modified: branches/SAMBA_3_0/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0/source/printing/nt_printing.c 2005-06-15 18:50:05 UTC (rev 7619)
+++ branches/SAMBA_3_0/source/printing/nt_printing.c 2005-06-15 19:28:14 UTC (rev 7620)
@@ -1307,10 +1307,16 @@
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 @@
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 @@
* 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 @@
* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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: ;
Modified: branches/SAMBA_3_0/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/reply.c 2005-06-15 18:50:05 UTC (rev 7619)
+++ branches/SAMBA_3_0/source/smbd/reply.c 2005-06-15 19:28:14 UTC (rev 7620)
@@ -4482,7 +4482,7 @@
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;
More information about the samba-cvs
mailing list