diff options
Diffstat (limited to 'source/printing/nt_printing.c')
-rw-r--r-- | source/printing/nt_printing.c | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index 944b695a9dd..cbd220d2602 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -659,13 +659,18 @@ BOOL nt_printing_init(struct messaging_context *msg_ctx) Function to allow filename parsing "the old way". ********************************************************************/ -static void driver_unix_convert(char *name,connection_struct *conn, - char *saved_last_component, SMB_STRUCT_STAT *pst) +static void driver_unix_convert(connection_struct *conn, + pstring name, + SMB_STRUCT_STAT *pst) { + char *new_name = NULL; unix_format(name); unix_clean_name(name); trim_string(name,"/","/"); - unix_convert(conn, name, False, saved_last_component, pst); + unix_convert(talloc_tos(),conn, name, False, &new_name, NULL, pst); + if (new_name) { + pstrcpy(name, new_name); + } } /******************************************************************* @@ -755,7 +760,7 @@ BOOL get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form) { int i,count; fstring form_name; - unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)-1); + unistr2_to_ascii(form_name, uni_formname, sizeof(form_name)); DEBUGADD(6,("Looking for builtin form %s \n", form_name)); count = sizeof(default_forms) / sizeof(default_forms[0]); for (i=0;i<count;i++) { @@ -858,7 +863,7 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) update=False; - unistr2_to_ascii(form_name, &form->name, sizeof(form_name)-1); + unistr2_to_ascii(form_name, &form->name, sizeof(form_name)); for (n=0; n<*count; n++) { if ( strequal((*list)[n].name, form_name) ) { update=True; @@ -871,7 +876,7 @@ BOOL add_a_form(nt_forms_struct **list, const FORM *form, int *count) DEBUG(0,("add_a_form: failed to enlarge forms list!\n")); return False; } - unistr2_to_ascii((*list)[n].name, &form->name, sizeof((*list)[n].name)-1); + unistr2_to_ascii((*list)[n].name, &form->name, sizeof((*list)[n].name)); (*count)++; } @@ -901,7 +906,7 @@ BOOL delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR *ret = WERR_OK; - unistr2_to_ascii(form_name, del_name, sizeof(form_name)-1); + unistr2_to_ascii(form_name, del_name, sizeof(form_name)); for (n=0; n<*count; n++) { if (!strncmp((*list)[n].name, form_name, strlen(form_name))) { @@ -933,7 +938,7 @@ void update_a_form(nt_forms_struct **list, const FORM *form, int count) { int n=0; fstring form_name; - unistr2_to_ascii(form_name, &(form->name), sizeof(form_name)-1); + unistr2_to_ascii(form_name, &(form->name), sizeof(form_name)); DEBUG(106, ("[%s]\n", form_name)); for (n=0; n<count; n++) { @@ -1288,7 +1293,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); - driver_unix_convert(filepath,conn,NULL,&stat_buf); + driver_unix_convert(conn,filepath,&stat_buf); status = open_file_ntcreate(conn, NULL, filepath, &stat_buf, FILE_GENERIC_READ, @@ -1324,7 +1329,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); - driver_unix_convert(filepath,conn,NULL,&stat_buf); + driver_unix_convert(conn,filepath,&stat_buf); status = open_file_ntcreate(conn, NULL, filepath, &stat_buf, FILE_GENERIC_READ, @@ -1452,7 +1457,7 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_ * deriver the cversion. */ slprintf(driverpath, sizeof(driverpath)-1, "%s/%s", architecture, driverpath_in); - driver_unix_convert(driverpath,conn,NULL,&st); + driver_unix_convert(conn,driverpath,&st); if ( !vfs_file_exist( conn, driverpath, &st ) ) { *perr = WERR_BADFILE; @@ -1741,6 +1746,7 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract SMB_STRUCT_STAT st; int ver = 0; int i; + TALLOC_CTX *ctx = talloc_tos(); memset(inbuf, '\0', sizeof(inbuf)); memset(outbuf, '\0', sizeof(outbuf)); @@ -1793,7 +1799,7 @@ WERROR 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, &st); + driver_unix_convert(conn,new_dir,&st); create_directory(conn, new_dir); /* For each driver file, archi\filexxx.yyy, if there is a duplicate file @@ -1819,8 +1825,8 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract slprintf(new_name, sizeof(new_name)-1, "%s/%s", architecture, driver->driverpath); 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) { - driver_unix_convert(new_name, conn, NULL, &st); - if ( !NT_STATUS_IS_OK(copy_file(conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| + driver_unix_convert(conn,new_name,&st); + if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); @@ -1835,8 +1841,8 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract slprintf(new_name, sizeof(new_name)-1, "%s/%s", architecture, driver->datafile); 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) { - driver_unix_convert(new_name, conn, NULL, &st); - if ( !NT_STATUS_IS_OK(copy_file(conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| + driver_unix_convert(conn,new_name,&st); + if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); @@ -1853,8 +1859,8 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract slprintf(new_name, sizeof(new_name)-1, "%s/%s", architecture, driver->configfile); 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) { - driver_unix_convert(new_name, conn, NULL, &st); - if ( !NT_STATUS_IS_OK(copy_file(conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| + driver_unix_convert(conn,new_name,&st); + if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); @@ -1872,8 +1878,8 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract slprintf(new_name, sizeof(new_name)-1, "%s/%s", architecture, driver->helpfile); 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) { - driver_unix_convert(new_name, conn, NULL, &st); - if ( !NT_STATUS_IS_OK(copy_file(conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| + driver_unix_convert(conn,new_name,&st); + if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", new_name, old_name)); @@ -1900,8 +1906,8 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract slprintf(new_name, sizeof(new_name)-1, "%s/%s", architecture, driver->dependentfiles[i]); 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) { - driver_unix_convert(new_name, conn, NULL, &st); - if ( !NT_STATUS_IS_OK(copy_file(conn, new_name, old_name, + driver_unix_convert(conn,new_name,&st); + if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE| OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) { DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n", @@ -4938,7 +4944,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 ) { pstrcpy( file, s ); - driver_unix_convert(file, conn, NULL, &st); + driver_unix_convert(conn,file,&st); DEBUG(10,("deleting driverfile [%s]\n", s)); unlink_internals(conn, NULL, 0, file, False); } @@ -4947,7 +4953,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 ) { pstrcpy( file, s ); - driver_unix_convert(file, conn, NULL, &st); + driver_unix_convert(conn,file,&st); DEBUG(10,("deleting configfile [%s]\n", s)); unlink_internals(conn, NULL, 0, file, False); } @@ -4956,7 +4962,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 ) { pstrcpy( file, s ); - driver_unix_convert(file, conn, NULL, &st); + driver_unix_convert(conn,file,&st); DEBUG(10,("deleting datafile [%s]\n", s)); unlink_internals(conn, NULL, 0, file, False); } @@ -4965,7 +4971,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 ) { pstrcpy( file, s ); - driver_unix_convert(file, conn, NULL, &st); + driver_unix_convert(conn,file,&st); DEBUG(10,("deleting helpfile [%s]\n", s)); unlink_internals(conn, NULL, 0, file, False); } @@ -4981,7 +4987,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct if ( (p = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) { pstrcpy( file, p ); - driver_unix_convert(file, conn, NULL, &st); + driver_unix_convert(conn,file,&st); DEBUG(10,("deleting dependent file [%s]\n", file)); unlink_internals(conn, NULL, 0, file, False); } |