mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 02:36:11 +00:00
GIT_MODE_TYPE should exclude setgid bits
The GIT_MODE_TYPE macro was looking at all bits above the permissions, but it should really just look at the top bits so that it will give the right results for a setgid or setuid entry. Since we're now using these macros in the tests, this was causing a test failure on platforms that don't support setgid.
This commit is contained in:
parent
c97d407d9c
commit
af22dabb43
@ -228,7 +228,8 @@ extern git_off_t git_futils_filesize(git_file fd);
|
||||
#define GIT_PERMS_FOR_WRITE(MODE) (GIT_PERMS_EXECUTABLE(MODE) ? 0777 : 0666)
|
||||
|
||||
#define GIT_MODE_PERMS_MASK 0777
|
||||
#define GIT_MODE_TYPE(MODE) ((MODE) & ~GIT_MODE_PERMS_MASK)
|
||||
#define GIT_MODE_TYPE_MASK 0170000
|
||||
#define GIT_MODE_TYPE(MODE) ((MODE) & GIT_MODE_TYPE_MASK)
|
||||
#define GIT_MODE_ISBLOB(MODE) (GIT_MODE_TYPE(MODE) == GIT_MODE_TYPE(GIT_FILEMODE_BLOB))
|
||||
|
||||
/**
|
||||
|
@ -418,12 +418,8 @@ static void assert_mode_seems_okay(
|
||||
expect_setgid = false;
|
||||
}
|
||||
|
||||
if (S_ISGID != 0) {
|
||||
if (expect_setgid)
|
||||
cl_assert((st.st_mode & S_ISGID) != 0);
|
||||
else
|
||||
cl_assert((st.st_mode & S_ISGID) == 0);
|
||||
}
|
||||
if (S_ISGID != 0)
|
||||
cl_assert_equal_b(expect_setgid, (st.st_mode & S_ISGID) != 0);
|
||||
|
||||
cl_assert_equal_b(
|
||||
GIT_PERMS_EXECUTABLE(expect_mode), GIT_PERMS_EXECUTABLE(st.st_mode));
|
||||
|
Loading…
Reference in New Issue
Block a user