Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)

Recognizing Permission Problems

Ninety percent of day-to-day problems in running Unix systems are permissions- related . Most often, some process tries to write to a file or directory that it doesn't have permission to write to. Maybe it did yesterday , but someone accidentally or carelessly changed it, and then something stopped working.

Permission problems show up in so many ways that it is not reasonable to try to list them here, but there are a few rules you can follow to spot permission problems.

Often the first sign is an error message containing the words "Permission denied ." Sometimes it is accompanied by more informationfor example,

/usr/local/bin/script.sh: permission denied: /etc/foo [3]

This is telling you that line 3 of the script /usr/local/bin/script.sh failed because it did not have enough permission to do something with /etc/foo . You have to look inside the script to see what exactly was going on, but you have a good place to start.

Some things to keep in mind:

1.

To create a new file, rename a file, delete a file, or change a file's permissions, the process must have write permission in the directory where the file is being created.

2.

To change an existing file, you must have write permission on the file.

3.

To cd into a directory, the process must have execute permission on the full path of the directory. So to cd into /Users/ vanilla /Sites/images/big_images , the processes doing the cd must have execute permission on the following:

/ /Users /Users/vanilla /Users/vanilla/Sites /Users/vanilla/Sites /images /Users/vanilla/Sites /images/big_images

4.

To list the contents of a subdirectory, you must have read permission for it, as well as permission to cd into the directory where it's stored. So to list the contents of /Users/vanilla/Sites/images/big_images , you must be able to cd into /Users/vanilla/Sites/images and have read permission on big_images. You do not need to be able to cd into a directory to list its contents.

To correct a permission problem:

1.

Write down the permissions of the files or directories you think should change.

You might try redirecting the output of ls -l into a file, for example:

ls -l bad_file > permission_save

2.

Change the permissions to what you think will fix the problem.

3.

Test the fix.

If the fix doesn't work, change the permissions back to what they started as, and think through the problem again. Go back to step 2. Lather, rinse, repeat.

Using ACLs

Starting with version 10.4 Mac OS X supports a form of permissions called an Access Control List (ACL). ACLs are special files, normally hidden from view, that allow you to specify in excruciating detail the kinds of access that users have to a file or directory. For example, using an ACL, you can give permission to append to a file but not to delete it, or to delete or create a file, but not to alter an existing file. And you can give these permissions separately to each user or group in the ACL.

ACLs are not enabled by default in the regular version of Mac OS X, but they are enabled in Mac OS X Server (see www.apple.com/server/documentation). There is also an article on understanding ACLs at www.afp548.com/article.php?story=20050506085817850. Or, check out Apple Training Series: Mac OS X Server Essentials, soon to be published by Peachpit Press, for much more about ACLs than we are able to cover here.

To enable ACLs:

1.

sudo fsaclctl -a -e

Enter your password if asked for it.

You will see a line of output for each filesystem (volume, partition) you have mounted, with at least the root filesystem being listed:

ProcessVolume: processing /

Tips

To add an ACL entry:

Tips

To remove an ACL entry:

To alter an existing ACL entry:

Категории