Different File Folder Permissions When Uploading Script

durangod

Well-Known Member
May 12, 2012
502
45
78
cPanel Access Level
Website Owner
Hi,
I have a test user that also uses cpanel. They told me during testing of my script that they had to change the folder permissions from 700 to 755 to test it.

I checked the folders on my cpanel version of the script and they are 755, and when i upload and unzip the zip file they are also 755.

So i had the user choose a few odd folders from another script (not mine) and just zip them up as a test and unzip them on his server, they were 755. So i had him
do the exact same thing with my script, they were 700.

This has be baffled, i would understand if maybe he was using a different panel on his server or maybe other folders did the same thing. But i dont understand
why my folders are different and upload as 700 when other scripts upload at 755, especially when they are 755 on my server and i zip them from there.

Any ideas on what to check or where to even start, im baffled..

The user said he was using cpanel file manager to upload and unpack the zip files (not ftp or sftp)
 
Last edited:

keat63

Well-Known Member
Nov 20, 2014
1,795
204
93
cPanel Access Level
Root Administrator
Are you sending them directly from one server to the other ?
I personally wouldn't know how to do this, it's something that i've never tried.
I would ordinarily use my local PC as a middle man.

What happens if you download to your PC then upload to the new server ?
 

durangod

Well-Known Member
May 12, 2012
502
45
78
cPanel Access Level
Website Owner
Hi, thanks for your reply.... no i am downloading the zip file from cpanel to my pc, then the file gets unzipped to my pc and the folder gets put into github, then the user gets it from github. However we have also tried it with me sending the zip file directly to him and skipping github and the same thing, he uploads it to his server and 700

So far in my research i have found this, it still does not really explain it fully but its in the right direction i think...

most archive formats -- including zip -- do NOT include permissions in their archive. When you unpack the files they will default to whatever permissions the directory you unpack them into has. This is why most folks use tarballs as they do include permissions. .zip, .rar, and .7z do not.
That makes sense other than the fact that his folder is 755..
 

keat63

Well-Known Member
Nov 20, 2014
1,795
204
93
cPanel Access Level
Root Administrator
What does he use to upload them to his server.
I used to use WSFTP for instance, which if I recall would change the permissions for some unknown reason.

Today I use FileZilla.
So I just created a new folder on my PC.

SFTP uploaded it to one of my cpanel accounts, and it went across as 755.
I changed its permissions on the server to 700 and deleted it from my PC.
Then downloaded back to my PC.

Removed it from the server.
Re-uploaded it back to the server and now its permissions was 775.

Considering it was 755, then manually changed to 700, which ended up being 755 with no interaction from me other than SFTP.

Something is going on that I can't explain, but proves that it's not just you.

This was an empty folder by the way, no files, no zips etc.
 

cPSamuelM

Technical Analyst Team Lead
Staff member
Nov 20, 2019
182
31
103
USA
cPanel Access Level
Root Administrator
Hello @durangod

I'm not sure if I understand the exact reproduction steps for this issue. Am I correct in understanding that the directories inside a .zip archive are being assigned permissions of 700 after being unzipped? Or are the contents of the .zip archive extracted prior to being uploaded?

Note that the umask is responsible for setting the permissions on newly created files, unless the new files are already assigned permissions, as in a tar archive.

https://man7.org/linux/man-pages/man1/umask.1p.html

You might want to check the umask on the affected user to determine if it is responsible for the unexpected results you're observing.
 

durangod

Well-Known Member
May 12, 2012
502
45
78
cPanel Access Level
Website Owner
Thanks for the replies.... turns out after some testing its not a cpanel issue. I sent two archives to the user, one tar and one zip via email, they both uploaded correctly as 755 folders. Now the only difference is that the first time the user got the files via my repo on github, so it seems that somehow github repository changes the file permissions of the files in some way. I am still researching this..... :)

Has anyone ever heard of github changing file permissions?
 

cPSamuelM

Technical Analyst Team Lead
Staff member
Nov 20, 2019
182
31
103
USA
cPanel Access Level
Root Administrator
Hello,

I'm glad to hear it's not a cPanel issue. As for file permissions changing when moving files into your git repository, that may be dependent on a number of different factors, for example the environment of your local PC and the method you are using to move the files into git.

The following 3rd party article provides a brief overview of how git handles file mode settings:

https://medium.com/@tahteche/how-git-treats-changes-in-file-permissions-f71874ca239d
 

durangod

Well-Known Member
May 12, 2012
502
45
78
cPanel Access Level
Website Owner
Thanks for the link im sure it should help... appreciate that very much.. I upload my repo using githubs desktop application. I cant use the cpanel github deal because it means i have to enable ssh and i dont want to do that. I feel safer using the desktop app.

For those of you who are new to github, get their desktop application, it makes quick work of keeping your repo updated, add a comment, hit two buttons and done the master is updated. I tried doing the same directly in github and they made it sooo complicated i could not understand what i was suppose do to and when.. But the desktop app makes it so easy.. no logging in, it just does it..

Now i am sure that with such automation there might be some downsides (like maybe this permission deal) im not sure.... But i like it anyway... :)