1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-03 08:30:09 +00:00
emacs/lib
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
..
malloc Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
_Noreturn.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
acl_entries.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
acl-errno-valid.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
acl-internal.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
acl-internal.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
acl.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
af_alg.h * Import lib/af_alg.h from gnulib 2020-08-23 11:52:49 +02:00
alloca.in.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
allocator.c
allocator.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
arg-nonnull.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
at-func.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
attribute.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
binary-io.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
binary-io.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
byteswap.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
c-ctype.c
c-ctype.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
c-strcase.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
c-strcasecmp.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
c-strncasecmp.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
c++defs.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
canonicalize-lgpl.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
careadlinkat.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
careadlinkat.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
cdefs.h Update from Gnulib by running admin/merge-gnulib 2021-01-23 11:37:49 -08:00
cloexec.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
cloexec.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
close-stream.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
close-stream.h
copy-file-range.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
COPYING Merge from Gnulib 2017-10-01 18:31:10 -07:00
count-leading-zeros.c logb now works correctly on large integers 2017-03-03 09:19:08 -08:00
count-leading-zeros.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
count-one-bits.c
count-one-bits.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
count-trailing-zeros.c
count-trailing-zeros.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
diffseq.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
dirent.in.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
dirfd.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
dtoastr.c
dtotimespec.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
dup2.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
dynarray.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
eloop-threshold.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
errno.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
euidaccess.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
execinfo.c
execinfo.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
explicit_bzero.c Update from Gnulib by running admin/merge-gnulib 2021-01-23 11:37:49 -08:00
faccessat.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fchmodat.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
fcntl.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fcntl.in.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fdopendir.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
file-has-acl.c Redo emacsclient socket symlink-attack checking 2021-07-23 13:33:37 +02:00
filemode.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
filemode.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
filename.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
filevercmp.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
filevercmp.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fingerprint.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fingerprint.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
flexmember.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fpending.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fpending.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
free.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
fstatat.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fsusage.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
fsusage.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
fsync.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
ftoastr.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
ftoastr.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
futimens.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
get-permissions.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getdtablesize.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getgroups.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
getloadavg.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
getopt1.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt_int.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt-cdefs.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt-core.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt-ext.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt-pfx-core.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt-pfx-ext.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getopt.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
getrandom.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
gettext.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
gettime.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
gettimeofday.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
gnulib.mk.in Redo emacsclient socket symlink-attack checking 2021-07-23 13:33:37 +02:00
group-member.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
idx.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
ieee754.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
ignore-value.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
intprops.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
inttypes.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
lchmod.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
libc-config.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
limits.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
lstat.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
Makefile.in * lib/Makefile.in (Makefile): Fix typo. 2021-06-09 09:51:45 -07:00
malloca.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
malloca.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
md5.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
md5.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
memmem.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
mempcpy.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
memrchr.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
min-max.h
mini-gmp-gnulib.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mini-gmp.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
mini-gmp.h Update Gnulib. 2020-12-25 02:36:03 -08:00
minmax.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mkostemp.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
mktime-internal.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
mktime.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
nstrftime.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
open.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
openat-die.c
openat-priv.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
openat-proc.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
openat.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pathmax.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pipe2.c Convert many more links to use HTTPS 2021-03-24 10:20:18 +01:00
pselect.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
pthread_sigmask.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
qcopy-acl.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
rawmemchr.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
rawmemchr.valgrind Update copyright year to 2021 2021-01-01 01:13:56 -08:00
readlink.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
readlinkat.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
regcomp.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
regex_internal.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
regex_internal.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
regex.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
regex.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
regexec.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
root-uid.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
save-cwd.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
save-cwd.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
scratch_buffer.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
set-permissions.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha1.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
sha1.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha256.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha256.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha512.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sha512.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sig2str.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
sig2str.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sigdescr_np.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
signal.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stat-time.c
stat-time.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stdalign.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stddef.in.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
stdint.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stdio-impl.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
stdio.in.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
stdlib.in.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
stpcpy.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
str-two-way.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
strftime.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
string.in.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
strnlen.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
strtoimax.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
strtol.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
strtoll.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
symlink.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_random.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_select.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_stat.in.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
sys_time.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
sys_types.in.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
tempname.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
tempname.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
time_r.c Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
time_rz.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
time-internal.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
time.in.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
timegm.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
timespec-add.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
timespec-sub.c Update copyright year to 2021 2021-01-01 01:13:56 -08:00
timespec.c
timespec.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
u64.c
u64.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
unistd.c
unistd.in.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00
unlocked-io.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
utimens.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
utimens.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
utimensat.c Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
verify.h Update from Gnulib by running admin/merge-gnulib 2021-01-22 12:02:55 -08:00
vla.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
warn-on-use.h Update copyright year to 2021 2021-01-01 01:13:56 -08:00
xalloc-oversized.h Update from Gnulib by running admin/merge-gnulib. 2021-01-01 01:52:03 -08:00