So I'm creating a script at work that will automatically change preferences of the screensaver preference file, then reapply chmod and chown to that file. I want it to run for all users on that computer minus the standard accounts like Guest or Shared.
This is what I've got so far.
echo copying file
sudo cp -v PolicyBanner.rtf /Library/Security
echo changing permission
sudo chmod -R o+rw /Library/Security/PolicyBanner.rtf
#What I'm doing here is listing all the user directories in /Users, minus "Shared" - I guess I should include "Guest" as well. The point is to modify a specific file in each user directory (/Users/<user>/Library/Preferences/<file>.
Then reapply own ownership and permission to the file so it will take effect.
Otherwise OSX will throw out the changes thinking that it is corrupt.
# I want to take the output ($i) and put it into an array to read so when I run
the defaults, chown, and chmod commands, it's running them for the users own file.
#The for loop gets all the users minus Shared. Then I want to add those into an array so when I run the chmod, chown command they modify that users specific file.
for i in `ls`;
if [ $i == "Shared" ]; then
sudo defaults write </Users/<user>/Library/Preferences/<file>
sudo chown <user> </Users/<user>/Library/Preferences/<file>
sudo chmod 600 </Users/<user>/Library/Preferences/<file>
echo securing system preferences
sudo chmod o-r /System/Library/PreferencePanes/<file>