Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error backing up SourceTree #30

Closed
dbingham opened this issue Apr 29, 2013 · 13 comments
Closed

Error backing up SourceTree #30

dbingham opened this issue Apr 29, 2013 · 13 comments

Comments

@dbingham
Copy link

Backing up Library/Application Support/SourceTree/sourcetree.license...
Traceback (most recent call last):
  File "./mackup.py", line 731, in <module>
    main()
  File "./mackup.py", line 684, in main
    app.backup()
  File "./mackup.py", line 310, in backup
    delete(filepath)
  File "./mackup.py", line 490, in delete
    os.remove(filepath)
OSError: [Errno 1] Operation not permitted: '/Users/dbingham/Library/Application Support/SourceTree/sourcetree.license'
@lra
Copy link
Owner

lra commented Apr 29, 2013

Can you give me the output of ls -al /Users/dbingham/Library/Application Support/SourceTree/ and ls -al "Dropbox/Mackup/Library/Application Support/SourceTree/" ?

@dbingham
Copy link
Author

$ ls -al /Users/dbingham/Library/Application\ Support/SourceTree/
total 48
drwxr-xr-x    9 dbingham  staff   306 Apr  2 12:35 ./
drwx------+ 106 dbingham  staff  3604 Apr 29 09:17 ../
drwxr-xr-x    3 dbingham  staff   102 Nov  9  2011 MASReceipt/
drwxr-xr-x    8 dbingham  staff   272 Apr  2 11:17 SourceTree 1.5.8/
-rw-r--r--    1 dbingham  staff  5361 Apr  2 12:35 browser.plist
-rw-r--r--@   1 dbingham  staff   812 Apr  2 11:59 hgrc_sourcetree
-rw-r--r--    1 dbingham  staff   366 Mar 18 09:45 hostusernamemap
-rw-r--r--    1 dbingham  staff   236 Apr  2 12:35 openWindowList
-rw-r--r--@   1 dbingham  staff   568 Feb 27  2012 sourcetree.license

and

$ ls -al "Dropbox/Mackup/Library/Application Support/SourceTree/"
total 8
drwxr-xr-x  3 dbingham  staff  102 Apr 29 09:17 ./
drwxr-xr-x  6 dbingham  staff  204 Apr 29 09:17 ../
-rw-------  1 dbingham  staff  568 Apr 29 09:17 sourcetree.license

@lra
Copy link
Owner

lra commented Apr 30, 2013

Can you try this version ? https://github.com/lra/mackup/blob/fix_sourcetree/mackup.py
Replace your current mackuped sourcetree files if asked.

If it breaks anything, just move back your "Application Support/SourceTree" from Mackup to your user's library.

@dbingham
Copy link
Author

dbingham-itko:mackup(fix_sourcetree) dbingham$ ./mackup.py backup
Backing up Library/Application Support/SourceTree/sourcetree.license...
A file named /Users/dbingham/Dropbox/Mackup/Library/Application Support/SourceTree/sourcetree.license already exists in the backup.
Are you sure that your want to replace it ? <Yes|No>Yes
Traceback (most recent call last):
  File "./mackup.py", line 734, in <module>
    main()
  File "./mackup.py", line 687, in main
    app.backup()
  File "./mackup.py", line 304, in backup
    delete(filepath)
  File "./mackup.py", line 493, in delete
    os.remove(filepath)
OSError: [Errno 1] Operation not permitted: '/Users/dbingham/Library/Application Support/SourceTree/sourcetree.license'

@dbingham
Copy link
Author

So. I looked at this a bit more...

-------------------------------------------------------------------------------------------------------- 09:14:22
dbingham-itko:mackup(fix_sourcetree) dbingham$ ls -l /Users/dbingham/Library/Application\ Support/SourceTree/sourcetree.license
-rw-r--r--@ 1 dbingham  staff  568 Feb 27  2012 /Users/dbingham/Library/Application Support/SourceTree/sourcetree.license
-------------------------------------------------------------------------------------------------------- 09:14:27
dbingham-itko:mackup(fix_sourcetree) dbingham$ xattr "/Users/dbingham/Library/Application Support/SourceTree/sourcetree.license"
com.apple.metadata:com_apple_backup_excludeItem
com.apple.quarantine

Nothing really odd there. I'd expect to be able to delete the file. Let's clone the dir and try to delete the file from the OS and see what happens.

