Skip navigation

How to reset permissions for all user home dirs

1025 Views 1 Reply Latest reply: Feb 17, 2013 4:09 PM by Don Roedl RSS
Newbie-2-macs Level 1 Level 1 (15 points)
Currently Being Moderated
Feb 17, 2013 5:19 AM

Hello all,

 

Hope someone can help me with how best to approach this.

 

The home dirs permissions have been messed up by a restore of data. Users cannot log into clients for some reason. I have created a new home dir for an existing user which can now login whereas with his previous home dir could not. After checking the permissions on some home folders, it looks like the owner is missing (just blank).

 

I was going to use a terminal script to extract the username using dscl and then using this in a variable reset the home dirs. However, it gets a little more complicated in that the user homes are spererated into folders such as year7, year 8 etc). I have tried to extract the NFSHomeDirectory, again using dscl, but this is where I get stuck. My script allows me to pull in the first column of the array but I don't know how to edit the script to pull in the NFSHomeDirectory path into a 2nd array that can then be added to the chown script via a variable. Here is my script at the moment. $HomeDir is the variable that will hold the NFSHomeDirectory path.

 

#!/bin/bash

# userlist.sh

 

dscl /LDAPv3/127.0.0.1 -list /Users NFSHomeDirectory | awk '{print $1","$2}' > $PWD/Users.txt

UIDs=$PWD/users.txt

 

for name in $(awk 'BEGIN{FS=","}{print $1}' < "$UIDs" )

 

do

 

sudo chown -R $name $HomeDir

sudo chmod -R 700 $HomeDir

 

sudo chmod +a "$name allow list,add_file,search,delete,add_subdirectory,delete_child,readattr,writeattr,re adextattr,writeextattr,readsecurity,file_inherit,directory_inherit" $HomeDir

sudo chown -R $name:staff $HomeDir

sudo chmod -R ug+rwx $HomeDir

 

  let "n += 1"

 

done

exit 0

 

Thanks in advance for any help.

  • Don Roedl Level 2 Level 2 (210 points)

    Assuming you have tried resetting the actual owner name on one of the homes with an 'unknown' user, and it works then it is a simple matter of changing the permissions. The application Passenger from MacInMind software has functionality built in to batch change permissions in directories. Its reliable and works slick! I have also used 'Server Cleanup" version 2 (10.3/10.4 servers) in the past to successfully repair home permissions. There is a vesion 3 that is for 10.5 server. You could give it a look and see if it is for you. Read all instructions and warnings on that one. http://www.gabrenas.org/ServerCleanup3.html

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.