Subject: bug#33847: 27.0.50; emacsclient does not find server socket

From: Eli Zaretskii <[email-masked]>
Date: Thu, 22 Jul 2021 20:30:20 +0300

> From: Lars Ingebrigtsen <[email-masked]>
> Cc: [email-masked],  [email-masked],  [email-masked],  [email-masked]
> Date: Thu, 22 Jul 2021 19:05:11 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Looks like you didn't attach the right patch?
> 
> Yup; 2nd attempt now.

Thanks.

It looks like the w32-related aspect of this is easier to resolve than
I originally thought, because almost all of the changes are in the
SOCKETS_IN_FILE_SYSTEM part, which is not compiled for the MS-Windows
build.  The only potential issues I spotted are:

> --- a/lib-src/emacsclient.c
> +++ b/lib-src/emacsclient.c
> @@ -80,6 +80,7 @@ Copyright (C) 1986-1987, 1994, 1999-2021 Free Software Foundation, Inc.
>  #include <sys/stat.h>
>  #include <unistd.h>
>  
> +#include <acl.h>  <<<<<<<<<<<<<<<<<<<<<<<<<<<
>  #include <filename.h>
>  #include <intprops.h>
>  #include <min-max.h>

We cannot unconditionally include acl.h on MS-Windows, so this has to
be #ifdef'ed away.

> @@ -91,6 +92,10 @@ Copyright (C) 1986-1987, 1994, 1999-2021 Free Software Foundation, Inc.
>  # pragma GCC diagnostic ignored "-Wformat-truncation=2"
>  #endif
>  
> +#ifndef O_PATH
> +# define O_PATH O_SEARCH <<<<<<<<<<<<<<<<<<<<<<<<<
> +#endif

This is probably harmless, but I'd like to #ifdef it away as well.

> diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
> index 07736f9b8b..0b9aaf6d9e 100644
> --- a/lib/gnulib.mk.in
> +++ b/lib/gnulib.mk.in
> @@ -98,6 +98,7 @@
>  #  fcntl \
>  #  fcntl-h \
>  #  fdopendir \
> +#  file-has-acl \
>  #  filemode \
>  #  filename \
>  #  filevercmp \
> @@ -1788,6 +1789,16 @@ EXTRA_libgnu_a_SOURCES += fdopendir.c
>  endif
>  ## end   gnulib module fdopendir
>  
> +## begin gnulib module file-has-acl
> +ifeq (,$(OMIT_GNULIB_MODULE_file-has-acl))
> +
> +libgnu_a_SOURCES += file-has-acl.c
> +
> +EXTRA_DIST += acl-internal.h
> +
> +endif
> +## end   gnulib module file-has-acl
> +
>  ## begin gnulib module filemode
>  ifeq (,$(OMIT_GNULIB_MODULE_filemode))
>  

We need to add stuff to nt/gnulib-cfg.mk to omit building the
file-has-acl.c file on MS-Windows.  (I can do that after the rest is
installed.)

The only other worry is whether we indeed have ways to test this
thoroughly enough on Posix systems.