-------------------------------------------------------------------------------------------------------- 09:15:30
dbingham-itko:mackup(fix_sourcetree) dbingham$ ditto "/Users/dbingham/Library/Application Support/SourceTree" ~/Desktop/SourceTree
-------------------------------------------------------------------------------------------------------- 09:19:49
dbingham-itko:mackup(fix_sourcetree) dbingham$ ls -la ~/Desktop/SourceTree/
total 48
drwxr-xr-x  9 dbingham  staff   306 Apr  2 12:35 ./
drwx------+ 5 dbingham  staff   170 Apr 30 09:19 ../
drwxr-xr-x  3 dbingham  staff   102 Nov  9  2011 MASReceipt/
drwxr-xr-x  8 dbingham  staff   272 Apr  2 11:17 SourceTree 1.5.8/
-rw-r--r--  1 dbingham  staff  5361 Apr  2 12:35 browser.plist
-rw-r--r--@ 1 dbingham  staff   812 Apr  2 11:59 hgrc_sourcetree
-rw-r--r--  1 dbingham  staff   366 Mar 18 09:45 hostusernamemap
-rw-r--r--  1 dbingham  staff   236 Apr  2 12:35 openWindowList
-rw-r--r--@ 1 dbingham  staff   568 Feb 27  2012 sourcetree.license
-------------------------------------------------------------------------------------------------------- 09:19:58
dbingham-itko:mackup(fix_sourcetree) dbingham$ xattr ~/Desktop/SourceTree/sourcetree.license 
com.apple.metadata:com_apple_backup_excludeItem
com.apple.quarantine
-------------------------------------------------------------------------------------------------------- 09:20:11
dbingham-itko:mackup(fix_sourcetree) dbingham$ rm ~/Desktop/SourceTree/sourcetree.license 
override rw-r--r--  dbingham/staff uchg for /Users/dbingham/Desktop/SourceTree/sourcetree.license? y
rm: /Users/dbingham/Desktop/SourceTree/sourcetree.license: Operation not permitted

Hm. Ok. 'dbingham' has write, so should be able to delete. Am I who I think I am?

-------------------------------------------------------------------------------------------------------- 09:20:42
dbingham-itko:mackup(fix_sourcetree) dbingham$ whoami
dbingham
-------------------------------------------------------------------------------------------------------- 09:20:45
dbingham-itko:mackup(fix_sourcetree) dbingham$ groups
staff com.apple.access_ssh access_bpf everyone _appstore localaccounts _appserverusr admin _appserveradm _lpadmin _lpoperator _developer com.apple.sharepoint.group.1 com.apple.access_screensharing-disabled com.apple.sharepoint.group.2

Yes, I am. Weird. How about dir permissions. If the dir doesn't have write, I won't be able to delete...

-------------------------------------------------------------------------------------------------------- 09:21:40
dbingham-itko:mackup(fix_sourcetree) dbingham$ ls -ld "/Users/dbingham/Library/Application Support/SourceTree"
drwxr-xr-x  9 dbingham  staff  306 Apr  2 12:35 /Users/dbingham/Library/Application Support/SourceTree/

But it does, so that's not it. Only other thing I know of is file flags.

-------------------------------------------------------------------------------------------------------- 09:22:02
dbingham-itko:mackup(fix_sourcetree) dbingham$ ls -lO "/Users/dbingham/Library/Application Support/SourceTree"
total 48
drwxr-xr-x  3 dbingham  staff  -     102 Nov  9  2011 MASReceipt/
drwxr-xr-x  8 dbingham  staff  -     272 Apr  2 11:17 SourceTree 1.5.8/
-rw-r--r--  1 dbingham  staff  -    5361 Apr  2 12:35 browser.plist
-rw-r--r--@ 1 dbingham  staff  -     812 Apr  2 11:59 hgrc_sourcetree
-rw-r--r--  1 dbingham  staff  -     366 Mar 18 09:45 hostusernamemap
-rw-r--r--  1 dbingham  staff  -     236 Apr  2 12:35 openWindowList
-rw-r--r--@ 1 dbingham  staff  uchg  568 Feb 27  2012 sourcetree.license

And there it is. "uchg". Weird. I never set that myself. Maybe an earlier version of sourcetree did it automatically? Let's remove it and be sure...

-------------------------------------------------------------------------------------------------------- 09:40:55
dbingham-itko:mackup(fix_sourcetree) dbingham$ chflags nouchg ~/Desktop/SourceTree/sourcetree.license 
-------------------------------------------------------------------------------------------------------- 09:41:04
dbingham-itko:mackup(fix_sourcetree) dbingham$ rm ~/Desktop/SourceTree/sourcetree.license 

Well, that worked. Let's try it on the real file and try mackup again.

