Previous Table of Contents Next

Searching for Files with Special Permissions

You should monitor your systems for any unauthorized use of the setuid and setgid permissions to gain superuser privileges. A suspicious listing would be one that grants ownership of a setuid or setgid program to a user other than bin or sys.

You can use the permissions (-perm) option to the find command to search for files with setuid, setgid, or sticky bit permissions. Use the following steps to search for files with setuid permissions:

1.  Become superuser.
2.  Type find <directory> -user root -perm -4000 -print and press Return.

The following example lists the system files that have setuid permissions.

castle% find / -user root -perm -4000 -print

Access Control Lists (ACLs)

Access Control Lists (ACLs, pronounced “ackkls”) can provide greater control over file permissions when traditional UNIX file permissions are not enough. UNIX file protection provides read, write, and execute permissions for three user classes: owner, group, and other. An ACL provides better file security by enabling you to define file permissions for the owner, owner's group, others, specific users, and groups. It also enables you to define default permissions for each of these categories.

For example, you might have two groups that need permission to access a file, one to read it and one to write to it. Alternatively, you might have a file that you wanted everyone in a group to be able to read, so you would give group read permissions on that file. Suppose that you want only two people in the group to be able to write to that file. With standard UNIX permissions, you cannot give write permission to only two members of a group. You can, however, set up an ACL for that file to grant only two people in the group write permissions on that file.

ACLs are extensions to standard UNIX file permissions. The ACL information is stored and associated with each file individually.

ACL Commands

You define an ACL for a file or directory by using the ACL commands and options listed in Table 18-8.

Table 18-8 ACL Commands and Options

Command/Option Description
getfacl Displays ACL entries.
-a Displays the filename, owner, group, and ACL of the file.
-d Displays the filename, owner, and group of the file. The information is displayed even if the file does not have an ACL.
setfacl Sets, adds, modifies, and deletes ACL entries.
-s acl_entries Sets the ACL for the file, removing all old entries and replacing them with the newly specified ACL.
-m acl_entries Adds one or more new ACL entries to the file or modifies one or more existing ACL entries for the file. If an entry already exists, the specified permissions replace the current permissions. If no entry exists, a new entry is created.
-d acl_entries Deletes one or more entries from the file. You cannot delete entries for the file owner, the owning group, and other. Note that deleting an entry does not necessarily have the same result as removing all permissions from the entry.
-f acl_file Specifies a file containing the ACL entries to be used as arguments to the setfacl command.
-r Recalculates permissions for the ACL mask. Permissions specified in the mask are ignored and replaced by the maximum permissions needed to give access to any additional user, owning group, and additional group entries in the ACL.

Each ACL entry consists of the following fields, which are separated by colons:

<entry-type>:[<UID>] | [<GID>]:<perms>

Table 18-9 explains each of the elements of the syntax for ACL commands.

Table 18-9 ACL Argument Syntax

Argument Description
<entry-type> Type of ACL entry on which to set file permissions. For example, <entry_type> can be user (the owner of a file) or mask (the ACL mask).
<UID> Username or identification number.
<GID> Group name or identification number.
<perm> Permissions set for the <entry-type>. Permissions can be set symbolically using the characters r, w, x, and - or by using octal values from 0 to 7.

NOTE:  ACLs are supported in UFS file systems only. If you restore or copy files with ACL entries in the /tmp directory, which is usually mounted as a TMPFS file system, the ACL entries are lost. If you need to temporarily store UFS files containing ACLs, use the /var/tmp directory instead.

Previous Table of Contents Next