21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

and a saved user ID. * The effective user ID is the user ID used for most permission<br />

checks. The real user and saved user IDs are used primarily for determining whether<br />

a process can legally change its effective user ID (see Recipe 1.3).<br />

In addition to user IDs, each process also has a group ID. As with user IDs, there are<br />

actually three group IDs: an effective group ID, a real group ID, and a saved group<br />

ID. Processes may belong to more than a single group. The operating system maintains<br />

a list of groups to which a process belongs for each process. Group-based permission<br />

checks check the effective group ID as well as the process’s group list.<br />

The operating system performs a series of tests to determine whether a process has<br />

permission to access a particular file on the filesystem or some other resource (such<br />

as a semaphore or shared memory segment). By far, the most common permission<br />

check performed is for file access.<br />

When a process creates a file or some other resource, the operating system assigns a<br />

user ID and a group ID as the owner of the file or resource. The user ID is assigned<br />

the process’s effective user ID, and the group ID is assigned the process’s effective<br />

group ID.<br />

To define the accessibility of a file or resource, each file or resource has three sets of<br />

three permission bits assigned to it. For the owning user, the owning group, and<br />

everyone else (often referred to as “world” or “other”), read, write, and execute permissions<br />

are stored.<br />

If the process attempting to access a file or resource shares its effective user ID with<br />

the owning user ID of the file or resource, the first set of permission bits is used. If<br />

the process shares its effective group ID with the owning group ID of the file or<br />

resource, the second set of permission bits is used. In addition, if the file or<br />

resource’s group owner is in the process’s group membership list, the second set of<br />

permission bits is used. If neither the user ID nor the group ID match, the third set of<br />

bits is used. User ownership always trumps group ownership.<br />

Files also have an additional set of bits: the sticky bit, the setuid bit, and the setgid<br />

bit. The sticky and setgid bits are defined for directories; the setuid and setgid bits<br />

are defined for executable files; and all three bits are ignored for any other type of<br />

file. In no case are all three bits defined to have meaning for a single type of file.<br />

The sticky bit<br />

Under normal circumstances, a user may delete or rename any file in a directory that<br />

the user owns, regardless of whether the user owns the file. Applying the sticky bit to<br />

a directory alters this behavior such that a user may only delete or rename files in the<br />

directory if the user owns the file and additionally has write permission in the direc-<br />

* Saved user IDs may not be available on some very old Unix platforms, but are available on all modern<br />

Unixes.<br />

Understanding the Unix Access Control Model | 39<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!