commit dc77c5968b046ae7d22d45a8fc78f3774276f807
parent a0fae719775b50917f3aeb42af79069187f38934
Author: Richard Ipsum <richardipsum@fastmail.co.uk>
Date: Wed, 3 Jul 2019 17:32:42 +0100
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.
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/chgrp.c b/chgrp.c
@@ -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 {
diff --git a/chown.c b/chown.c
@@ -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 {