From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: implement getfacl(1) for socket files
Date: Mon, 4 Jul 2022 10:39:44 +0200 [thread overview]
Message-ID: <YsKnUOvT/jnv/8QD@calimero.vinschen.de> (raw)
In-Reply-To: <c16697ba-b02f-ffd1-7422-fa22443e7895@cornell.edu>
On Jul 3 14:37, Ken Brown wrote:
> Patch attached.
LGTM, but make this master (i .e., 3.4) only.
Thanks,
Corinna
> From 28cd29d99fe6d1a54c8dad04854bda10743737d3 Mon Sep 17 00:00:00 2001
> From: Ken Brown <kbrown@cornell.edu>
> Date: Sat, 2 Jul 2022 15:12:40 -0400
> Subject: [PATCH] Cygwin: implement getfacl(1) for socket files
>
> Do this by defining the acl_get method for the fhandler_socket_local
> and fhandler_socket_unix classes. Also define acl_set for these
> classes.
>
> Partially addresses: https://cygwin.com/pipermail/cygwin/2022-July/251768.html
> ---
> winsup/cygwin/fhandler.h | 4 ++
> winsup/cygwin/release/3.3.6 | 3 ++
> winsup/cygwin/sec_posixacl.cc | 76 +++++++++++++++++++++++++++++++++++
> 3 files changed, 83 insertions(+)
>
> diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
> index d5ec56a6d..cb5e08fa3 100644
> --- a/winsup/cygwin/fhandler.h
> +++ b/winsup/cygwin/fhandler.h
> @@ -861,6 +861,8 @@ class fhandler_socket_local: public fhandler_socket_wsock
> int fchmod (mode_t newmode);
> int fchown (uid_t newuid, gid_t newgid);
> int facl (int, int, struct acl *);
> + struct __acl_t *acl_get (uint32_t);
> + int acl_set (struct __acl_t *, uint32_t);
> int link (const char *);
>
> /* from here on: CLONING */
> @@ -1143,6 +1145,8 @@ class fhandler_socket_unix : public fhandler_socket
> int fchmod (mode_t newmode);
> int fchown (uid_t newuid, gid_t newgid);
> int facl (int, int, struct acl *);
> + struct __acl_t *acl_get (uint32_t);
> + int acl_set (struct __acl_t *, uint32_t);
> int link (const char *);
>
> /* select.cc */
> diff --git a/winsup/cygwin/release/3.3.6 b/winsup/cygwin/release/3.3.6
> index 44a7bcf9d..b18691428 100644
> --- a/winsup/cygwin/release/3.3.6
> +++ b/winsup/cygwin/release/3.3.6
> @@ -26,3 +26,6 @@ Bug Fixes
> - Fix a console problem that the text longer than 1024 bytes cannot
> be pasted correctly.
> Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251764.html
> +
> +- Don't error out if getfacl(1) is called on a socket file.
> + Partially addresses: https://cygwin.com/pipermail/cygwin/2022-July/251768.html
> diff --git a/winsup/cygwin/sec_posixacl.cc b/winsup/cygwin/sec_posixacl.cc
> index e7e5a9c3e..c2daa3309 100644
> --- a/winsup/cygwin/sec_posixacl.cc
> +++ b/winsup/cygwin/sec_posixacl.cc
> @@ -633,6 +633,44 @@ fhandler_disk_file::acl_get (acl_type_t type)
> return acl;
> }
>
> +acl_t
> +fhandler_socket_local::acl_get (acl_type_t type)
> +{
> + if (!dev ().isfs ())
> + /* acl_get_fd on a socket. */
> + return fhandler_base::acl_get (type);
> +
> + /* acl_get_fd on a socket opened with O_PATH or acl_get_file on a
> + socket file. */
> + if (get_flags () & O_PATH)
> + {
> + set_errno (EBADF);
> + return NULL;
> + }
> + fhandler_disk_file fh (pc);
> + return fh.acl_get (type);
> +}
> +
> +#ifdef __WITH_AF_UNIX
> +acl_t
> +fhandler_socket_unix::acl_get (acl_type_t type)
> +{
> + if (!dev ().isfs ())
> + /* acl_get_fd on a socket. */
> + return fhandler_base::acl_get (type);
> +
> + /* acl_get_fd on a socket opened with O_PATH or acl_get_file on a
> + socket file. */
> + if (get_flags () & O_PATH)
> + {
> + set_errno (EBADF);
> + return NULL;
> + }
> + fhandler_disk_file fh (pc);
> + return fh.acl_get (type);
> +}
> +#endif
> +
> extern "C" acl_t
> acl_get_fd (int fd)
> {
> @@ -765,6 +803,44 @@ fhandler_disk_file::acl_set (acl_t acl, acl_type_t type)
> return ret;
> }
>
> +int
> +fhandler_socket_local::acl_set (acl_t acl, acl_type_t type)
> +{
> + if (!dev ().isfs ())
> + /* acl_set_fd on a socket. */
> + return fhandler_base::acl_set (acl, type);
> +
> + /* acl_set_fd on a socket opened with O_PATH or acl_set_file on a
> + socket file. */
> + if (get_flags () & O_PATH)
> + {
> + set_errno (EBADF);
> + return -1;
> + }
> + fhandler_disk_file fh (pc);
> + return fh.acl_set (acl, type);
> +}
> +
> +#ifdef __WITH_AF_UNIX
> +int
> +fhandler_socket_unix::acl_set (acl_t acl, acl_type_t type)
> +{
> + if (!dev ().isfs ())
> + /* acl_set_fd on a socket. */
> + return fhandler_base::acl_set (acl, type);
> +
> + /* acl_set_fd on a socket opened with O_PATH or acl_set_file on a
> + socket file. */
> + if (get_flags () & O_PATH)
> + {
> + set_errno (EBADF);
> + return -1;
> + }
> + fhandler_disk_file fh (pc);
> + return fh.acl_set (acl, type);
> +}
> +#endif
> +
> extern "C" int
> acl_set_fd (int fd, acl_t acl)
> {
> --
> 2.36.1
>
prev parent reply other threads:[~2022-07-04 8:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-03 18:37 Ken Brown
2022-07-04 8:39 ` 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=YsKnUOvT/jnv/8QD@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).