Greetings all,
I'm trying to move what were formerly local login and logout hook files on our lab machines to Jamf Pro. I'm having trouble with one at the moment. It is the script I use to roll out old home directories. We don't want the user home directories to hang around forever, but we don't want students to lose files to a system crash or forgetting to copy them to local storage, so we have a two user buffer before the home directory is deleted. The script runs on logout. This does not seem to work in Mojave. I get a bunch of "operation not permitted" errors. I assume this has something to do with the greater protections in Mojave (the labs were never updated to High Sierra, they are still running Sierra, and have not been under Jamf Pro before either). There is some logic around what directories to get rid of, but the salient portion of things is just:
chflags -Rf nouchg "${baseDirectory}${homeFolder}"
rm -Rf "${baseDirectory}${homeFolder}"
WriteLog "PurgeOldHomes" "${baseDirectory}"${homeFolder}" just died"
What I get back is the following (kinda lengthy). The folders that do not have associated errors are indeed deleted like they are supposed to be, but it leaves behind the Library folder, the Pictures folder, and of course the home directory folder itself. The short question is, is there a way around this? We need this functionality. Thanks for any help. Here is a part of the log (alabuser is a substitute for a student ID):
2019-02-13 12:37:56 PurgeOldHomes Working on alabuser
2019-02-13 12:37:56 PurgeOldHomes /Users/alabuser is a directory and is being evaluated
2019-02-13 12:37:56 PurgeOldHomes /Users/alabuser is Unprotected and is being evaluated
chflags: /Users/alabuser/Library/Application Support/CallHistoryTransactions: Operation not permitted
chflags: /Users/alabuser/Library/Application Support/com.apple.TCC: Operation not permitted
chflags: /Users/alabuser/Library/Application Support/AddressBook: Operation not permitted
chflags: /Users/alabuser/Library/Application Support/CallHistoryDB: Operation not permitted
chflags: /Users/alabuser/Library/IdentityServices: Operation not permitted
chflags: /Users/alabuser/Library/Calendars: Operation not permitted
chflags: /Users/alabuser/Library/Messages: Operation not permitted
chflags: /Users/alabuser/Library/Mail: Operation not permitted
chflags: /Users/alabuser/Library/Safari: Operation not permitted
chflags: /Users/alabuser/Library/Suggestions: Operation not permitted
chflags: /Users/alabuser/Library/Containers/com.apple.Safari: Operation not permitted
chflags: /Users/alabuser/Library/PersonalizationPortrait: Operation not permitted
chflags: /Users/alabuser/Library/Metadata/CoreSpotlight: Operation not permitted
chflags: /Users/alabuser/Library/Cookies: Operation not permitted
chflags: /Users/alabuser/Library/Caches/CloudKit/com.apple.Safari: Operation not permitted
rm: /Users/alabuser/Pictures: Operation not permitted
rm: /Users/alabuser/Library/Application Support/CallHistoryTransactions: Operation not permitted
rm: /Users/alabuser/Library/Application Support/com.apple.TCC: Operation not permitted
rm: /Users/alabuser/Library/Application Support/AddressBook: Operation not permitted
rm: /Users/alabuser/Library/Application Support/CallHistoryDB: Operation not permitted
rm: /Users/alabuser/Library/Application Support: Operation not permitted
rm: /Users/alabuser/Library/IdentityServices: Operation not permitted
rm: /Users/alabuser/Library/Calendars: Operation not permitted
rm: /Users/alabuser/Library/Preferences/com.apple.AddressBook.plist: Operation not permitted
rm: /Users/alabuser/Library/Preferences/com.apple.universalaccess.plist: Operation not permitted
rm: /Users/alabuser/Library/Preferences: Operation not permitted
rm: /Users/alabuser/Library/Messages: Operation not permitted
rm: /Users/alabuser/Library/Mail: Operation not permitted
rm: /Users/alabuser/Library/Safari: Operation not permitted
rm: /Users/alabuser/Library/Suggestions: Operation not permitted
rm: /Users/alabuser/Library/Containers/com.apple.Safari: Operation not permitted
rm: /Users/alabuser/Library/Containers: Operation not permitted
rm: /Users/alabuser/Library/PersonalizationPortrait: Operation not permitted
rm: /Users/alabuser/Library/Metadata/CoreSpotlight: Operation not permitted
rm: /Users/alabuser/Library/Metadata: Operation not permitted
rm: /Users/alabuser/Library/Cookies: Operation not permitted
rm: /Users/alabuser/Library/Caches/CloudKit/com.apple.Safari: Operation not permitted
rm: /Users/alabuser/Library/Caches/CloudKit: Operation not permitted
rm: /Users/alabuser/Library/Caches: Operation not permitted
rm: /Users/alabuser/Library: Operation not permitted
rm: /Users/alabuser: Operation not permitted
2019-02-13 12:37:56 PurgeOldHomes /Users/alabuser just died