mirror of
https://git.busybox.net/busybox.git
synced 2024-11-23 05:33:33 +08:00
test: -x can return 0/1 early if all X bits are the same
function old new delta nexpr 702 725 +23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
96b0607302
commit
0929a129fc
@ -654,16 +654,16 @@ static int test_st_mode(struct stat *st, int mode)
|
||||
enum { ANY_IX = S_IXUSR | S_IXGRP | S_IXOTH };
|
||||
unsigned euid;
|
||||
|
||||
//TODO if (mode == X_OK) {
|
||||
// /* Do we already know with no extra syscalls? */
|
||||
// //if (!S_ISREG(st->st_mode))
|
||||
// // return 0; /* not a regular file */
|
||||
// // ^^^ bash does not check this
|
||||
// if ((st->st_mode & ANY_IX) == 0)
|
||||
// return 0; /* no one can execute */
|
||||
// if ((st->st_mode & ANY_IX) == ANY_IX)
|
||||
// return 1; /* anyone can execute */
|
||||
// }
|
||||
if (mode == X_OK) {
|
||||
/* Do we already know with no extra syscalls? */
|
||||
//if (!S_ISREG(st->st_mode))
|
||||
// return 0; /* not a regular file */
|
||||
// ^^^ bash 5.2.15 "test -x" does not check this!
|
||||
if ((st->st_mode & ANY_IX) == 0)
|
||||
return 0; /* no one can execute */
|
||||
if ((st->st_mode & ANY_IX) == ANY_IX)
|
||||
return 1; /* anyone can execute */
|
||||
}
|
||||
|
||||
euid = get_cached_euid(&groupinfo->euid);
|
||||
if (euid == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user