chown/chgrp: chown target not symlink by default

chown on a symlink should only chown the symlink itself when -h
is specified, when no options are provided the target should be chown'd.
This commit is contained in:
Richard Ipsum 2019-07-03 17:32:42 +01:00 committed by Michael Forney
parent a0fae71977
commit dc77c5968b
2 changed files with 2 additions and 2 deletions

View File

@ -18,7 +18,7 @@ chgrp(const char *path, struct stat *st, void *data, struct recursor *r)
char *chownf_name;
int (*chownf)(const char *, uid_t, gid_t);
if (r->follow == 'P' || (r->follow == 'H' && r->depth) || (hflag && !(r->depth))) {
if ((r->maxdepth == 0 && r->follow == 'P') || (r->follow == 'H' && r->depth) || (hflag && !(r->depth))) {
chownf_name = "lchown";
chownf = lchown;
} else {

View File

@ -21,7 +21,7 @@ chownpwgr(const char *path, struct stat *st, void *data, struct recursor *r)
char *chownf_name;
int (*chownf)(const char *, uid_t, gid_t);
if (r->follow == 'P' || (r->follow == 'H' && r->depth) || (hflag && !(r->depth))) {
if ((r->maxdepth == 0 && r->follow == 'P') || (r->follow == 'H' && r->depth) || (hflag && !(r->depth))) {
chownf_name = "lchown";
chownf = lchown;
} else {