The scheduler did not use the ConfigFilePerm setting when copying PPD files or
interface scripts attached to a request (STR #4703)

Use cupsdCreateConfFile when copying attached files, and use ConfigFilePerm.



git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@12851 a1ca3aef-8c08-0410-bb20-df032aa958be
diff --git a/CHANGES.txt b/CHANGES.txt
index 40ea992..b61a4cc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,10 +1,12 @@
-CHANGES.txt - 2.1.0 - 2015-08-26
+CHANGES.txt - 2.1.0 - 2015-08-28
 --------------------------------
 
 CHANGES IN CUPS V2.1.0
 
 	- Fixed more scheduler crash bugs in the new logging code (STR #4687,
 	  STR #4690)
+	- The scheduler did not use the ConfigFilePerm setting when copying PPD
+	  files or interface scripts attached to a request (STR #4703)
 	- Now support new Chinese locale IDs and their correct fallback locales
 	  (<rdar://problem/22086642>, <rdar://problem/22130168>)
 	- "make check" incorrectly reported an expectation of 18 warning
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 0e9249d..624f219 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -70,7 +70,7 @@
 			   cups_array_t *exclude);
 static int	copy_banner(cupsd_client_t *con, cupsd_job_t *job,
 		            const char *name);
-static int	copy_file(const char *from, const char *to);
+static int	copy_file(const char *from, const char *to, mode_t mode);
 static int	copy_model(cupsd_client_t *con, const char *from,
 		           const char *to);
 static void	copy_job_attrs(cupsd_client_t *con,
@@ -2615,7 +2615,7 @@
 	* interfaces directory and make it executable...
 	*/
 
-	if (copy_file(srcfile, dstfile))
+	if (copy_file(srcfile, dstfile, ConfigFilePerm | 0110))
 	{
           send_ipp_status(con, IPP_INTERNAL_ERROR,
 	                  _("Unable to copy interface script - %s"),
@@ -2625,7 +2625,6 @@
 
 	cupsdLogMessage(CUPSD_LOG_DEBUG,
 			"Copied interface script successfully");
-	chmod(dstfile, 0755);
       }
 
       snprintf(dstfile, sizeof(dstfile), "%s/ppd/%s.ppd", ServerRoot,
@@ -2638,7 +2637,7 @@
 	* ppd directory and make it readable by all...
 	*/
 
-	if (copy_file(srcfile, dstfile))
+	if (copy_file(srcfile, dstfile, ConfigFilePerm))
 	{
           send_ipp_status(con, IPP_INTERNAL_ERROR,
 	                  _("Unable to copy PPD file - %s"),
@@ -2648,7 +2647,6 @@
 
 	cupsdLogMessage(CUPSD_LOG_DEBUG,
 			"Copied PPD file successfully");
-	chmod(dstfile, 0644);
       }
       else
       {
@@ -4336,7 +4334,8 @@
 
 static int				/* O - 0 = success, -1 = error */
 copy_file(const char *from,		/* I - Source file */
-          const char *to)		/* I - Destination file */
+          const char *to,		/* I - Destination file */
+	  mode_t     mode)		/* I - Permissions */
 {
   cups_file_t	*src,			/* Source file */
 		*dst;			/* Destination file */
@@ -4353,7 +4352,7 @@
   if ((src = cupsFileOpen(from, "rb")) == NULL)
     return (-1);
 
-  if ((dst = cupsFileOpen(to, "wb")) == NULL)
+  if ((dst = cupsdCreateConfFile(to, mode)) == NULL)
   {
     cupsFileClose(src);
     return (-1);
@@ -4377,7 +4376,7 @@
 
   cupsFileClose(src);
 
-  return (cupsFileClose(dst));
+  return (cupsdCloseCreatedConfFile(dst, to));
 }