AppleScripts not working for an account using FileVault

I have FileVault turned on for a particular user account on my machine but AppleScript seems to be locked out of this user’s folders even when I am logged in as this user.

For example I use AppleScript to get the names of all files in a folder. If this folder is contained in the protected user’s home then despite the fact that I am logged in as that user the AppleScript fails.

Any suggestions?

Thanks

Martin

Disclaimer: I don’t have Panther/FileVault.

It’s hard to say without seeing your code but I suspect there’s a problem with paths. Are the paths/references in the script hardwired or built on the fly?

Hardwired: alias “Mac HD:Users:username:”
On the fly: path to current user folder

– Rob

Rob, Thanks for picking this up…

The code I have used is:

tell application "Finder"
			set FileList to {}
			try
				set FileList to (name of every file of folder ImportSource) as list
			end try
		end tell

where ImportSource has been hardcoded as “Mac HD:Users:username:folder:” or “username:folder” or the result of a choose folder.

Does this help?

Martin

Well, I would think that a ‘choose folder’ would work around a path problem if that was the issue. Since I don’t have access to FileVault, I have nothing else to offer. I know that you aren’t the first person who has encountered this type of problem but I don’t know if anyone has been able to overcome it.

On a related note, based on all that I’ve read about FileVault, it needs more work and I wouldn’t trust it with my data. One disadvantage is that it puts all user data into a single file (disk image). This means that if the disk image becomes unusable, everything is lost. I run daily backups but I still don’t like the idea of placing all of my cookies in one basket.

– Rob

I’ve reported this to Apple as Bug ID #3519134.

I really hope this can be fixed soon…

For a workaround, check out “FileVault-proof Finder selection to alias list” at scriptbuilders.net/files/filevaultprooffinderselectiontoaliaslist1.2.html in the ScriptBuilders section. It shows how to coerce FileVault-protected Finder objects into regular AppleScript aliases or POSIX items. Then you can use f.i. “info for” and all other commands of the StandardAdditions on the AppleScript alias of your FileVault-protected file or folder. “Info for” gets you the item’s name, kind, creation date etc.

HTH

Jan

Model: Alu-PowerBook 15" 1.25 GHz
AppleScript: 1.10
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

There is a script which bypasses the bug in the case of the network disk mounted by automount. Thanks to Michal Málek.


on open (x)
	getAsFinderItem(x)
	open result
end open


on getAsFinderItem(x) -- x may be an alias
	tell application "Finder"
		set applePath to (x as Unicode text)
		set itemList to my split(applePath, ":") -- decompose  path to x to the list of strings
		my compose(rest of itemList, disk (first item of itemList))
	end tell
end getAsFinderItem

on compose(lst, rst)
	-- compose({x1, x2, .., xn}, r) --> item x1 of item x2 of ...item xn of r 
	-- compose({""}, r) --> r 	
	tell application "Finder"
		if length of lst is 0 or (length of lst is 1 and first item of lst is "") then
			return rst
		else
			return my compose(rest of lst, item (item 1 of lst) of rst)
		end if
	end tell
end compose


on split(str, delim)
	-- inspired by http://www.apple.com/applescript/guidebook/sbrt/pgs/sbrt.07.htm
	set originalDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to the delim
	set the item_list to every text item of str
	set AppleScript's text item delimiters to originalDelim
	return item_list
end split

In a quick check on my FileVault-protected PowerBook, Michal Málek’s script as suggested by tlustoch in the last post works on folders only, not on files. For yet another approach that works on both folders and files, check out the ScriptBuilder post “Get/set Finder properties of FileVault-protected items” at scriptbuilders.net/files/getsetfinderpropertiesoffilevaultprotecteditems1.1.html.

HTH,

Jan

Model: Alu-PowerBook 15" 1.25 GHz
AppleScript: 1.10
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

No more need for my workaround in Leopard, Apple finally fixed the underlying bug when moving to Mac OS 10.5.

:slight_smile: