work/bootstrap/gec17.c
EIF_BOOLEAN eif_file_eaccess(rt_stat_buf *buf, int op) {
	int mode = buf->st_mode & ST_MODE;	/* Current mode */
#ifdef HAS_GETEUID
	int uid = buf->st_uid;				/* File owner */
	int gid = buf->st_gid;				/* File group */
	int euid, egid;						/* Effective user and group */
#endif

    switch (op) {
	case 0: /* Is file readable */
#ifdef EIF_WINDOWS
	return ((mode && S_IREAD) ? EIF_TRUE : EIF_FALSE);
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();

		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IRUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IRGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IRGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IROTH) ? EIF_TRUE : EIF_FALSE);
	case 1: /* Is file writable */
#ifdef EIF_WINDOWS
		return ((mode & S_IWRITE) ? EIF_TRUE : EIF_FALSE);
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();

		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IWUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IWGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IWGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IWOTH) ? EIF_TRUE : EIF_FALSE);
	case 2: /* Is file executable */
#ifdef EIF_WINDOWS
		return EIF_TRUE;
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();

		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IXUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IXGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IXGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IXOTH) ? EIF_TRUE : EIF_FALSE);
	case 3: /* Is file setuid */
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISUID) ? EIF_TRUE : EIF_FALSE);
#endif
	case 4: /* Is file setgid */
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISGID) ? EIF_TRUE : EIF_FALSE);
#endif
	case 5: /* Is file sticky */
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISVTX) ? EIF_TRUE : EIF_FALSE);
#endif
	case 6: /* Is file owned by effective UID */
#ifdef HAS_GETEUID
		return ((uid == geteuid()) ? EIF_TRUE : EIF_FALSE);
#else
		return EIF_TRUE;
#endif
	case 7: /* Is file owned by real UID */
#ifdef HAS_GETEUID
		return ((uid == getuid()) ? EIF_TRUE : EIF_FALSE);
#else
		return EIF_TRUE;
#endif
	default:
		return EIF_FALSE;
	}
}
/*
 * Check file permissions using effective UID and effective GID. The
 * current permission mode is held in the st_mode field of the stat()
 * buffer structure `buf'.
 */
Check file permissions using effective UID and effective GID. The
current permission mode is held in the st_mode field of the stat()
buffer structure `buf'.
Check file permissions using effective UID and effective GID . The current permission mode is held in the st_mode field of the stat () buffer structure ` buf ' .
EIF_BOOLEAN eif_file_eaccess(rt_stat_buf *buf, int op) {
	int mode = buf->st_mode & ST_MODE;	
#ifdef HAS_GETEUID
	int uid = buf->st_uid;				
	int gid = buf->st_gid;				
	int euid, egid;						
#endif
    switch (op) {
	case 0: 
#ifdef EIF_WINDOWS
	return ((mode && S_IREAD) ? EIF_TRUE : EIF_FALSE);
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();
		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IRUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IRGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IRGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IROTH) ? EIF_TRUE : EIF_FALSE);
	case 1: 
#ifdef EIF_WINDOWS
		return ((mode & S_IWRITE) ? EIF_TRUE : EIF_FALSE);
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();
		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IWUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IWGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IWGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IWOTH) ? EIF_TRUE : EIF_FALSE);
	case 2: 
#ifdef EIF_WINDOWS
		return EIF_TRUE;
#elif defined HAS_GETEUID
		euid = geteuid();
		egid = getegid();
		if (euid == 0)
			return EIF_TRUE;
		else if (uid == euid)
			return ((mode & S_IXUSR) ? EIF_TRUE : EIF_FALSE);
		else if (gid == egid)
			return ((mode & S_IXGRP) ? EIF_TRUE : EIF_FALSE);
#ifdef HAS_GETGROUPS
		else if (eif_group_in_list(gid))
			return ((mode & S_IXGRP) ? EIF_TRUE : EIF_FALSE);
#endif
		else
#endif
			return ((mode & S_IXOTH) ? EIF_TRUE : EIF_FALSE);
	case 3: 
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISUID) ? EIF_TRUE : EIF_FALSE);
#endif
	case 4: 
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISGID) ? EIF_TRUE : EIF_FALSE);
#endif
	case 5: 
#ifdef EIF_WINDOWS
		return EIF_FALSE;
#else
		return ((mode & S_ISVTX) ? EIF_TRUE : EIF_FALSE);
#endif
	case 6: 
#ifdef HAS_GETEUID
		return ((uid == geteuid()) ? EIF_TRUE : EIF_FALSE);
