--- which-2.13/bash.c.orig Tue Feb 26 23:39:42 2002 +++ which-2.13/bash.c Wed Feb 27 00:02:36 2002 @@ -33,7 +33,6 @@ */ #define HAVE_GETGROUPS #undef SHELL -#undef AFS #undef NOGROUP /* @@ -146,51 +145,52 @@ if (S_ISDIR (finfo.st_mode)) return (FS_EXISTS); -#if defined (AFS) - /* We have to use access(2) to determine access because AFS does not - support Unix file system semantics. This may produce wrong - answers for non-AFS files when ruid != euid. I hate AFS. */ - if (access (name, X_OK) == 0) - return (FS_EXISTS | FS_EXECABLE); - else - return (FS_EXISTS); -#else /* !AFS */ - - /* Find out if the file is actually executable. By definition, the - only other criteria is that the file has an execute bit set that - we can use. */ - if (user_id == -1) - user_id = geteuid (); /* CHANGED: bash uses: current_user.euid; */ - - /* Root only requires execute permission for any of owner, group or - others to be able to exec a file. */ - if (user_id == 0) + if (getenv("AFS")) { + /* We have to use access(2) to determine access because AFS does not + support Unix file system semantics. This may produce wrong + answers for non-AFS files when ruid != euid. I hate AFS. */ + if (access (name, X_OK) == 0) + return (FS_EXISTS | FS_EXECABLE); + else + return (FS_EXISTS); + } + else /* !AFS */ { - int bits; - - bits = (u_mode_bits (finfo.st_mode) | - g_mode_bits (finfo.st_mode) | - o_mode_bits (finfo.st_mode)); - - if (X_BIT (bits)) - return (FS_EXISTS | FS_EXECABLE); - } - - /* If we are the owner of the file, the owner execute bit applies. */ - if (user_id == finfo.st_uid && X_BIT (u_mode_bits (finfo.st_mode))) - return (FS_EXISTS | FS_EXECABLE); - - /* If we are in the owning group, the group permissions apply. */ - if (group_member (finfo.st_gid) && X_BIT (g_mode_bits (finfo.st_mode))) - return (FS_EXISTS | FS_EXECABLE); - - /* If `others' have execute permission to the file, then so do we, - since we are also `others'. */ - if (X_BIT (o_mode_bits (finfo.st_mode))) - return (FS_EXISTS | FS_EXECABLE); - else - return (FS_EXISTS); -#endif /* !AFS */ + /* Find out if the file is actually executable. By definition, the + only other criteria is that the file has an execute bit set that + we can use. */ + if (user_id == -1) + user_id = geteuid (); /* CHANGED: bash uses: current_user.euid; */ + + /* Root only requires execute permission for any of owner, group or + others to be able to exec a file. */ + if (user_id == 0) + { + int bits; + + bits = (u_mode_bits (finfo.st_mode) | + g_mode_bits (finfo.st_mode) | + o_mode_bits (finfo.st_mode)); + + if (X_BIT (bits)) + return (FS_EXISTS | FS_EXECABLE); + } + + /* If we are the owner of the file, the owner execute bit applies. */ + if (user_id == finfo.st_uid && X_BIT (u_mode_bits (finfo.st_mode))) + return (FS_EXISTS | FS_EXECABLE); + + /* If we are in the owning group, the group permissions apply. */ + if (group_member (finfo.st_gid) && X_BIT (g_mode_bits (finfo.st_mode))) + return (FS_EXISTS | FS_EXECABLE); + + /* If `others' have execute permission to the file, then so do we, + since we are also `others'. */ + if (X_BIT (o_mode_bits (finfo.st_mode))) + return (FS_EXISTS | FS_EXECABLE); + else + return (FS_EXISTS); + } /* !AFS */ } /* Return 1 if STRING is an absolute program name; it is absolute if it