public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin/main] Cygwin: fix chmod on native NFS FIFOs
Date: Fri,  8 Sep 2023 20:41:46 +0000 (GMT)	[thread overview]
Message-ID: <20230908204146.0DA19385841D@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bedefff9e25b6b2bdc13e0268a437f82dc4b4798

commit bedefff9e25b6b2bdc13e0268a437f82dc4b4798
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Fri Sep 8 22:38:53 2023 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Sep 8 22:38:53 2023 +0200

    Cygwin: fix chmod on native NFS FIFOs
    
    By handling native NFS FIFOs as actual FIFOs, chmod on a FIFO
    suddenly called fhandler_base::fchmod, which is insufficient
    to handle FIFO files on any filesystem.
    
    Note that this does not fix Cygwin FIFOs on NFS or AFS yet.
    
    Fixes: 622fb0776ea3 ("Cygwin: enable usage of FIFOs on NFS")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/base.cc      | 10 ++++++++--
 winsup/cygwin/fhandler/disk_file.cc |  5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler/base.cc b/winsup/cygwin/fhandler/base.cc
index 3d348b5159a4..6163df2914d4 100644
--- a/winsup/cygwin/fhandler/base.cc
+++ b/winsup/cygwin/fhandler/base.cc
@@ -613,7 +613,10 @@ fhandler_base::open (int flags, mode_t mode)
 	options |= FILE_OPEN_REPARSE_POINT;
     }
 
-  if (get_device () == FH_FS)
+  /* If the file is a FIFO, open has been called for an operation on the file
+     constituting the FIFO, e. g., chmod or statvfs.  Handle it like a normal
+     file.  Eespecially the access flags have to be set correctly. */
+  if (get_device () == FH_FS || get_device () == FH_FIFO)
     {
       /* O_TMPFILE files are created with delete-on-close semantics, as well
 	 as with FILE_ATTRIBUTE_TEMPORARY.  The latter speeds up file access,
@@ -1710,7 +1713,10 @@ int
 fhandler_base::fchmod (mode_t mode)
 {
   if (pc.is_fs_special ())
-    return chmod_device (pc, mode);
+    {
+      fhandler_disk_file fh (pc);
+      return fh.fchmod (mode);
+    }
   /* By default, just succeeds. */
   return 0;
 }
diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc
index d59cde78b5bd..4f373637e514 100644
--- a/winsup/cygwin/fhandler/disk_file.cc
+++ b/winsup/cygwin/fhandler/disk_file.cc
@@ -715,7 +715,10 @@ fhandler_disk_file::fchmod (mode_t mode)
   NTSTATUS status;
   IO_STATUS_BLOCK io;
 
-  if (pc.is_fs_special ())
+  if (pc.is_fs_special ()
+      /* For NFS, only handle Cygwin FIFOs specially.  Changing mode of
+	 native FIFOs will work with the default code below. */
+      && (!pc.fs_is_nfs () || pc.nfsattr ()->filler1 == NF3FIFO))
     return chmod_device (pc, mode);
 
   if (!get_handle ())

                 reply	other threads:[~2023-09-08 20:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230908204146.0DA19385841D@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).