summaryrefslogtreecommitdiff
path: root/source/printing
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2004-05-07 18:31:17 +0000
committerGerald Carter <jerry@samba.org>2004-05-07 18:31:17 +0000
commitd391651d4211fc88c89447c3e86eba1ecd4e3f52 (patch)
treef60ec29ae8e9e830a15312bd845121810356a067 /source/printing
parentb7fc60b599845f29dd1fe44e50420f6044ba7d5e (diff)
downloadsamba-d391651d4211fc88c89447c3e86eba1ecd4e3f52.tar.gz
r567: getting ready for 3.0.4 -- still holding for one more bug fix
Diffstat (limited to 'source/printing')
-rw-r--r--source/printing/nt_printing.c64
-rw-r--r--source/printing/printing.c10
2 files changed, 54 insertions, 20 deletions
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c
index 675794c4c27..0670b2543eb 100644
--- a/source/printing/nt_printing.c
+++ b/source/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: ;
}
@@ -2692,14 +2718,13 @@ static WERROR publish_it(NT_PRINTER_INFO_LEVEL *printer)
/* retreive the guid and store it locally */
if (ADS_ERR_OK(ads_search_dn(ads, &res, prt_dn, attrs))) {
- ads_memfree(ads, prt_dn);
ads_pull_guid(ads, res, &guid);
ads_msgfree(ads, res);
store_printer_guid(printer->info_2, guid);
win_rc = mod_a_printer(*printer, 2);
}
- safe_free(prt_dn);
+ SAFE_FREE(prt_dn);
ads_destroy(&ads);
return WERR_OK;
@@ -3030,6 +3055,7 @@ static int unpack_values(NT_PRINTER_DATA *printer_data, char *buf, int buflen)
/* check to see if there are any more registry values */
+ regval_p = NULL;
len += tdb_unpack(buf+len, buflen-len, "p", &regval_p);
if ( !regval_p )
break;
@@ -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;
}
-
diff --git a/source/printing/printing.c b/source/printing/printing.c
index e4ef1f52d0e..2355dd14506 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -249,7 +249,7 @@ static TDB_DATA print_key(uint32 jobid)
static uint32 j;
TDB_DATA ret;
- j = jobid;
+ SIVAL(&j, 0, jobid);
ret.dptr = (void *)&j;
ret.dsize = sizeof(j);
return ret;
@@ -358,9 +358,9 @@ static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key,
return 0;
if (*sysjob == pjob->sysjob) {
- uint32 *jobid = (uint32 *)key.dptr;
+ uint32 jobid = IVAL(key.dptr,0);
- sysjob_to_jobid_value = *jobid;
+ sysjob_to_jobid_value = jobid;
return 1;
}
@@ -1905,10 +1905,12 @@ static BOOL allocate_print_jobid(struct tdb_print_db *pdb, int snum, const char
static BOOL add_to_jobs_changed(struct tdb_print_db *pdb, uint32 jobid)
{
TDB_DATA data, key;
+ uint32 store_jobid;
key.dptr = "INFO/jobs_changed";
key.dsize = strlen(key.dptr);
- data.dptr = (char *)&jobid;
+ SIVAL(&store_jobid, 0, jobid);
+ data.dptr = (char *)&store_jobid;
data.dsize = 4;
DEBUG(10,("add_to_jobs_changed: Added jobid %u\n", (unsigned int)jobid ));