Folder Action to strip ACEs and remove user immutable bit (Leopard)

Hi all,

We’ve recently filed an official bug report with apple regarding the way Leopard handles ACEs on the ACLs when copying files from another *nix server that isn’t bound to directory services to a client that is (it keeps the ACEs from the remote file system, which it isn’t supposed to). The issue is further compounded when you copy these files directly to XSan 2.1-- the files become ghost files that the SAN can’t resolve (not even to delete!!)

Anyway, after being on the phone with Apple Enterpise, they suggested until they get around to fixing the issue, that I write a folder-action script to strip ACEs and the user immutable bit from the files being copied to the workstations. The folder-action script should just be applied to the Desktop, and when users want to copy files from the remote SMB share to the SAN, they have to do a “hop” and copy it do the desktop of the local workstation first (where it strips everything and prepares it to be copied to the SAN).

Here is my script:


(*
Add - Fix File Permissions for SAN
©2009 Independence Public Media

This Folder Action handler is triggered whenever items are added to the attached folder.

The script will strip ACE and the user immutable bit off of all files that are copied to the desktop.
If this script does not run and files are copied to the SAN, then the ACEs and user immutable bit cause the files to become ghost files. 
*)

on adding folder items to this_folder after receiving these_items
	try
		repeat with i from 1 to number of items in these_items
			set this_item to item i of these_items
			tell application "Finder"
				set this_path to the quoted form of the POSIX path of this_item
				do shell script ("chmod -R -N " & this_path & "; chflags -R nouchg " & this_path)
				(* do shell script ("chmod 705 " & this_path) *)
			end tell
		end repeat
	end try
end adding folder items to

When I originally coded the script I did it on a Tiger machine (1.10.7), and the code was to just set the permissions of the file to 705 (as a test). It runs fine on my Tiger machine, but for some reason I can’t get it to run on Leopard (2.0.1). I’m fairly new to applescript, but I think I did an okay job (and it runs on tiger?). Any ideas?

Thanks a bunch!

Model: MacPro
AppleScript: 2.0.1
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

Hi,

in Leopard the nouchg flag can only be changed as owner or root

 
.
do shell script ("chmod -R -N " & this_path & "; chflags -R nouchg " & this_path) user name "user" password "¢¢¢" with administrator privilege
.
s

Hi,

Thanks for your response.

Well when I run the folder action script, the chmod -R -N doesn’t execute either, as the ACEs aren’t stripped. Additionally, if i run chflags -R nouchg on a file from the command prompt using the same account in which I’m trying to attach this desktop folder action script, it works fine.

Here we show this happening:

The script, however, is not executing the commands.

Thanks,
-M

then catch the error with a on error branch and display dialog the error
A pure try block is actually useless in a folder action event handler, because a folder action script aborts silently, when an error occurs