public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 0/1] Fix facl on files opened with O_PATH
Date: Wed, 24 Feb 2021 10:42:42 +0100	[thread overview]
Message-ID: <YDYfkmha8sVqfpsX@calimero.vinschen.de> (raw)
In-Reply-To: <20210223224950.40895-1-kbrown@cornell.edu>

On Feb 23 17:49, Ken Brown via Cygwin-patches wrote:
> I'm not sure if this patch is right.  Should facl fail on all commands
> or just on SETACL?  If the command is GETACL, for example, should this
> fail like fgetxattr(2) or should it succeed like fstat(2)?
> 
> Cygwin may be the only platform that supports both facl(2) and O_PATH,
> so I guess we're on our own here.

Not entirely.  facl is also the underlying function for the POSIX ACL
calls, deprecated but still supported by Linux.  I. e., on a file system
supporting ACLs (xfs, ext4, etc), this needs testing:

  int fd = open (..., O_PATH);
  if (fd < 0)
    perror ("open");
  else if (acl_get_fd (fd) != NULL)
    printf ("acl_get_fd works with O_PATH\n");
  else
    perror ("acl_get_fd");

I just did that and it turns out that the above code returns with

  acl_get_fd: Bad file descriptor

At first I was actually a bit surprised.  I thought fetching ACLs is
along the lines of fstat, but on second though it's not.  ACLs are
stored as extended attributes and given that fgetxattr is supposed to
fail with EBADF, it's logical that acl_get_fd fails with EBADF as well.
qed

So your patch looks good.


Thanks,
Corinna

      parent reply	other threads:[~2021-02-24  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-23 22:49 Ken Brown
2021-02-23 22:49 ` [PATCH 1/1] Cygwin: facl: fail with EBADF " Ken Brown
2021-02-24  9:42 ` Corinna Vinschen [this message]

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=YDYfkmha8sVqfpsX@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    /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).