aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/test.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index ad777953f..6085d6663 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -638,7 +638,7 @@ static int binop(void)
638static int is_a_group_member(gid_t gid) 638static int is_a_group_member(gid_t gid)
639{ 639{
640 /* Short-circuit if possible, maybe saving a call to getgroups(). */ 640 /* Short-circuit if possible, maybe saving a call to getgroups(). */
641 if (gid == getgid() || gid == getegid()) 641 if (gid == get_cached_egid(&groupinfo->egid))
642 return 1; 642 return 1;
643 643
644 return is_in_supplementary_groups(groupinfo, gid); 644 return is_in_supplementary_groups(groupinfo, gid);
@@ -656,15 +656,16 @@ static int test_st_mode(struct stat *st, int mode)
656 656
657//TODO if (mode == X_OK) { 657//TODO if (mode == X_OK) {
658// /* Do we already know with no extra syscalls? */ 658// /* Do we already know with no extra syscalls? */
659// if (!S_ISREG(st->st_mode)) 659// //if (!S_ISREG(st->st_mode))
660// return 0; /* not a regular file */ 660// // return 0; /* not a regular file */
661// // ^^^ bash does not check this
661// if ((st->st_mode & ANY_IX) == 0) 662// if ((st->st_mode & ANY_IX) == 0)
662// return 0; /* no one can execute */ 663// return 0; /* no one can execute */
663// if ((st->st_mode & ANY_IX) == ANY_IX) 664// if ((st->st_mode & ANY_IX) == ANY_IX)
664// return 1; /* anyone can execute */ 665// return 1; /* anyone can execute */
665// } 666// }
666 667
667 euid = geteuid(); 668 euid = get_cached_euid(&groupinfo->euid);
668 if (euid == 0) { 669 if (euid == 0) {
669 /* Root can read or write any file. */ 670 /* Root can read or write any file. */
670 if (mode != X_OK) 671 if (mode != X_OK)
@@ -1019,6 +1020,8 @@ int test_main(int argc, char **argv)
1019 struct cached_groupinfo info; 1020 struct cached_groupinfo info;
1020 int r; 1021 int r;
1021 1022
1023 info.euid = -1;
1024 info.egid = -1;
1022 info.ngroups = 0; 1025 info.ngroups = 0;
1023 info.supplementary_array = NULL; 1026 info.supplementary_array = NULL;
1024 r = test_main2(&info, argc, argv); 1027 r = test_main2(&info, argc, argv);