11/*
22 * Printer routines for the CUPS scheduler.
33 *
4- * Copyright © 2020-2024 by OpenPrinting
4+ * Copyright © 2020-2025 by OpenPrinting
55 * Copyright © 2007-2019 by Apple Inc.
66 * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77 *
@@ -2794,8 +2794,7 @@ cupsdUpdatePrinterPPD(
27942794 int i ; /* Looping var */
27952795 cups_file_t * src , /* Original file */
27962796 * dst ; /* New file */
2797- char srcfile [1024 ], /* Original filename */
2798- dstfile [1024 ], /* New filename */
2797+ char filename [1024 ], /* PPD filename */
27992798 line [1024 ], /* Line from file */
28002799 keystring [41 ]; /* Keyword from line */
28012800 cups_option_t * keyword ; /* Current keyword */
@@ -2805,37 +2804,21 @@ cupsdUpdatePrinterPPD(
28052804 p -> name );
28062805
28072806 /*
2808- * Get the old and new PPD filenames ...
2807+ * Get the base PPD filename ...
28092808 */
28102809
2811- snprintf (srcfile , sizeof (srcfile ), "%s/ppd/%s.ppd.O" , ServerRoot , p -> name );
2812- snprintf (dstfile , sizeof (srcfile ), "%s/ppd/%s.ppd" , ServerRoot , p -> name );
2810+ snprintf (filename , sizeof (filename ), "%s/ppd/%s.ppd" , ServerRoot , p -> name );
28132811
28142812 /*
2815- * Rename the old file and open the old and new...
2813+ * Open the old and new PPDs ...
28162814 */
28172815
2818- if (rename (dstfile , srcfile ))
2819- {
2820- cupsdLogMessage (CUPSD_LOG_ERROR , "Unable to backup PPD file for %s: %s" ,
2821- p -> name , strerror (errno ));
2816+ if ((src = cupsdOpenConfFile (filename )) == NULL )
28222817 return (0 );
2823- }
28242818
2825- if ((src = cupsFileOpen ( srcfile , "r" )) == NULL )
2819+ if ((dst = cupsdCreateConfFile ( filename , ConfigFilePerm )) == NULL )
28262820 {
2827- cupsdLogMessage (CUPSD_LOG_ERROR , "Unable to open PPD file \"%s\": %s" ,
2828- srcfile , strerror (errno ));
2829- rename (srcfile , dstfile );
2830- return (0 );
2831- }
2832-
2833- if ((dst = cupsFileOpen (dstfile , "w" )) == NULL )
2834- {
2835- cupsdLogMessage (CUPSD_LOG_ERROR , "Unable to create PPD file \"%s\": %s" ,
2836- dstfile , strerror (errno ));
28372821 cupsFileClose (src );
2838- rename (srcfile , dstfile );
28392822 return (0 );
28402823 }
28412824
@@ -2845,11 +2828,9 @@ cupsdUpdatePrinterPPD(
28452828
28462829 if (!cupsFileGets (src , line , sizeof (line )))
28472830 {
2848- cupsdLogMessage (CUPSD_LOG_ERROR , "Unable to read PPD file \"%s\": %s" ,
2849- srcfile , strerror (errno ));
2831+ cupsdLogMessage (CUPSD_LOG_ERROR , "Unable to read PPD file \"%s\": %s" , filename , strerror (errno ));
28502832 cupsFileClose (src );
28512833 cupsFileClose (dst );
2852- rename (srcfile , dstfile );
28532834 return (0 );
28542835 }
28552836
@@ -2887,7 +2868,7 @@ cupsdUpdatePrinterPPD(
28872868 */
28882869
28892870 cupsFileClose (src );
2890- cupsFileClose (dst );
2871+ cupsdCloseCreatedConfFile (dst , filename );
28912872
28922873 return (1 );
28932874}
@@ -3448,7 +3429,7 @@ add_printer_filter(
34483429 }
34493430
34503431 do
3451- {
3432+ {
34523433 ptr ++ ;
34533434 } while (_cups_isspace (* ptr ));
34543435
0 commit comments