Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Repair a user/group Finder crashing issue System 10.5
If you've tried to edit the ownership of your files in Leopard's Finder, you may have seen in the Get Info window that many of your files and folders belong to a group called "unknown," and that when you try to fix them, the Finder crashes. This is because in older versions of Mac OS X, users belonged to their own private groups with the same ID number as the user (e.g., 501/501). But in Leopard, users now have a primary group membership of staff (20). Unfortunately, if you updated your system to Leopard using the Archive/Install or Upgrade method, your existing users were left with their old membership values, and Leopard doesn't quite love them.

Fixing the problem requires several steps, including editing your user accounts' hidden options, fixing group ownership of your home folder, and sending some obscure commands to directory services in Terminal via the dscl command. Whew! To make things simpler, I've written a simple bash script that makes all the necessary changes. And here it is:
#!/bin/bash
#
# Leopard User Fix by Thinkyhead
#
# Fixes the broken group membership in Leopard after an upgrade
#

if [ `whoami` == "root" ]; then
 echo "[ERROR] `basename $0` must be executed as an admin user (no sudo)."
 exit 1
fi

GID_IS_UID=`sudo dscl . read /Users/$USER | grep PrimaryGroupID | grep "$UID"`
GID_IS_STAFF=`sudo dscl . read /Users/$USER | grep PrimaryGroupID | grep 20`

if [ -z $GID_IS_UID ]; then
 echo "[ERROR] It looks like your account is already fixed!"
  if [ -z "$GID_IS_STAFF" ]; then
   echo "[ERROR] However, you are not a member of group 'staff' which is bad!"
  fi

 echo -n "Would you like to proceed anyway? (y/N):"; read PROCEED
 if [ -z $REPAIR ] || [ "$PROCEED" = "n" ] || [ "$PROCEED" = "N" ]; then
  exit 0
 fi
fi

#
# 1. Change User's primary group to "staff" (20):
#
	sudo dscl . changei /Users/$USER PrimaryGroupID 1 20

#
# 2. Make sure the user is in the "staff" group in Directory Services:
#

USER_IS_IN_STAFF=`sudo dscl . read /Groups/staff | grep GroupMembership | grep "$USER"`

if [ -z $USER_IS_IN_STAFF ]; then
	sudo dscl . append /Groups/staff GroupMembership $USER
fi

#
# 3. Fix group permissions on all items in the user's home folder:
#
	sudo chgrp -R staff $HOME

#
# ...or more slowly, but more accurately:
#
#	sudo chgrp staff $HOME
#	sudo find $HOME -group $UID -exec chgrp staff "{}" ;
#

#
# 4. Delete the group that's no longer in use:
#
	sudo dscl . delete /Groups/$USER >/dev/null 2>&1

#
# 5. Repair Permissions
#

echo -n "Would you like to repair permissions? (Y/n):"; read REPAIR
if [ -z $REPAIR ] || [ "$REPAIR" = "y" ] || [ "$REPAIR" = "Y" ]; then
  sudo diskutil repairPermissions /
fi

#
# 6. Reboot for safety.
#

echo -n "Logging out is recommended, but reboot is more thorough.nWould you like to reboot? (Y/n):"; read REBOOT
if [ -z $REBOOT ] || [ "$REBOOT" = "y" ] || [ "$REBOOT" = "Y" ]; then
  reboot
fi

exit 0
Save the script somewhere, and make it executable (chmod a+x scriptname), then run it to fix the problem.

[robg adds: As a reader on the queue review site noted, Apple has a different solution: create a group with the same group ID as your user ID, and make that new group your primary group. I'm not sure that this problem affects all Upgrade users, either -- my MacBook Pro was upgraded from 10.4 to 10.5, but it doesn't have this Finder crash on Get Info edit problem.]
    •    
  • Currently 3.43 / 5
  You rated: 2 / 5 (7 votes cast)
 
[46,788 views]  

10.5: Repair a user/group Finder crashing issue | 12 comments | Create New Account
Click here to return to the '10.5: Repair a user/group Finder crashing issue' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Repair a user/group Finder crashing issue
Authored by: momerath on Dec 12, '07 10:47:02AM

I had this same problem. When I enabled ACLs on the folders it seemed to work well enough. Thanks for the alternate solution (and the link to the apple one).



