1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-26 07:33:47 +00:00
emacs/m4
Paul Eggert 007744dd04 Redo emacsclient socket symlink-attack checking
* admin/merge-gnulib (GNULIB_MODULES): Add file-has-acl.
* lib/file-has-acl.c: New file, copied from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib-src/emacsclient.c: Include acl.h, for file_has_acl.
(O_PATH): Default to O_SEARCH, which is good enough here.
(union local_sockaddr): New type.
(socket_status): Remove, replacing with ...
(connect_socket): New function.  All callers changed.
This function checks for ownership and permissions issues with the
parent directory of the socket file, instead of checking the
owner of the socket (which does not help security).
(socknamesize): Move to file scope.
(local_sockname): New arg S.  No need to pass socknamesize.
UID arg is now uid_t.  All callers changed.  Get file descriptor
of parent directory of socket, to foil some symlink attacks.
Do not follow symlinks to that directory.
(set_local_socket): Create the socket here instead of on
each attempt to connect it.  Fall back from XDG_RUNTIME_DIR
to /tmp only if the former fails due to ENOENT.  Adjust
permission-failure diagnostic to match changed behavior.

This addresses Bug#33847, which complained about emacsclient in a
safer XDG environment not connecting to an Emacs server running in
a less-safe enviroment outside XDG.  The patch fixes a
longstanding issue with emacsclient permission checking.
It’s ineffective to look at the permission of the socket file
itself; on some platforms, these permissions are ignored anyway.
What matters are the permissions on the parent directory of the
socket file, as these are what make symlink attacks possible.
Change the permissions check accordingly, and also refuse to
follow symlinks to that parent directory.  These changes make it
OK for emacsclient to fall back from XDG_RUNTIME_DIR to the
traditionally less-safe /tmp/emacsNNNN directories, since /tmp is
universally sticky nowadays.
2021-07-23 13:33:37 +02:00
..
__inline.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
00gnulib.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
absolute-header.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
acl.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
alloca.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
builtin-expect.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
byteswap.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
canonicalize.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
clock_time.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
close-stream.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
copy-file-range.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
d-type.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
dirent_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
dirfd.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
double-slash-root.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
dup2.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
eealloc.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
environ.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
errno_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
euidaccess.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
execinfo.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
explicit_bzero.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
extensions.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
extern-inline.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
faccessat.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fchmodat.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
fcntl_h.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fcntl.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fdopendir.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
filemode.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
flexmember.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fpending.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fpieee.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
free.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fstatat.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fsusage.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fsync.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
futimens.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getdtablesize.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getgroups.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
getloadavg.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
getopt.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getrandom.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
gettime.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
gettimeofday.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
glibc21.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
gnulib-common.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
gnulib-comp.m4 Redo emacsclient socket symlink-attack checking 2021-07-23 13:33:37 +02:00
group-member.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
ieee754-h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
include_next.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
inttypes.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
largefile.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
lchmod.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
libgmp.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
limits-h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
lstat.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
malloca.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
manywarnings.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mbstate_t.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
md5.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
memmem.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mempcpy.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
memrchr.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
minmax.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mkostemp.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mktime.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
mode_t.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
multiarch.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
nocrash.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
nstrftime.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
off_t.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
open-cloexec.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
open-slash.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
open.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pathmax.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
pid_t.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pipe2.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pkg.m4 ; Fix more typos 2020-10-03 12:53:51 +02:00
pselect.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pthread_sigmask.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
rawmemchr.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
readlink.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
readlinkat.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
regex.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
sha1.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha256.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha512.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sig2str.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
sigdescr_np.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
signal_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
socklen.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
ssize_t.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
st_dm_mode.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stat-time.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
std-gnu11.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stdalign.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stddef_h.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
stdint.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stdio_h.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
stdlib_h.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
stpcpy.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
string_h.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
strnlen.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
strtoimax.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
strtoll.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
symlink.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_random_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_select_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_socket_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_stat_h.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
sys_time_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_types_h.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
tempname.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
time_h.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
time_r.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
time_rz.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
timegm.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
timer_time.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
timespec.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
tm_gmtoff.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
unistd_h.m4 Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
unlocked-io.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
utimens.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
utimensat.m4 Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
utimes.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
vararrays.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
warnings.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
wchar_t.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00
zzgnulib.m4 Update copyright year to 2021 2021-01-01 01:13:56 -08:00