From b29fc0b05f579d293043b130aef3338eaf052c8e Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 1 Nov 2019 19:03:00 -0700 Subject: [PATCH] chgrp: Pass -1 as the owner ID to chown(3) Otherwise, if the owner ID changes between stat() and chown(), we will revert to the previous owner while changing the group. --- chgrp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chgrp.c b/chgrp.c index 93d7577..960ed2c 100644 --- a/chgrp.c +++ b/chgrp.c @@ -26,7 +26,7 @@ chgrp(const char *path, struct stat *st, void *data, struct recursor *r) chownf = chown; } - if (chownf(path, st->st_uid, gid) < 0) { + if (chownf(path, -1, gid) < 0) { weprintf("%s %s:", chownf_name, path); ret = 1; } else if (S_ISDIR(st->st_mode)) {