1 /* @(#)eaccess.c 1.6 14/05/15 Copyright 2004-2014 J. Schilling */ 2 #include <schily/mconfig.h> 3 #ifndef lint 4 static UConst char sccsid[] = 5 "@(#)eaccess.c 1.6 14/05/15 Copyright 2004-2014 J. Schilling"; 6 #endif 7 /* 8 * Implement the best possible emulation for eaccess() 9 * 10 * Copyright 2004-2014 J. Schilling 11 */ 12 /* 13 * The contents of this file are subject to the terms of the 14 * Common Development and Distribution License, Version 1.0 only 15 * (the "License"). You may not use this file except in compliance 16 * with the License. 17 * 18 * See the file CDDL.Schily.txt in this distribution for details. 19 * A copy of the CDDL is also available via the Internet at 20 * http://www.opensource.org/licenses/cddl1.txt 21 * 22 * When distributing Covered Code, include this CDDL HEADER in each 23 * file and include the License file CDDL.Schily.txt from this distribution. 24 */ 25 26 #include <schily/unistd.h> 27 #include <schily/standard.h> 28 #include <schily/errno.h> 29 #include <schily/schily.h> 30 31 #ifndef HAVE_EACCESS 32 EXPORT int eaccess __PR((const char *name, int mode)); 33 34 EXPORT int 35 eaccess(name, mode) 36 const char *name; 37 int mode; 38 { 39 #ifdef HAVE_EUIDACCESS 40 return (euidaccess(name, mode)); 41 #else 42 #ifdef HAVE_ACCESS_E_OK 43 return (access(name, E_OK|mode)); 44 #else 45 if (getuid() == geteuid() && getgid() == getegid()) 46 return (access(name, mode)); 47 #ifdef EOPNOTSUPP 48 seterrno(EOPNOTSUPP); 49 #else 50 seterrno(EINVAL); 51 #endif 52 return (-1); 53 #endif 54 #endif 55 } 56 #endif 57