Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running into a root permissions issue on OS X 10.8.3. This is manifesting itself in various forms.

It became clear after trying to execute a self-update of MacPorts. The following issue http://stackoverflow.com/questions/15780321/macport-selfupdate-fails-code-23-xcode-command-line-tools-are-installed highlights the error seen.

XCode and the XCode command line utilities are installed and the root user is enabled.

The key thing is that I can't make changes as root as root doesn't seem to have the right permissions. I've tried chown'ing and chmod'ing anything in /etc and /etc/local but I always get "Operation not permitted"

I've followed all the normal resolutions. Disk Utility -> Repair Permissions, Enable/Disable the root user, change the root user p/w, power-cycle the machine.

bash-3.2$ chmod 775 base.tar
chmod: Unable to change file mode on base.tar: Operation not permitted
bash-3.2$ ls -la
total 129744
drwxr-xr-x  10 root  admin       340  8 Apr 15:17 .
drwxr-xr-x   3 root  admin       102  8 Apr 12:38 ..
-rw-r--r--   1 root  admin   9453803  8 Apr 12:30 PortIndex
-rw-r--r--   1 root  admin       512  8 Apr 12:31 PortIndex.rmd160
drwxr-xr-x  24 root  wheel       816 31 Jan 17:30 base
-rw-r--r--   1 root  admin   3594240  8 Apr 15:01 base.tar
-rw-r--r--   1 root  admin       512  8 Apr 15:01 base.tar.rmd160
drwxr-xr-x  51 root  wheel      1734  8 Apr 15:17 ports
-rw-r--r--   1 root  admin  53360640  8 Apr 15:01 ports.tar
-rw-r--r--   1 root  admin       512  8 Apr 15:01 ports.tar.rmd160
bash-3.2$ whoami
root
bash-3.2$ 

At this stage I'm considering re-installing but would prefer to fix this rather than start again.

Output of id is :

uid=504(root) 
gid=0(wheel) 
groups=0(wheel),
402(com.apple.sharepoint.group.1),
401(com.apple.access_screensharing),
1(daemon),
2(kmem),
3(sys),
4(tty),
5(operator),
8(procview),
9(procmod),
12(everyone),
20(staff),
29(certusers),
33(_appstore),
61(localaccounts),
504(admin),
98(_lpadmin),
100(_lpoperator),
204(_developer),
403(com.apple.sharepoint.group.2)

output of dscl . read '/Users/root'

bash-3.2$ dscl . read '/Users/root'
AppleMetaNodeLocation: /Local/Default
GeneratedUID: FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000
NFSHomeDirectory: /Users/root
Password: ********
PasswordPolicyOptions:
 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>failedLoginCount</key>
    <integer>0</integer>
    <key>failedLoginTimestamp</key>
    <date>2001-01-01T00:00:00Z</date>
    <key>lastLoginTimestamp</key>
    <date>2001-01-01T00:00:00Z</date>
    <key>passwordLastSetTime</key>
    <date>2013-05-27T07:39:18Z</date>
</dict>
</plist>

PrimaryGroupID: 0
RealName: root
RecordName:
 root
 BUILTIN\Local System
RecordType: dsRecTypeStandard:Users
SMBSID: S-1-5-18
UniqueID: 504
UserShell: /bin/bash
share|improve this question
    
One thing to try would be booting from the restore partition (or, DVD, if your computer is 10.6 or older), and running disk utility to repair permissions on the main partition. –  Kent May 27 '13 at 8:26
    
Also, make sure the permissions on /etc/sudoers is -r--r----- (440). –  Kent May 27 '13 at 8:27
    
The shell doesn't seem to recognize your root-ness, hence the $ instead of #. What's the output of id? –  Daniel Beck May 27 '13 at 8:55
    
comments taken onboard and question amended with output –  Keith Lynch May 27 '13 at 9:05
    
Why does root have uid 504 on your system? –  patrix May 27 '13 at 9:20

1 Answer 1

up vote 2 down vote accepted

Somehow you created another user named root who does not have root permissions (which might have overridden the default root account), or changed root's user ID. root should have UID 0. Maybe the instructions for Enable/Disable the root user, change the root user p/w you followed were incorrect.

You can try specifying UID 0 explicitly by running sudo as follows:

sudo -u '#0' <command>

dscl is the command-line utility for managing user accounts (among other things). Output of dscl . read '/Users/root' should look similar to this by default:

AppleMetaNodeLocation: /Local/Default
GeneratedUID: FFFFEEEE-DDDD-CCCC-BBBB-AAAA00000000
NFSHomeDirectory: /var/root
Password: *
PrimaryGroupID: 0
RealName:
 System Administrator
RecordName: root
RecordType: dsRecTypeStandard:Users
SMBSID: S-1-5-18
UniqueID: 0
UserShell: /bin/sh

You could try to re-set everything by running dscl . change '/Users/root' 'UniqueID' '504' '0', and hope that sudo works for this. This could break even more though – I've only tested it with the UserShell key.

share|improve this answer
    
thanks for this. I wasn't able to change with dscl but went through directory utility instead. Got the gist of what you were suggesting. My root user is now '0'. The dscl output has some kerberos info but I assume you filtered this out from your post for security reasons? –  Keith Lynch May 27 '13 at 11:30
    
I filtered nothing, but additional entries might not be a problem -- it looks like the UID is the important issue here. It looks like that line might be the hash of the password (my root doesn't have that). –  Daniel Beck May 27 '13 at 11:31
    
OK. I've removed some of the superfluous info but as you say it doesn't make much odds. The key thing here was definitely the UID. Anyway thanks again for the help. Much appreciated. I'm a happy user again. Was really fearing having to re-install –  Keith Lynch May 27 '13 at 12:00
    
Thanks for this, it fixed my issue. For those just copy/pasting the command, don't forget to change '504' with the actual current id of the root user. Also, don't forget it's UniqueID and not UniqueId (that typo cost me 10 minutes of confusion) –  maxmackie Jul 23 at 0:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.