18.12.2012 Views

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

O'Reilly - Practical UNIX & Internet Sec... 7015KB

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[Chapter 5] 5.2 Using File Permissions<br />

To copy an ACL from one file to a group of files, use xargs:<br />

$ ls *.dat *.old | xargs -i /bin/sh -c "aclget silver | aclput {}"<br />

These commands copy the ACL in silver to all the files ending in .dat and .old in the current directory.<br />

You can use the ls -le command to quickly determine whether a file has an extended permissions set or not:<br />

$ ls -le *_acl<br />

-rw-r-----+ 1 chavez chem 51 Mar 20 13:27 has_acl<br />

-rwxrws---- 2 chavez chem 512 Feb 08 17:58 no_acl<br />

The plus sign appended to the normal mode string indicates the presence of extended permissions; the minus sign is present<br />

otherwise.<br />

5.2.5.2 HP-UX access control lists<br />

The lsacl command can be used to view the access control list for a file. For a file having only normal <strong>UNIX</strong> file modes set, the<br />

output looks like this:<br />

(chavez.%,rw-)(%.chem,r--)(%.%,---) bronze<br />

This example shows the format an ACL takes under HP-UX. Each parenthesized item is known as an access control list entry,<br />

although we're going to call them "entries." The percent sign character ("%") is a wildcard within an entry, and the three entries<br />

in the previous listing specify the access for user chavez as a member of any group, for any user in group chem, and for all other<br />

users and groups, respectively.<br />

A file can have up to 16 access control list entries: three base entries corresponding to normal file modes and up to 13 optional<br />

entries. Here is the access control list for another file (generated this time by lsacl -l):<br />

silver:<br />

rwx chavez.%<br />

r-x %.chem<br />

r-x %.phys<br />

r-x hill.bio<br />

rwx harvey.%<br />

--- %.%<br />

This ACL grants every access to user chavez with any current group membership (she is the file owner). It grants read and<br />

execute access to members of the chem and phys groups; it grants read and execute access to user hill, if hill is a member of<br />

group bio; it grants user harvey read, write, and execute access regardless of his group membership; and it grants no access to<br />

any other user or group.<br />

Entries within an HP-UX access control list are examined in order of decreasing specificity: entries with a specific user and<br />

group are considered first; those with only a specific user follow; ones with only a specific group are next; and the other entries<br />

are last of all. Within a class, entries are examined in order. When determining whether or not to permit file access, the first<br />

applicable entry is used. Thus, user harvey will be given write access to the file silver even if he is a member of the chem or phys<br />

group.<br />

The chacl command is used to modify the access control list for a file. ACLS can be specified to chacl in two distinct forms: as a<br />

list of entries or via a chmod-like syntax. By default, chacl adds entries to the current ACL. For example, these two commands<br />

add to the file server's ACL read access for the bio group and read and execute access for user hill:<br />

$ chacl "(%.bio,r--) (hill.%,r-x)" silver<br />

$ chacl "%.bio = r, hill.% = rx" silver<br />

In either format, the access control list must be passed to chacl as a single argument. The second format also includes + and -<br />

operators as in chmod. For example, this command adds read access for group chem and user harvey, and removes write access<br />

for group chem, adding or modifying ACL entries as needed:<br />

$ chacl "%.chem -w+r, harvey.% +r" silver<br />

chacl's -r option can be used to replace the current ACL:<br />

$ chacl -r "@.% = 7, %.@ = rx, %.bio = r, %.% = " *.dat<br />

file:///C|/Oreilly Unix etc/<strong>O'Reilly</strong> Reference Library/networking/puis/ch05_02.htm (8 of 9) [2002-04-12 10:44:09]

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

Saved successfully!

Ooh no, something went wrong!