[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: Hal Itosis on Dec 12, '07 02:03:22PM
>This is because in older versions of Mac OS X, users belonged to their own private groups
> with the same ID number as the user (e.g., 501/501). But in Leopard, users now have
> a primary group membership of staff (20).

All pre-Panther cats (Jaguar, etc.) had users' files and folders in the staff group.
So this is not anything new. It may be that Leopard has *reintroduced* this to
make "sharing" a lighter task... but Panther used the '501/501' scheme as part
of the enhanced security features it promoted (shadow passwords, etc).

What's really happened here is that -- due to the demise of Net Info and the
final move to Directory Services -- some users using some upgrade paths had
some problems (with their accounts getting converted properly). Their special
private 'group' simply didn't make the trip. [Whether this is a bug on Apple's
part, or maybe the users backed up to a disk where ownerships were ignored,
or both, or something else... isn't entirely clear.

What is clear is that there is an alternative (as robg linked to) to simply create
the missing group. Somehow though, I don't think their command sequence
is the best solution yet, because: there's no provision to link our group name
to any *gid* number. [I wish some server gurus here would post about this.]

Anyway... here's my best attempt thus far:

### create a group with the same name & number as user/uid: 

 sudo dscl . -create /Groups/`id -un` Password \*
 sudo dscl . -create /Groups/`id -un` PrimaryGroupID `id -u`
 sudo dscl . -merge /Groups/`id -un` GroupMembership `id -un`
 sudo dscacheutil -flushcache

 sudo dscl . -create /Users/`id -un` PrimaryGroupID `id -u`
 sudo dscacheutil -flushcache

As the O.P.'s script suggests, realize that: those commands I posted should be pasted into
Terminal (one-by-one) as they are... and *not* saved as a script which gets run with sudo.

If that were done, many variables would execute with values of '0' instead of '501'.

Comments/corrections welcome.

-HI-


[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: johnsawyercjs on Jan 23, '08 07:25:54PM

Hal Itosis says:

"As the O.P.'s script suggests, realize that: those commands I posted should be pasted into Terminal (one-by-one) as they are... and *not* saved as a script which gets run with sudo."

I don't see any suggestion in the original post that implies (at least to me) that the commands you supply need to be pasted into Terminal (though I believe you when you say your commands need to be pasted in)--where's the connection? The script in the original post says to save the script shown there as an executable, and mentions nothing about running it line by line from Terminal. I see the line "must be executed as an admin user (no sudo)", but I'm still puzzled.



[ Reply to This | # ]
DOES NOT WORK...
Authored by: germ on Dec 12, '07 05:39:53PM

./LeopardUserFix.sh: line 16: [: PrimaryGroupID:: binary operator expected



[ Reply to This | # ]
DOES NOT WORK...
Authored by: macmark.de on Dec 23, '07 10:50:07AM

Yeah, it seems to have a bug, but you can use the essential lines of it to do it manually.



[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: johnsawyercjs on Jan 23, '08 07:16:10PM

Attempts to compile the original post's script, using Script Editor, results in this when it hits the 'whoami' in one of the first lines:

if [ 'whoami' == "root" ]; then

Syntax error
"Expected expression, etc. but found unknown token"

Any solutions?



[ Reply to This | # ]
Not AppleScript
Authored by: thinkyhead on Jul 29, '11 02:51:31PM

Script Editor is for AppleScripts, not BASH scripts. This script is meant to be run in Terminal.

---
|
| slur was here
|



[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: johnsawyercjs on Jan 23, '08 07:29:48PM

Hmm. I thought I'd fixed this problem with my Mac's OS 10.5.1 a while back, but now it's happening again. I don't remember what I did (if anything), but Apple's solution, and Hal Itosis's commands (entered one by one into Terminal), haven't fixed it for me. I can't try slur's script, due to the compile error I mention above.



[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: johnsawyercjs on Jan 23, '08 07:35:35PM

The good old BatChmod 1.37 utility fixed the folder I was trying to fix, removing the "unknown" user entry, after which Finder's Get Info listed just the users System, Admin, and Everyone for that folder. iRepair 1.06 couldn't see the folder until I used BatChmod.



[ Reply to This | # ]
you are not a member of group 'staff'
Authored by: MtnBiker on Feb 01, '08 05:00:51PM

I ran the original posters script and got the following message (running script in TextMate):
[ERROR] However, you are not a member of group 'staff' which is bad!

Can I add myself to staff?

I think I got in the mess because when installed Leopard I had some problems (like a blue screen after first try at upgrading from Panther), so I ran the Leopard upgrade again and in my hast typed my short username wrong. Then in the System Preferences>Users I created an account using my old short user name, gave myself admin rights and deleted the accidentally created user. But like others I get password required dialog boxes to delete a file. I'm also having Aperture problems which I suspect may be permissions related.

I'm looking at the Forums here and see similar problems, but I'm out of my element here. I'm OK with using terminal, but the whole permissions thing is beyond me, and I don't want to mess it up any more than it already is. I'm thinking about erasing and starting over, but that's days of reinstalling apps, etc.

I realize that the forums may be a better place for this, but the original script trapped a problem I have, so am trying here first.

Thanks

---
Hermosa Beach, CA USA



[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: PizzaCake on Mar 11, '08 12:53:33PM

Thanks, I had a problem with spotlight not indexing some files especially spotlight comments. I'd tried deleting spotlight-V100 to re-index and many other things which did not work when all along it was a group membership problem.

I had upgraded from Tiger to Leopard. The GUI tools in Leopard showed my primary group was staff and nothing looked wrong until I discovered the Unix commands thanks to your great script. I didn't run the script but it was very well commented so I knew what the commands did if I ran them in terminal.

dscl . read /Groups/staff

showed I wasn't in the group staff.

sudo dscl . append /Groups/staff GroupMembership $USER

added me to group staff.

sudo chgrp -R staff $HOME

changes group ownership on all files in home to staff.

sudo diskutil repairPermissions /

repair disk permissions.

Reboot.




[ Reply to This | # ]
10.5: Repair a user/group Finder crashing issue
Authored by: engrav on May 18, '08 04:27:11PM

thank you much, this thread fixed my stuff, I think

I appended myself into staff with sudo dscl . append /Groups/staff GroupMembership $USER as above

then (since I am a unix newbie) went back to System Preferences and set my GID to 20

which after reboot resulted in a new group engrav (501) which I deleted

and now id in terminal displays the right stuff and all is working (so far)

thank you



[ Reply to This | # ]