#else
		return EIF_TRUE;
#endif
	case 7: 
#ifdef HAS_GETEUID
		return ((uid == getuid()) ? EIF_TRUE : EIF_FALSE);
#else
		return EIF_TRUE;
#endif
	default:
		return EIF_FALSE;
	}
}
EIF_BOOLEAN eif_file_eaccess ( rt_stat_buf * buf , int op ) { int mode = buf -> st_mode & ST_MODE ; #ifdef HAS_GETEUID int uid = buf -> st_uid ; int gid = buf -> st_gid ; int euid , egid ; #endif switch ( op ) { case 0 : #ifdef EIF_WINDOWS return ( ( mode && S_IREAD ) ? EIF_TRUE : EIF_FALSE ) ; #elif defined HAS_GETEUID euid = geteuid ( ) ; egid = getegid ( ) ; if ( euid == 0 ) return EIF_TRUE ; else if ( uid == euid ) return ( ( mode & S_IRUSR ) ? EIF_TRUE : EIF_FALSE ) ; else if ( gid == egid ) return ( ( mode & S_IRGRP ) ? EIF_TRUE : EIF_FALSE ) ; #ifdef HAS_GETGROUPS else if ( eif_group_in_list ( gid ) ) return ( ( mode & S_IRGRP ) ? EIF_TRUE : EIF_FALSE ) ; #endif else #endif return ( ( mode & S_IROTH ) ? EIF_TRUE : EIF_FALSE ) ; case 1 : #ifdef EIF_WINDOWS return ( ( mode & S_IWRITE ) ? EIF_TRUE : EIF_FALSE ) ; #elif defined HAS_GETEUID euid = geteuid ( ) ; egid = getegid ( ) ; if ( euid == 0 ) return EIF_TRUE ; else if ( uid == euid ) return ( ( mode & S_IWUSR ) ? EIF_TRUE : EIF_FALSE ) ; else if ( gid == egid ) return ( ( mode & S_IWGRP ) ? EIF_TRUE : EIF_FALSE ) ; #ifdef HAS_GETGROUPS else if ( eif_group_in_list ( gid ) ) return ( ( mode & S_IWGRP ) ? EIF_TRUE : EIF_FALSE ) ; #endif else #endif return ( ( mode & S_IWOTH ) ? EIF_TRUE : EIF_FALSE ) ; case 2 : #ifdef EIF_WINDOWS return EIF_TRUE ; #elif defined HAS_GETEUID euid = geteuid ( ) ; egid = getegid ( ) ; if ( euid == 0 ) return EIF_TRUE ; else if ( uid == euid ) return ( ( mode & S_IXUSR ) ? EIF_TRUE : EIF_FALSE ) ; else if ( gid == egid ) return ( ( mode & S_IXGRP ) ? EIF_TRUE : EIF_FALSE ) ; #ifdef HAS_GETGROUPS else if ( eif_group_in_list ( gid ) ) return ( ( mode & S_IXGRP ) ? EIF_TRUE : EIF_FALSE ) ; #endif else #endif return ( ( mode & S_IXOTH ) ? EIF_TRUE : EIF_FALSE ) ; case 3 : #ifdef EIF_WINDOWS return EIF_FALSE ; #else return ( ( mode & S_ISUID ) ? EIF_TRUE : EIF_FALSE ) ; #endif case 4 : #ifdef EIF_WINDOWS return EIF_FALSE ; #else return ( ( mode & S_ISGID ) ? EIF_TRUE : EIF_FALSE ) ; #endif case 5 : #ifdef EIF_WINDOWS return EIF_FALSE ; #else return ( ( mode & S_ISVTX ) ? EIF_TRUE : EIF_FALSE ) ; #endif case 6 : #ifdef HAS_GETEUID return ( ( uid == geteuid ( ) ) ? EIF_TRUE : EIF_FALSE ) ; #else return EIF_TRUE ; #endif case 7 : #ifdef HAS_GETEUID return ( ( uid == getuid ( ) ) ? EIF_TRUE : EIF_FALSE ) ; #else return EIF_TRUE ; #endif default : return EIF_FALSE ; } }
Check file permissions using effective UID and effective GID.
Check file permissions using effective UID and effective GID .
/* Current mode */ /* File owner */ /* File group */ /* Effective user and group */ /* Is file readable */ /* Is file writable */ /* Is file executable */ /* Is file setuid */ /* Is file setgid */ /* Is file sticky */ /* Is file owned by effective UID */ /* Is file owned by real UID */