| United States-English |
|
|
|
![]() |
HP Servers and Workstations: Managing Systems and Workgroups > Chapter 8 Administering a System: Managing
System SecurityManaging Access to Files and Directories |
|
On a traditional UNIX system, file access is controlled by granting permissions to the file owner, the file’s group, and all other users. These can be set with the chmod command and displayed with the ll (ls -l) command. (See chmod(1) and ls(1). Access Control Lists (ACLs) give you a more precise way to control access to files than you have with traditional UNIX file permissions. ACLs allow you to grant or restrict file access in terms of individual users and specific groups, in addition to the traditional control. Both HFS and JFS file systems support ACLs, but they use different mechanisms and have somewhat different semantics.
HFS ACL permissions are set with the chacl command and displayed with the lsacl command. (See chacl(1) and lsacl(1).) The chacl command is a superset of the chmod command. Any specific permissions you assign with the chacl command are added to the more general permissions assigned with the chmod command. The simple form of the chacl command is: chacl 'user.group operator mode' filename... where:
The apostrophes (') are used to protect spaces and any special shell characters. When a file has ACLs, the ll command displays a + after the permission string. If a user.group matches more than one HFS ACL entry, the more specific entry takes precedence. See Example 8-2 “Multiple HFS ACL Matches”. Example 8-1 Creating an HFS ACL Suppose you use the chmod command to allow only yourself write permission to myfile. (This also deletes any previous HFS ACLs.)
The lsacl command displays just the default (no ACL) values, corresponding to the basic owner, group, and other permissions. Now you use chacl to allow your manager to have read and write access to the file.
Notice two things: the ll permissions display has a + appended, indicating that ACLs exist and the ll permissions string did not change. The additional entry in the lsacl display specifies that user naomi in group users has read and write access to myfile. Example 8-2 Multiple HFS ACL Matches If a user’s user.group combination matches more than one ACL entry, the most specific entry takes precedence. Using file myfile,
add a write-only entry for user naomi.
Now, user naomi has write access to file myfile, using the ACL defined for naomi.%, but does not have read access to the file because naomi.% takes precedence over the ACLs defined for %.users and %.%. lsacl displays the HFS ACLs in decreasing order of specificity. That is, permission matches are attempted from left to right.
This section describes JFS Access Control Lists and how to use them.
A JFS ACL contains one-line entries naming specific users and groups and indicating what access is granted to each. The presence of a JFS ACL also changes the meaning of the group permission bits displayed using the ls -l command. There are always at least four entries in a JFS ACL: a user entry, a group entry, a class entry, and an other entry. When a JFS ACL contains only these four entries, the permissions it grants are exactly the same as the permissions represented by the standard UNIX system permission bits. While having such an ACL (we will call it a minimal JFS ACL) provides no greater functionality than the permission bits alone, we will start by describing a minimal JFS ACL, and augment it with additional entries to show how the mechanism works. The first entry in a minimal JFS ACL indicates the permissions that the owner of the file gets, and maps directly to the owner permission bits. Because it applies to the owner of the file, no indication of the user’s name is needed. An ACL entry that grants read and write access to the file’s owner would look like this:
The second and third entries in a minimal ACL specify the permission granted to members of the file’s owning group; the permissions specified in these entries are exactly equal in a minimal ACL. For example, ACL entries granting read-only access to the file’s owning group would look like this:
The class and group entries will be described at length later in “JFS ACL Class Entries”. The fourth and last entry in a minimal JFS ACL is a catch-all entry that specifies the permissions for anyone who isn’t granted or denied permission by any other entry. An other entry that denies access to all users not the owner of the file nor in the file’s owning group would look like this:
The minimal ACL described above would look like this in its entirety: The permission bits displayed by ls -l for this file would look like this:
In the case of a minimal JFS ACL, there is a clear correspondence between the ACL entries and the permission bits. The next section describes how additional JFS ACL entries affect file access and the interpretation of the permission bits. If you want to specifically grant and/or deny access to specific users and/or groups on the system, you can add up to 13 more user and group entries to the four minimal entries described in the previous section. Additional user entries grant and deny access to specific user IDs on your system.For example, the following entry in the ACL of a file grants read, write, and execute access to a user logged in as boss:
Similarly, additional group entries grant and deny access to specific group IDs on your system. For example, an ACL with the following entry would deny access to a user in the group spies:
In a file with a minimal ACL, the owning group and class ACL entries are identical. However, in a file with additional entries, the owning group and class ACL entries are distinct. The owning group entry grants permissions to a specific group: the owning group. The class entry is more general; it specifies the maximum permissions that can be granted by any of the additional user and group entries. If a particular permission is not granted in the class entry, it cannot be granted by any ACL entries (except for the first user (owner) entry and the other entry). Any permission can be denied to a particular user or group. The class entry functions as an upper bound for file permissions. When an ACL contains more than one group and/or user entry, the collection of additional user and group entries are referred to as the group class entries, since the effective permission granted by any of these additional entries is limited by the class entry. When a file has a minimal ACL, the owning group and class ACL entries are identical, and chmod affects both of them. However, when a file contains additional, optional entries in the ACL:
To illustrate the function of the JFS ACL class entry, we will show how chmod and setacl affect a file with a minimal JFS ACL as well as a file with group class entries.
Consider a file, exfile, with read-only (444) permissions and a minimal JFS ACL. ls -l shows the permissions for exfile as:
getacl lists the following output for exfile: Example 8-4 getacl Output for exfile, a Minimal JFS ACL
Using chmod to add write permissions to exfile changes both the owning group and the class ACL entries: Example 8-5 getacl Output for exfile, Showing Effect of chmod
Now we add some additional user and group entries, which will affect the class ACL entry, but not the owning group entry. The first setacl command below grants read-only permission to user guest; the other ACL entries are unaffected. However, when we grant read-execute permissions to the group dev, the upper bound on permissions (the class entry) is extended to include execute permission. Example 8-6 getacl Output for exfile, Showing Effect of setacl
Now if we use chmod to remove write and execute permission from “group”, we actually reduce the class permissions to read-only. The owning group permissions, while unchanged, are effectively reduced to read-only as well. Example 8-7 getacl Output for exfile, Showing Effect of chmod on Class Permissions
Note that the other permissions are unchanged. The class entry does not limit the access that can be granted by the first user (owner) entry or the other entry. Now ls -l will list the permissions of exfile as follows. The + at the end of the permissions string indicates that there is an ACL for the file. Often, you will want all the files created in a directory to have certain ACL entries. For example, you might want to allow another person to write to any file in a directory of yours where the two of you are working on something together. You can put an ACL entry granting the desired access on every file in the directory, but every time you create a new file you will have to add that entry again. Using default ACL entries, you can get the system to do this for you automatically every time a file is created. A default ACL entry looks like this:
It can be placed only on a directory, never on an ordinary file. It never has any influence on what access is granted to a user for the directory it is placed on. All it does is cause the specified entry to be included in the ACL of any file created in the directory. If the newly created file is a directory, the default ACL entries have two effects. First, the corresponding non-default ACL entries are created, so that the desired permissions are granted and denied for the directory, just as for any file created in the directory. Second, the default entries themselves are copied, so that the new subdirectory has the same default ACL as the parent directory. For example, if you want any files created in the directory projectdir to be readable by certain users, you could create the appropriate default entries as shown below. Example 8-9 A JFS ACL with Default Entries
With these entries in place, any new file created in the directory projectdir could have an ACL like that shown below for planfile. The entries for user:boss, user:jjones, and group:dev are generated from the default entries on the projectdir directory. Example 8-10 Effect of Default Entries on a New File
If the newly created file is a directory, the same ACL entries are generated, but in addition the default entries themselves are also placed in the ACL, as shown in docdir, below. Whenever a file is created on a VxFS version 4 file system, the system initializes a minimal JFS ACL for the file, containing a user entry for the owner permissions, a group entry for the owning group permissions, a class entry for the owning group permissions, and an other entry for the other group permissions. Additional entries may be added by the user, or as a result of default entries specified on the parent directory. The getacl command reports the entries in the ACL. As indicated, each ACL has at least four entries, one each corresponding to the file mode permissions for owner, group, class, and other. File permission bits for user and group are translated into special cases of these entries:
In an ACL, there must be one each of these special user and group entries. There may be any number of additional user entries and group entries, but these must all contain a user ID or group ID, respectively. There is only one other entry in an ACL, representing the permission bits for permissions to be granted to other users. The following is an example of the output of the getacl command for a file named junk owned by user1 in group1 whose permission mode bits are -rw-rw-r--: Example 8-12 Example getacl Output for a Minimal JFS ACL
If setacl is used to give read-write permission to user2 and user3 and read-only permission to group2, getacl would produce the following output: Example 8-13 Example getacl Output after Additions to the ACL
Note that the class entry changed to include execute permission when the group2 entry was given execute permission. getacl shows effective permissions when they are more restricted than the permissions that specifically granted in the ACL. For example, if we use chmod to deny execute permissions to the group class, some ACL entries will show an #effective permission that differs from the ACL entry: Example 8-14 Example getacl Output Showing Effective Permissions
Because chmod affects the class ACL entry and not the owning group entry, chmod may be used to deny access to all additional user and group entries without the need to reset each entry with setacl. If you are user1 (the owner of the file junk used in examples earlier in this section), you can provide read access for junk to an additional user by adding an entry to the ACL naming that user and specifying read access. You do this with the setacl command. For example, the following command gives user boss read-only access to the file:
The -m (modify) option indicates that you are adding or changing an entry to the ACL. You can add group-specific entries in just the same way. For example, to grant read and write access to everyone in the group dev, type the following:
The -m option can be used to change an existing entry as well as add a new one. If an entry already exists for the specified user or group, the permissions for that entry are set to the values specified on the command line. The -d option deletes an entry. With -d, you do not specify any permissions in the ACL entry. For example, the following command deletes the entry for the group dev:
You may add, change, or delete any number of entries on the same command line with the -m and -d options. You can either supply a comma-separated list of entries to an option, or repeat the option with additional entries. For example the following two command lines have the same effect:
You can also combine the -m and -d options on the same command line. If you are adding or changing several entries, you will probably want to use a different procedure. You can save the ACL to a file, edit it, adding, changing, or deleting entries to produce whatever ACL you want, and then apply this new ACL to the file. For example, you could save the ACL to a file with this command:
Then you could edit it so that it appeared as below. Example 8-15 A Complex JFS ACL
This ACL can now be applied to the file by using the -f option of the setacl command as follows:
In this example, several changes have been made. While before the ACL entries only granted access to people, now they are used to deny access as well. Note specifically the entries for user user4 and group group4. Normally, setacl recalculates the class entry so as to ensure that permissions granted in the additional ACL entries will actually be granted.If the -n option is specified, the class entry is not recalculated; the existing value is used. This means that some permissions granted by the ACL entries will not be granted in practice. For example, returning to our exfile example, when it was a minimal ACL with read-write permissions across the board:
Suppose we use setacl -n to add read-execute permissions to group dev as follows: Example 8-16 Effect of setacl -n, Showing Effective Permissions
The group dev ACL entry is added as specified, but execute permission will not actually be granted. Execute permission is denied by the class entry, and the class entry was not recalculated because -n was specified. If -n was not used, class would have been reset to class:rwx, and the effective comment would not be there. JFS ACLs adhere to the POSIX ACL standard. JFS ACLs differ from HFS ACLs in both format (internal and external) and functionality. Functional differences between JFS and HFS ACLs include:
The following table lists equivalent commands and functions for JFS ACLs and HFS ACLs. Table 8-1 HFS and JFS ACL Equivalents
ACLs are not visible on remote files by Network File System (NFS), although their control over access permissions remains effective. Individual manpage entries specify the behavior of the various system calls, library calls, and commands under these circumstances. Use caution when transferring a file with optional entries over a network, or when manipulating a remote file, because optional entries are deleted with no indication. The default umask setting in a standard system is octal 000. This should be changed to u=rwx,g=rx,o=rx (or octal 022). This means that all directories created will have a default permission mode of 755, granting access of drwxr-xr-x. All files created will have the default permission mode of 644, granting access of -rw-r--r--. See umask(1). If a directory is writable in a category (either through standard permissions or ACLs), anyone in that category can remove its files, regardless of the permissions on the files themselves. There are two ways to protect against unwanted deletions:
These guidelines should be followed to protect user accounts:
Access to all devices in your system is controlled by device special files, which enable programs to be device independent. These files have been shipped with permission settings that enable proper use and maximal security. If you install any other special files, refer to insf(1M) for the correct permission settings. Since device special files can be as vulnerable to tampering as any other file, observe the following precautions:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||