tracker issue : CF-4114019

select a category, or use search below
(searches all categories and all time range)

Folders and files saved as read-only when extracted by cfzip

| View in Tracker

Status/Resolution/Reason: To Fix//BugVerified

Reporter/Name(from Bugbase): Earl Schellhous / Earl Schellhous (Earl Schellhous)

Created: 02/04/2016

Components: File Management

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Linux OracleLinux 6

Vote Count: 0

+++++++++Problem Description: I'm using <cfzip> because the production server is still on CF9. <cfzip> is first used to zip a directory recursively into a temporary zip file. A directory is created using <cfdirectory> and set to mode="775". Then the files are extracted into the new directory using <cfzip>. All directories and files created by <cfzip> are read only.

Steps to Reproduce:
Use the relevant parts of the code to reproduce:

<!--- zipfile = /var/www/html/ --->
<cfset zipfile = request.webroot & "admin/" />

<cfzip action="zip" source="#sourceFolder#" file="#zipfile#" recurse="yes" storePath="yes">

<cfif NOT DirectoryExists(destFolder)>
		destFolder = /var/www/html/CHE2A/SSII2016 and is saved as mode 775  
		ls -al:
		drwxrwxr-x  15 apache   devel  4096 Feb  4 09:50 SSII2016
	<cfdirectory action="CREATE" directory="#destFolder#" mode="775" />
	<cfzip action="unzip" file="#zipfile#" recurse="yes" storePath="yes" destination="#destFolder#" />
	<cfoutput><strong>Directory #destFolder# created and files placed.</strong><br></cfoutput>
	<cffile action="READ" file="#destFolder#/Application.cfm" variable="appFile" />
	<!--- do some stuff to the file
	<cfset appFile = Replace(appFile,"DEFAULTCOURSENAME",CNUMBER & Year) />
	<cfset appFile = Replace(appFile,"DEFAULTCOID",FORM.NewCOID) />
		Fails at <cffile action="WRITE"> files and folders under destFolder are
		saved as mode 755 (read only for group). ColdFusion is running under user apache 
		and group devel and saves the extracted folders as 755 and the .cfm files
		as 444 (read only for all).
		ls -al:
 		drwxr-xr-x  2 apache devel 4096 Feb  4 09:37 Exercise
		-r--r--r--  1 apache devel 2988 Jul 21  2006 index.cfm
	<cffile action="WRITE" file="#destFolder#/Application.cfm" output="#appFile#" />
	<cfoutput><strong>Application.cfm modified.</strong><br></cfoutput>
	<cffile action="DELETE" file="#zipfile#" />
	<cfoutput><strong>Temp zip file deleted.</strong><br></cfoutput>
	<cfoutput><strong>Directory #destFolder# already exists.</strong></cfoutput>

Actual Result:
Files and directories are created read-only

Expected Result:
Files and directories should be writeable by the same group that created them.

Any Workarounds:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4114019

External Customer Info:
External Company:  
External Customer Name: Earl Schellhous
External Customer Email:  
External Test Config: My Hardware and Environment details:

Server Product 	ColdFusion

Version 	11,0,07,296330

Edition 	Developer  

Operating System 	UNIX  

OS Version 	3.8.13-55.1.5.el6uek.x86_64  

Update Level 	/opt/coldfusion11/cfusion/lib/updates/chf11000007.jar  

Adobe Driver Version 	5.1.3 (Build 000094)



I am able to repor this on linux. If in the source folder permission for group and others is 777 then after unizip persimmon changes to read read only for group and others and for user executable permission is not there. i have the repro case. Please reach to me for machine details.
Comment by Poonam J.
4821 | July 14, 2016 11:56:59 PM GMT
This is a limitation in Unix environement. Whenever a file is added to zip archive, its permission information is lost and it is set to 544 by default. There is a way to override this but the current library we use for zip (zip4j) does not support that. We need to use common-compress for that. Even then the the premission has to be set for each file individually using source file permisssions. To fix this we need to change the zip library and make lots of changes in ColdFusion code too. We will evaluate this for the next release.
Comment by Chinoy G.
4822 | July 27, 2016 11:39:01 PM GMT