4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
28 #include <sys/types.h>
32 check_perm( statbuf
, uid
, gid
, perm
)
38 int fail
= -1; /* assume no permission at onset */
40 /* Make sure we're dealing with a directory */
41 if( S_ISDIR( statbuf
.st_mode
)) {
44 * Have a directory, so make sure user has permission
45 * by the various possible methods to this directory.
47 if( (statbuf
.st_uid
== uid
) &&
48 (statbuf
.st_mode
& (perm
<< 6)) == (perm
<< 6) )
51 if( (statbuf
.st_gid
== gid
) &&
52 (statbuf
.st_mode
& (perm
<< 3)) == (perm
<< 3) )
55 if( (statbuf
.st_mode
& perm
) == perm
)