Technical Notes |
|
Many Reflection products, such as Reflection NFS, Reflection X, and Reflection for UNIX and OpenVMS, provide connectivity to UNIX host computers. This technical note describes UNIX file and directory permissions and how file and directory ownership interacts with these permissions. This note also illustrates how an exports file on a UNIX host computer can affect client access to NFS file systems.
Note: The Reflection NFS Client standalone product is also included as a component of several Reflection products. For details, refer to Technical Note 3000.
Access to a file or directory is determined by comparing three pieces of information:
This technical note explains each of these items and then demonstrates how to combine this information to determine access. An additional section is provided to explain file and directory access using NFS.
Each user account on a UNIX host computer has a unique user name and primary group name. To identify your user name and primary group name, connect to your UNIX host using a terminal or terminal emulator and type id at the host prompt.
The gpck and pwck UNIX utilities will detect problems in the /etc/groups and /etc/passwords files respectively. Use the hosts man pages to determine how to run gpck and pwck.
Example syntax for a Sun host: /usr/sbin/grpck /etc/group
Access to a specific file or directory depends on your category of ownership. There are three possible categories:
Your user and group names are used to determine which category of ownership is applicable for determining access to a particular file or directory. Comparing user and group names to file and directory ownership is explained below in "Determining Access to a File or Directory."
Every file and directory has read, write, execute, or no permissions for owner, group, and other. The permissions are listed from left to right when you do a full file or directory listing.
The following diagram shows a typical listing for a file on a UNIX host computer:
The first character indicates whether this is a file (-) or a directory (d). The next nine characters can be examined in groups of three. The first set of three characters corresponds to the owner permissions, the second set corresponds to the group permissions, and the third set shows the permissions for anyone who is not the owner or a group member (other).
Both files and directories can be assigned read (r), write (w), execute (x), or no (-) permissions. The meaning of these permissions, however, is different for files and directories, as is shown in the following table:
| Permission Type |
File Access |
Directory Access |
| r |
User can open and read the file. |
User can do a directory listing and can read files in the directory. |
| w |
User can modify the contents of the file. |
User can create, modify, and delete files in the directory. |
| x |
User can execute the file (Only applies to binary files and scripts). |
User can change directories (cd) into this directory. |
| - |
User does not have the type of access replaced by this character (either read, write, or execute). |
User does not have the type of access replaced by this character (either read, write, or execute). |
To determine whether you have access to a specific file or directory, follow these steps:
$ -rwxr-x--- 1 bobr sales 1422 Apr 7 11:25 /mrktg/file.txt| Owner |
Group |
Other |
| (bobr) |
(sales) |
(all other users) |
| rwx |
r-x |
--- |
In the following example, user bobr needs to determine if he has access to the hope.txt file in the /mrktg/june directory.
User name: bobr
Group name: mgr
$ -rwxr-x--- 1 bobr sales 1422 Apr 7 11:25 /mrktg/hope.txt| Owner |
Group |
Other |
| (bobr) |
(sales) |
(all other users) |
| rwx |
r-x |
--- |
In the following example, user mattg needs to determine if he has access to the north directory.
User name: mattgGroup name: sales$ drwxr-xr-x 13 bobr sales 3072 Jan 2 9:13 north| Owner |
Group |
Other |
| (bobr) |
(sales) |
(all other users) |
| rwx |
r-x |
r-x |
The user's access to a file is based on both the file and directory permissions, and the most restrictive privileges take precedence.
For example, user bobr is trying to access notes.txt in the north directory. Here are the relevant file and directory permissions:
-rwxr-x--- 1 bobr sales 1422 Apr 7 11:25 /sales/north/notes.txtdr-xr-xr-x 13 bobr sales 3072 Jan 2 09:13 northThis information shows that bobr is the owner of the file and the directory. He has rwx permissions to the file, and r-x permissions to the directory in which the file resides. Therefore, his combined access for the notes.txt file will be r-x.
If you are accessing UNIX host files from an NFS client or gateway, such as Reflection NFS, there may be additional restrictions placed on the host resources. NFS servers use an exports file to limit access to specific file systems (directories) and users.
In order to access host file systems or printers using an NFS client, the file systems must be exported. To export a file system or printer, it must be added to the host /etc/exports file.
The exports file allows the administrator to control the following access:
Note: Though generally similar, the exports file and access-control parameters and switches used in the exports file vary from host to host. For example, Sun UNIX host computers use an /etc/dfs/dfstab file for controlling NFS exports. Check your UNIX host computer man pages for host-specific NFS exports file location and configuration information.
These are common switches and access parameters in the /etc/exports file:
| Switch |
Function |
| -rw=[user,user,...] |
Provides read, write access to only the listed users, read-only access to all other users |
| -ro |
Provides read-only access to the file system |
| -access=[user,user,...] |
Provides access to only the listed users |
| -root=[user,user,...] |
Provides root access to the listed users |
These are examples of some possible exports settings on an RS6000 host computer:
| File System and Access Switch |
Resulting Access |
| /usr1/south |
All users, with no restrictions |
| /usr1/north -access=bobr |
User bobr only (denies access to all other users) |
| /usr1/west -ro |
Read-only access to all users |
If a user is attempting to access a file on a UNIX host from a remote NFS client, access to that file will be determined by a combination of individual permissions. When combining the file, directory, and /etc/exports permissions, the most restrictive rights apply to the file.
The following example illustrates combined permissions for the user bobr, who is attempting to access the estimates.txt file in the year directory:
| bobr group name: |
sales |
| File permissions: |
-rwxr-x--- 1 bobr jefe 6145 Nov 4 8:14 /year/estimates.txt |
| Directory permissions: |
dr-xr-xr-- 13 lindac sales 7696 Jan 17 09:13 year |
| /etc/exports entry: |
/year -access=bobr,charleso |
In this example, bobr is the owner of the estimates.txt file. The owner has rwx permissions.
The directory containing estimates.txt (/year) is owned by lindac, but has sales as the group owner. User bobr is a member of the sales group, so his access to the /year directory is determined by the group permissions. In this case, the directory group permissions are r-x.
The combined permissions for bobr are r-x.
For NFS access, it is necessary to check the /etc/exports file to see if the year directory is being exported, and whether it has any restrictions for access. In this case, the /year directory is being exported with access for users bobr and charleso only.
User bobr, therefore, has r-x (read and execute) access to the estimates.txt file in the year directory using NFS. The user can cd into this directory, and can read and execute files within the directory. However, he cannot delete, rename, or create any files in this directory.