Loading source3/printing/nt_printing.c +46 −14 Original line number Diff line number Diff line Loading @@ -367,6 +367,19 @@ BOOL nt_printing_init(void) return True; } /******************************************************************* 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. ********************************************************************/ Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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; Loading Loading @@ -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 Loading @@ -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", Loading @@ -1488,10 +1505,11 @@ 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)) { if (!strequal(driver->datafile, driver->driverpath)) { Loading @@ -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", Loading @@ -1507,11 +1526,12 @@ 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->configfile && strlen(driver->configfile)) { if (!strequal(driver->configfile, driver->driverpath) && Loading @@ -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", Loading @@ -1528,11 +1549,12 @@ 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->helpfile && strlen(driver->helpfile)) { if (!strequal(driver->helpfile, driver->driverpath) && Loading @@ -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", Loading @@ -1550,11 +1573,12 @@ 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->dependentfiles) { for (i=0; *driver->dependentfiles[i]; i++) { Loading @@ -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", Loading @@ -1581,10 +1606,11 @@ 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: ; } } Loading Loading @@ -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; Loading Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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 ); } Loading Loading @@ -4987,4 +5020,3 @@ BOOL print_time_access_check(int snum) return ok; } Loading
source3/printing/nt_printing.c +46 −14 Original line number Diff line number Diff line Loading @@ -367,6 +367,19 @@ BOOL nt_printing_init(void) return True; } /******************************************************************* 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. ********************************************************************/ Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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; Loading Loading @@ -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 Loading @@ -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", Loading @@ -1488,10 +1505,11 @@ 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)) { if (!strequal(driver->datafile, driver->driverpath)) { Loading @@ -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", Loading @@ -1507,11 +1526,12 @@ 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->configfile && strlen(driver->configfile)) { if (!strequal(driver->configfile, driver->driverpath) && Loading @@ -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", Loading @@ -1528,11 +1549,12 @@ 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->helpfile && strlen(driver->helpfile)) { if (!strequal(driver->helpfile, driver->driverpath) && Loading @@ -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", Loading @@ -1550,11 +1573,12 @@ 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->dependentfiles) { for (i=0; *driver->dependentfiles[i]; i++) { Loading @@ -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", Loading @@ -1581,10 +1606,11 @@ 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: ; } } Loading Loading @@ -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; Loading Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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); } Loading @@ -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 ); } Loading Loading @@ -4987,4 +5020,3 @@ BOOL print_time_access_check(int snum) return ok; }