-------------------------------------------------------------------------------------------------------- 09:41:40
dbingham-itko:mackup(fix_sourcetree) dbingham$ chflags nouchg ~/Library/Application\ Support/SourceTree/sourcetree.license 
-------------------------------------------------------------------------------------------------------- 09:42:03
dbingham-itko:mackup(fix_sourcetree) dbingham$ ./mackup.py backup
Backing up Library/Application Support/SourceTree/sourcetree.license...
A file named /Users/dbingham/Dropbox/Mackup/Library/Application Support/SourceTree/sourcetree.license already exists in the backup.
Are you sure that your want to replace it ? <Yes|No>Yes
Backing up Library/Application Support/SourceTree/browser.plist...
Backing up Library/Application Support/SourceTree/hgrc_sourcetree...
...

Works like a charm now.

@lra
Copy link
Owner

lra commented Apr 30, 2013

Thanks that helps I'll work on this

@lra
Copy link
Owner

lra commented Apr 30, 2013

Could you try the latest version of https://github.com/lra/mackup/blob/fix_sourcetree/mackup.py ?
It should fix all those problems for good.

@lra
Copy link
Owner

lra commented Apr 30, 2013

you can bring back the sourcetree folder and chflags -R uchg it before.

@dbingham
Copy link
Author

Yeah, it works. But it messes with permissions in a way I wouldn't expect. I would expect permissions to be preserved as much as possible. For example:

Before (I put things back as close as possible to the original state):

dbingham-itko:SourceTree dbingham$ ls -lO@
total 48
drw-r--r--  3 dbingham  staff  -     102 Nov  9  2011 MASReceipt/
drw-r--r--  8 dbingham  staff  -     272 Apr  2 11:17 SourceTree 1.5.8/
-rw-r--r--  1 dbingham  staff  -    5361 Apr 30 11:37 browser.plist
-rw-r--r--@ 1 dbingham  staff  -     812 Apr 30 11:37 hgrc_sourcetree
    com.apple.TextEncoding    15 
-rw-r--r--  1 dbingham  staff  -     366 Mar 18 09:45 hostusernamemap
-rw-r--r--  1 dbingham  staff  -     236 Apr  2 12:35 openWindowList
-rw-r--r--@ 1 dbingham  staff  uchg  568 Apr 30 11:37 sourcetree.license
    com.apple.metadata:com_apple_backup_excludeItem   17 

And the files in the Mackup directory on Dropbox after a backup:

dbingham-itko:SourceTree dbingham$ ls -lO@
total 32
-rw-------  1 dbingham  staff  - 5361 Apr 30 11:49 browser.plist
-rw-------  1 dbingham  staff  -  812 Apr 30 11:49 hgrc_sourcetree
-rw-------  1 dbingham  staff  -  568 Apr 30 11:49 sourcetree.license

So, I expected the uchg flag to be gone, but didn't expect the xattrs to be gone and the permissions to change from 644 to 600.

Is that a limitation of Dropbox?

@dbingham
Copy link
Author

Also, while I'm thinking about it, is hostusernamemap not something we'd want to keep around? The name sounds like something that would be fairly useful.

@lra
Copy link
Owner

lra commented Apr 30, 2013

For the chmod and xattrs being cleaned up, it's because dropbox uses a default umask of 0644 for files, and when you sync your ssh keys (or any other license) you don't (and can't for ssh) have your key files readable by anyone.

As I don't think it make sense for any user config file to be readable by anyone, I just blindly enforce a mode of 0600 to any synced file.

The xattrs are cleaned up, because OS X use them to set some ACL that prevent mackup to move some files around too, and I don't see the point of keeping those special ACLs if I 0600 any file. But I might be wrong here.

About hostusernamemap, if you think it's a file that should be synced, we can add it to the list, feel free to tell me which file to sync here as I'm not a user of SourceTree.

@dbingham
Copy link
Author

On the permissions changes, I doubt it'll matter for the vast majority of stuff. Maybe someday you'll run across an application that just has to have its xattrs 'just so' in order to work. But until then, I say, go with what you've got. It makes things "cleaner" anyway.

I use SourceTree, but I don't know much about how it manages its files. The filename just sounded like it would be something along the lines of a cache of usernames you've used when authenticating with various hostnames. I could be totally wrong. But, in any case, it doesn't sound like anything critical. I could even see an argument for excluding it on purpose for security reasons. Feels weak to me, but I could see it.

Anyway, pure speculation on my part. If/when I come across anything definite about this file I'll either open a new ticket or send a pull request your way.

For the issue I reported here, I think we're good now. Feel free to close away!

Thanks!

@lra
Copy link
Owner

lra commented Apr 30, 2013

Makes sense, merging in, thx for your help

@lra lra closed this as completed Apr 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants