logo

utils-std

Collection of commonly available Unix tools
commit: bb456c484706990d3db59994940b62e89ab67642
parent c1dca7872a6458e4a17e3c02802c3834691b90dc
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue,  4 Jun 2024 19:29:38 +0200

lib/mode: Fix applying multiple perms after set operator

Diffstat:

Mlib/mode.c3+++
Mtest-lib/mode.c5++++-
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/mode.c b/lib/mode.c @@ -93,6 +93,9 @@ apply(struct meta_t *meta, int8_t mode) if(FIELD_MATCH(meta->dest, WHO_USER)) meta->new_modes.user = mode; if(FIELD_MATCH(meta->dest, WHO_GROUP)) meta->new_modes.group = mode; if(FIELD_MATCH(meta->dest, WHO_OTHER)) meta->new_modes.other = mode; + + // So a=rw is a=r+w rather than a=r,a=w + meta->op = OP_ADD; break; default: abort(); diff --git a/test-lib/mode.c b/test-lib/mode.c @@ -101,6 +101,9 @@ set_read() t_mode("g=r,o=r", 0, 00044); t_mode("u=r,o=r", 0, 00404); + t_mode("go=,u=xr", 0, 00500); + t_mode("go=,u=xr", 00777, 00500); + t_mode("=r", 00777, 00400); t_mode("a=r", 00777, 00444); t_mode("u=r", 00777, 00477); @@ -285,7 +288,7 @@ non_symbolic() int main() { - int plan = 152; + int plan = 154; printf("1..%d\n", plan); t_mode(NULL, 0, 0);