bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI, bug in chgrp, chown, with -R -H and...


From: Jim Meyering
Subject: FYI, bug in chgrp, chown, with -R -H and...
Date: Fri, 13 Oct 2006 21:50:58 +0200

I discovered a problem in chown and chgrp.
It's not worth worrying *too* much about, since few people use any of
the options (-H, -L) that make the tools traverse symbolic links.

I've added this to NEWS:

  chgrp and chown would malfunction when invoked with both -R and -H and
  with one or more of the following: --preserve-root, --verbose, --changes,
  --from=o:g (chown only).  This bug was introduced with the switch to
  gnulib's openat-based variant of fts, for coreutils-6.0.

2006-10-13  Jim Meyering  <address@hidden>

        * src/chown-core.c (change_file_owner): Use fstatat, not stat,
        now that we're using fts_open with FTS_CWDFD.
        * tests/chgrp/posix-H: Add --preserve-root to an invocation of
        chgrp, to exercise the above fix.
        * NEWS: Mention the above.

Index: src/chown-core.c
===================================================================
RCS file: /fetish/cu/src/chown-core.c,v
retrieving revision 1.43
diff -u -r1.43 chown-core.c
--- src/chown-core.c    20 Sep 2006 11:50:46 -0000      1.43
+++ src/chown-core.c    13 Oct 2006 18:43:52 -0000
@@ -318,7 +318,7 @@
         stat it to get info on the referent.  */
       if (S_ISLNK (file_stats->st_mode) && chopt->affect_symlink_referent)
        {
-         if (stat (file, &stat_buf) != 0)
+         if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0)
            {
              error (0, errno, _("cannot dereference %s"),
                     quote (file_full_name));
Index: tests/chgrp/posix-H
===================================================================
RCS file: /fetish/cu/tests/chgrp/posix-H,v
retrieving revision 1.5
diff -u -r1.5 posix-H
--- tests/chgrp/posix-H 17 Aug 2006 19:58:25 -0000      1.5
+++ tests/chgrp/posix-H 13 Oct 2006 18:45:51 -0000
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Test POSIX-mandated -H option.

-# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.

 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@

 fail=0

-chgrp -H -R $g2 1s 2 || fail=1
+chgrp --preserve-root -H -R $g2 1s 2 || fail=1

 # These must have group $g2.
 # =========================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]