mackup icon indicating copy to clipboard operation
mackup copied to clipboard

Why mackup change files' permission

Open hujianxin opened this issue 7 years ago • 15 comments

I have some executable script sync with mackup, when synced, these files will not be executed

hujianxin avatar Sep 04 '18 15:09 hujianxin

Try to sync a folder with your execs in it (e.g. ~/bin)?

lra avatar Sep 04 '18 18:09 lra

@lra Also not work

hujianxin avatar Sep 06 '18 04:09 hujianxin

If you sync a folder and not the files within it, mackup does not change the files permissions. Make sure you sync a folder and not files.

lra avatar Sep 06 '18 06:09 lra

I synced a folder, but mackup does change the files permission......

hujianxin avatar Sep 06 '18 12:09 hujianxin

My bad you are right, but it's this way because some file syncing engine and some OS mess up with the permissions (e.g. make some file executable, or world readable), and unless we find time to write specific code for each engine, the default has been to just make every folder and file read/write for the current user only.

lra avatar Sep 06 '18 19:09 lra

This bites me whenever I run mackup backup. I use Mackup, zsh, oh-my-zsh Git functionality, and powerlevel10k theme. If you run into problems with gitstatus, just use:

chmod +x ~/<your cloud drive>/Mackup/.oh-my-zsh/custom/themes/powerlevel10k/gitstatus/bin/gitstatusd-*

davidfmatheson avatar Dec 14 '20 15:12 davidfmatheson

When I copy any file (mackup backup -> file_system), their permissions totally reset to 700, and don't resore (when mackup uninstall)...

roman1gan avatar Jan 30 '22 09:01 roman1gan

@hujianxin did this issue go away for you? I can retry with the current version, if so.

davidfmatheson avatar Feb 08 '22 13:02 davidfmatheson

@davidfmatheson I don't use markup as for now, sorry for that.

hujianxin avatar Feb 09 '22 08:02 hujianxin

I have the same issue on macOS and Dropbox.

@lra What is the significance of calling chmod() after copying the file or directory? https://github.com/lra/mackup/blob/736c9975bf6f35fb52e5b14ef6cf72802356c760/mackup/utils.py#L142

I understand what I am about to propose may be inefficient, but can we call os.access() with os.R_OK, os.W_OK, and os.X_OK on the file or directory (recursively) to see what permissions the user has and set them correctly when backing up (instead of setting them to 0600 or 0700 blindly)? os.access() will consider ACLs as well, which is a bonus.

Because the mackup backup command is rarely called, the overhead of calling os.access() should be tolerable.

MahdiNazemi avatar Mar 02 '23 20:03 MahdiNazemi

@lra, I just noticed this issue is closed. Would it be possible to reopen it if you think using os.access() has some merit?

MahdiNazemi avatar Mar 07 '23 07:03 MahdiNazemi

Removing this would require adding tests and testing it on all engines, because it was added to prevent errors when adding files with bad modes to synced folders (e.g. in dropbox) leading to errors and issues.

lra avatar Apr 25 '23 09:04 lra

@lra could we just add a separate CLI flag to force keeping file permissions then? Users having the above problem would have a mechanism to solve it, with a remark there's no guarantee of no engine-specific errors, the rest would be unaffected.

jaklan avatar Dec 22 '23 22:12 jaklan

Yes, it could be a per app setting.

lra avatar Dec 30 '23 12:12 lra

Any updates?

weeebdev avatar Jul 08 '24 17:07 weeebdev