summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-05-03 16:38:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:24 -0500
commit683d27ff1ec26bc840f322c4c9d4d9d6f7125660 (patch)
treeff669f61a71b886e316356f11806a2a91296bf63
parentb9ca5901eee6e9b698b8ad410fd5c66275721b6e (diff)
downloadsamba-683d27ff1ec26bc840f322c4c9d4d9d6f7125660.tar.gz
samba-683d27ff1ec26bc840f322c4c9d4d9d6f7125660.tar.bz2
samba-683d27ff1ec26bc840f322c4c9d4d9d6f7125660.zip
r460: Fix for broken driver upload/delete path processing.
Jeremy. (This used to be commit 78be46d13bc88a300ab627c59862559d5491ee46)
-rw-r--r--source3/printing/nt_printing.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 675794c4c2..e187f325f4 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -368,6 +368,19 @@ BOOL nt_printing_init(void)
}
/*******************************************************************
+ Function to allow filename parsing "the old way".
+********************************************************************/
+
+static BOOL driver_unix_convert(char *name,connection_struct *conn,
+ char *saved_last_component, BOOL *bad_path, SMB_STRUCT_STAT *pst)
+{
+ unix_format(name);
+ unix_clean_name(name);
+ trim_string(name,"/","/");
+ return unix_convert(name, conn, saved_last_component, bad_path, pst);
+}
+
+/*******************************************************************
tdb traversal function for counting printers.
********************************************************************/
@@ -987,7 +1000,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
/* Get file version info (if available) for previous file (if it exists) */
pstrcpy(filepath, old_file);
- unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
+ driver_unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
fsp = open_file_shared(conn, filepath, &stat_buf,
SET_OPEN_MODE(DOS_OPEN_RDONLY),
@@ -1016,7 +1029,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
/* Get file version info (if available) for new file */
pstrcpy(filepath, new_file);
- unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
+ driver_unix_convert(filepath,conn,NULL,&bad_path,&stat_buf);
fsp = open_file_shared(conn, filepath, &stat_buf,
SET_OPEN_MODE(DOS_OPEN_RDONLY),
@@ -1132,7 +1145,7 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_
* deriver the cversion. */
slprintf(driverpath, sizeof(driverpath)-1, "%s/%s", architecture, driverpath_in);
- unix_convert(driverpath,conn,NULL,&bad_path,&st);
+ driver_unix_convert(driverpath,conn,NULL,&bad_path,&st);
fsp = open_file_shared(conn, driverpath, &st,
SET_OPEN_MODE(DOS_OPEN_RDONLY),
@@ -1403,6 +1416,8 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
pstring inbuf;
pstring outbuf;
fstring res_type;
+ BOOL bad_path;
+ SMB_STRUCT_STAT st;
int ver = 0;
int i;
@@ -1454,6 +1469,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
*/
DEBUG(5,("Creating first directory\n"));
slprintf(new_dir, sizeof(new_dir)-1, "%s/%d", architecture, driver->cversion);
+ driver_unix_convert(new_dir, conn, NULL, &bad_path, &st);
mkdir_internal(conn, new_dir);
/* For each driver file, archi\filexxx.yyy, if there is a duplicate file
@@ -1480,6 +1496,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->driverpath);
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)) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
@@ -1488,9 +1505,10 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unlink_internals(conn, 0, new_name);
ver = -1;
}
- }
- else
+ } else {
+ driver_unix_convert(new_name, conn, NULL, &bad_path, &st);
unlink_internals(conn, 0, new_name);
+ }
}
if (driver->datafile && strlen(driver->datafile)) {
@@ -1499,6 +1517,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->datafile);
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)) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
@@ -1507,9 +1526,10 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unlink_internals(conn, 0, new_name);
ver = -1;
}
- }
- else
+ } else {
+ driver_unix_convert(new_name, conn, NULL, &bad_path, &st);
unlink_internals(conn, 0, new_name);
+ }
}
}
@@ -1520,6 +1540,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->configfile);
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)) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
@@ -1528,9 +1549,10 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unlink_internals(conn, 0, new_name);
ver = -1;
}
- }
- else
+ } else {
+ driver_unix_convert(new_name, conn, NULL, &bad_path, &st);
unlink_internals(conn, 0, new_name);
+ }
}
}
@@ -1542,6 +1564,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->helpfile);
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)) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
@@ -1550,9 +1573,10 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unlink_internals(conn, 0, new_name);
ver = -1;
}
- }
- else
+ } else {
+ driver_unix_convert(new_name, conn, NULL, &bad_path, &st);
unlink_internals(conn, 0, new_name);
+ }
}
}
@@ -1573,6 +1597,7 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->dependentfiles[i]);
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)) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
@@ -1581,9 +1606,10 @@ BOOL move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
unlink_internals(conn, 0, new_name);
ver = -1;
}
- }
- else
+ } else {
+ driver_unix_convert(new_name, conn, NULL, &bad_path, &st);
unlink_internals(conn, 0, new_name);
+ }
}
NextDriver: ;
}
@@ -4410,6 +4436,8 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
DATA_BLOB null_pw;
NTSTATUS nt_status;
fstring res_type;
+ BOOL bad_path;
+ SMB_STRUCT_STAT st;
if ( !info_3 )
return False;
@@ -4445,6 +4473,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
if ( *info_3->driverpath ) {
if ( (s = strchr( &info_3->driverpath[1], '\\' )) != NULL ) {
+ driver_unix_convert(s, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting driverfile [%s]\n", s));
unlink_internals(conn, 0, s);
}
@@ -4452,6 +4481,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
if ( *info_3->configfile ) {
if ( (s = strchr( &info_3->configfile[1], '\\' )) != NULL ) {
+ driver_unix_convert(s, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting configfile [%s]\n", s));
unlink_internals(conn, 0, s);
}
@@ -4459,6 +4489,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
if ( *info_3->datafile ) {
if ( (s = strchr( &info_3->datafile[1], '\\' )) != NULL ) {
+ driver_unix_convert(s, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting datafile [%s]\n", s));
unlink_internals(conn, 0, s);
}
@@ -4466,6 +4497,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
if ( *info_3->helpfile ) {
if ( (s = strchr( &info_3->helpfile[1], '\\' )) != NULL ) {
+ driver_unix_convert(s, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting helpfile [%s]\n", s));
unlink_internals(conn, 0, s);
}
@@ -4480,6 +4512,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
/* bypass the "\print$" portion of the path */
if ( (file = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) {
+ driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting dependent file [%s]\n", file));
unlink_internals(conn, 0, file );
}
@@ -4987,4 +5020,3 @@ BOOL print_time_access_check(int snum)
return ok;
}
-