Revision of GMT timezone problem in Mac OS X from 3 January, 2008 - 18:21

I have had an odd problem with my timezone settings on my Mac over the last few days, I went on holiday recently and (of course) I took my Mac, when I went to change the timezone I discovered that the settings would not "stick", and instead of going back to the timezone I started with, actually went to GMT.

In any case, I worked out what the problem was, so I thought I should post the solution in case anyone else has runs across the same thing.

 

The cause of the GMT timezone problem in Mac OS X

In a nutshell the problem was being caused by /etc/localtime having the wrong permissions. It was pointing to the correct timezone, but the permissions were such that my user did not have access to the file.

At some point (I have no idea when) my default umask (the NSUmask) got changed from 18 (0x12 hex, 022 octal) to 63 (0x3f hex, 077 octal). This effectively means that, by default, files and links that get created will be read/write for the owner only.

Normally this shouldn't be a problem, but it can be when files created by one user on your machine need to be accessed by other users. In this case "System Preferences" was creating a new symbolic link (/etc/localtime) to the correct timezone file as user 'root' but the link didn't allow anyone (i.e. me) access to the linked to file, even though the permissions on the timezone file were fine.

Fixing the problem therefore is a simple three step process:

  1. Correct the default umask (NSUmask in this case)
  2. Logout and log back in
  3. Replace the timezone symbolic link

 

Fixing the GMT timezone problem step-by-step in Mac OS X

Step 1: Correct the default umask

Open up a terminal window and enter the following command:

sudo defaults write /Library/Preferences/.GlobalPreferences NSUmask 18


You will be prompted for your password.

NB: Don't be tempted to use the '-g' or '-globalDomain' switch in place of the specific domain above, they appear to be different. If you did not understand that last sentence then feel free to ignore it.

 

Step 2: Logout and log back in

Logout of your current session (Apple menu -> Log Out [username]), and then log back in. You may wish to save any unsaved documents and close any open applications as they will be shut down by the log out.

 

Step 3: Replace the timezone symbolic link

Changing the default umask (step 1) fixed the basic problem but the symptoms will remain until you replace the incorrect link as well.

 

Step 3a: Removing the timezone file

Open a terminal window and enter the following command:

sudo rm /etc/localtime


This will delete the problematic symbolic link, if the command succeeds there will be no message.

Close the terminal window.

 

Step 3b: Reset the timezone

In the system preferences, go into "Date and Time" and select your correct timezone.
NOTE: The "Closest City" drop down will show "GMT" initially, and if you attempt to use the drop down it will be empty. To have the drop down list correctly populated click on the world map first - this will force the drop down to become populated.

Close the system preferences, when you do this the symbolic link /etc/localtime will be created for you.

The time in the menu bar should now show the correct time, and if you go back into the System Preferences the correct timezone should be shown.