Re: Adding password for a file to keychain
Re: Adding password for a file to keychain
- Subject: Re: Adding password for a file to keychain
- From: Uli Kusterer <email@hidden>
- Date: Tue, 20 Dec 2005 20:28:28 +0100
Am 20.12.2005 um 18:31 schrieb Shawn Erickson:
How was it moved or renamed?
Aliases, when use right, will deal with moves and renamed as long as
the file is still on the same volume.
So how are you constructing your alias and resolving your alias?
Using an Alias *can't* work in this case. An Alias is a combination
of lots of info for finding a file. Let's assume it simply contained
the path, containing directory ID, file name and node ID. The
original Alias is
{ Hard Disk:Folder:File.txt, 17, File.txt, 777 }
Now the file is moved, and a new Alias is created:
{ Hard Disk:Folder2:File.txt, 18, File.txt, 777 }
These Aliases are different, although both can be used to find the
same file (since name and node ID still allow finding the moved
file). Aliases aren't guaranteed to stay the same, thus they are
unsuitable for looking up moved files.
Am 20.12.2005 um 18:08 schrieb Glen Simmons:
The alias works unless the file has been moved or renamed. Then the
alias data is different. So I'm thinking about doing this:
1. Create alias for the file and try to get the password from the
keychain using that.
2. If #1 fails, walk the keychain items that are "mine" and resolve
each alias to see if it matches. If so, try the password and if it
succeeds, update the filename / alias.
The node ID isn't really reliable as it's not available for all file
systems. It's not even dependent on the file system, but rather can
be available or not depending on how a file system was mounted
(remote vs. local etc.), if I remember correctly.
Your method sounds like a decent fallback plan, but I'd suggest you
try some additional approaches to avoid the overhead of walking the
keychain each time: Attach the Alias as a resource to your file
(typically type 'alis' is used), and use setxattr() to do the same in
a more Unix-safe way (requires 10.4 though, and I'm not sure how
persistent it is).
If you can somehow manage, try to get a sort of unique ID into your
file format. Most file formats contain length bytes or terminators,
so you should be able to append a GUUID to the file without causing
problems for other (older?) apps reading the files. They may get
stripped from the file by other apps but that's it. So, as long as
you can get that approved by the maintainers of the file format, that
would be even more reliable.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden