chflags

Issues…

I’ve long held that despite “having more computer issues than one should ever have”, all of my issues are either self inflicted to discover how to recover from such an event, or, the are the truly random and annoying things that I wonder how folks ever figure out.

Such is my experience with chflags.

The symptom

My Mac Pro has a zpool with a couple filesystems on it. It also happens that I have reloaded my Mac Pro twice in as many days while playing around with Mac OS X Server (which I gave me grief, the least of which was chime to login screen went from no more than 20 secs to 5-10 minuets.) and then back to Mac OS X 10.5.5 doing a fresh install using the restore DVD that came with my “late-2008″ MacBook Pro (which oddly enough the “About this Mac” window still shows a different build despite identical installs from the same media).

So the filesystem has seen a lot of rather wild and carefree abuse such as:

sudo chown jason:staff /Volumes/Indigo/*
sudo chmod -R 775 /Volumes/Indigo/*

Strange thing is, along the way. I got locked out of one of the directories on the drive. Now mind you, “directory” might be a bad term, as it really is just the ZFS mountpoint for a sub-filesystem. If you are familiar with ZFS then the following will explain my setup.

Indigo                              961G   661G   658G  /Volumes/Indigo
Indigo/Aperture                    97.2G   661G  97.2G  /Volumes/Indigo/Aperture
Indigo/Backups                     14.6G   661G   447M  /Volumes/Indigo/Backups
Indigo/Backups/Jasons-MacBook-Pro   381M   661G   381M  /Volumes/Indigo/Backups/Jasons-MacBook-Pro
Indigo/Backups/ShilohG4             423M   661G   423M  /Volumes/Indigo/Backups/ShilohG4
Indigo/Backups/jrm08               15.4M   661G  15.4M  /Volumes/Indigo/Backups/jrm08
Indigo/Backups/macpro              7.70G   661G  7.70G  /Volumes/Indigo/Backups/macpro
Indigo/Backups/powerbookg4         5.51G   661G  5.51G  /Volumes/Indigo/Backups/powerbookg4
Indigo/Backups/soekris              170M   661G   170M  /Volumes/Indigo/Backups/soekris
Indigo/Projects                    23.6M   661G  23.6M  /Volumes/Indigo/Projects

What does an ls show?

drwxr-xr-x  50 jason  staff   1.7K Oct 27 21:37 localdir
drw-r--r--   2 jason  staff    68B Oct 29 00:04 Aperture

Hmm, so the permissions are just wrong?
well…

Let’s try to make it right

I only showed above an example of what it looked like, but in my case, all of my ZFS sub-filesystems somehow had their permissions changed to something akin to 0644. The “obvious” fix is to chmod it and everything will be fine right? Ok, lets try that…

$chmod 0755 /Volumes/Indigo/Aperture
chmod: /Volumes/Indigo/Aperture/: Operation not permitted

Hmm, thats weird… oh well big deal if I am root right?

$sudo chmod 0755 /Volumes/Indigo/Aperture
chmod: /Volumes/Indigo/Aperture/: Operation not permitted

Snap.

Yeah. Maybe this was clear as day to you before reading this entry what I would have to use to solve my problem, but this one took a while. Not only that, but I ran into this a month or two ago, and then pretty much forgot about this issue. Hence, I’m writing this so that I don’t forget again. (or at least have something to refer back to)

The Fix

chflags

You knew that was coming, but how do you use it? Well, the man page will give you some detail but the jist of it is, that you can set flags on files and directories, one of which is a “unchangeable” flag. This flag somehow was getting set after my permission got messed up, and wasn’t being affected by anything that I was trying, terminal and finder.

To set the “unchangeable” flag type:

chflags uchg [filename]

And to remove the “unchangeable” flag type:

chflags nouchg [filename]

Once I unset the “unchangeable” flag I had no issues changing the permissions. Hard to find other folks who have seen this… just hope if you found this you didn’t have to search too hard, or maybe even better yet, maybe this is just a bug with the beta Mac OS X ZFS implementation that has been long since fixed.

What I learned

This goes back to what I started this entry with. My computers will be broken a lot, not because I lack the skills to keep them running all the time, rather I learn nothing with perfect computers (thou I do need something that works despite my best efforts so I use Mac OS X of course. Windows does all the breaking for me and that is just no fun! :P keep in mind I wanted to be a MCSE back in the day… anyhow…)

If nothing else, I now know how to change those flags, as well as other things I tried along the way that although they failed to fix my issues. For example I now know how to use chmod to remove all access control lists from files. I also can set the uchg flag to the GeekTook preference file because although I want most of my preferences to sync, I don’t want that particular one to sync, so if I lock it on each machine, i never have to worry about it changing.

Quite an interesting learning experience indeed… maybe sometime soon I’ll post on how I automate my EC2 recording and s3syncing and all things Amazon Web Services related… or not, depending on how much math and physics homework I have.

Till later!