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.
This commit is contained in:
Michael Forney 2019-11-01 19:03:00 -07:00
parent 71ba97c175
commit b29fc0b05f

View File

@ -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)) {