[hackers] [sbase] chown/chgrp: chown target not symlink by default || Richard Ipsum

From: <git_AT_suckless.org>
Date: Mon, 8 Jul 2019 22:42:06 +0200 (CEST)

commit dc77c5968b046ae7d22d45a8fc78f3774276f807
Author: Richard Ipsum <richardipsum_AT_fastmail.co.uk>
AuthorDate: Wed Jul 3 17:32:42 2019 +0100
Commit: Michael Forney <mforney_AT_mforney.org>
CommitDate: Wed Jul 3 22:33:06 2019 -0700

    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.

diff --git a/chgrp.c b/chgrp.c
index 5d3a71b..7ee3553 100644
--- a/chgrp.c
+++ b/chgrp.c
_AT_@ -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
index d7dc8e0..c517acf 100644
--- a/chown.c
+++ b/chown.c
_AT_@ -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 {
Received on Mon Jul 08 2019 - 22:42:06 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 08 2019 - 22:48:25 CEST