0

I have setup FTP between 2 remote systems and scripts are set up on both the system to Archive and Extract the file. So the script in the source Archives(tar) file and the script on the destination (extracts) the file. After each FTP transfer, I notice that files copied in the destination have write permission missing in the group(rwxr_xr_x).

I have checked manually creating the file and also the umask value of the user and when creating a file manually, it creates with write permission for the group user. This seems to be limited to only this FTP operation. Any Ideas?

3
  • 1
    This is probably dependent on the FTP client. – wurtel Jan 23 '19 at 15:39
  • How so? what would cause such a behavior on the FTP client? – Johnny_doubts Jan 23 '19 at 17:56
  • Nothing "cause" such behaviour, it will be programmed to behave so. If I write a ftp client that always gives files it creates for example the mode "rwxr---w-" then there's not much you could do about that. So if the client sets its own umask and/or forces permissions, then that will cause the behaviour you see. However I now read that you really meant the permissions of the files extracted from a tar file after the tar file is transferred via ftp, that's a completely different issue. – wurtel Jan 24 '19 at 8:14
1

If the file being transferred via FTP is a tar file, and the problem is that permissions of files within the tar file are not being preserved or honored after extraction, it's not an FTP problem.

When extracting the file, tar will by default honor your umask. In this case, I would guess it's set to 022, which masks the write bit for "group" and "other" in newly-created files. You need to run tar with the -p option when extracting to force it to keep the exact permissions as they appear inside the tar file.

2
  • hmm... thank you for pointing out to that.. I will check on that and reply back if that solved the issue... Thank you James :) – Johnny_doubts Jan 23 '19 at 17:58
  • I tried it worked but I have a newer problem at hand. The tar file happens to contain files created by different user, while this method works for files the user who is untarring owns it doesn't seem to have any effect on other user files. I'm unable to wrap my head around it. So I tried untarring the file as a 3rd user who has a umask of 0077 to my astonishment there is no change in the file permission after untar a tarred file with 777 permission after untar still retains the same set of permission (777) – Johnny_doubts Mar 6 '19 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.