all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in.
@ 2024-01-04 19:52 Jeremy Phelps
  2024-01-05 11:47 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Phelps @ 2024-01-04 19:52 UTC (permalink / raw)
  To: 68255

1. Configure your session manager not to kill leftover user processes
   after logging out. If you're using elogind, this can be done by
   editing /etc/elogind/logind.conf and setting KillUserProcesses=no.
   Same process for systemd-logind, except the file is located
   at /etc/systemd/logind.conf.
2. Log into a new session and run "emacs --daemon".
3. Log out of all sessions for that user. This causes the directory
   named in $XDG_RUNTIME_DIR to be deleted, and with it, the Emacs
   daemon's socket.
4. Log back in.
5. Observe that the emacs daemon's process is still there, and that
   its socket is gone.

Working around this problem is difficult because the XDG_RUNTIME_DIR
variable whose use causes this problem is referenced in two places:

1. The "server-socket-dir" variable in Elisp. This is fairly easy to
   change because Emacs can take you right to the definition.
2. The emacsclient binary. Changing the behavior here requires
   editing emacsclient.c, recompiling, and installing the resulting
   binary. Except it's too hard to get Emacs to build on modern
   Linux distros, so I hex-edited the emacsclient binary instead,
   NUL-ing out all strings containing "XDG_RUNTIME_DIR".

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37,
cairo version 1.16.0)
 of 2023-05-13, modified by Debian built on x86-ubc-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Devuan GNU/Linux 5 (daedalus)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --with-cairo --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/emacs-mPr7Vr/emacs-28.2+1=. -fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  shell-dirtrack-mode: t
  iswitchb-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/elpa/slime-2.27/slime-tests hides
/usr/share/emacs/site-lisp/elpa-src/slime-2.27/slime-tests
/usr/share/emacs/site-lisp/elpa/slime-2.27/slime hides
/usr/share/emacs/site-lisp/elpa-src/slime-2.27/slime
/usr/share/emacs/site-lisp/elpa/slime-2.27/slime-pkg hides
/usr/share/emacs/site-lisp/elpa-src/slime-2.27/slime-pkg
/usr/share/emacs/site-lisp/elpa/slime-2.27/slime-autoloads hides
/usr/share/emacs/site-lisp/elpa-src/slime-2.27/slime-autoloads
/home/jlp/.emacs.d/elpa/transient-20200107.2156/transient hides
/usr/share/emacs/28.2/lisp/transient

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils misearch multi-isearch apropos face-remap
cus-edit cus-start cus-load wid-edit ob-ruby ob-lisp ob-clojure ob-awk
ob-python python tramp-sh tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time ls-lisp ob-scheme
ob-shell shell org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-footnote org-src ob-comint org-pcomplete pcomplete org-list
org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval
org-table oc-basic bibtex iso8601 time-date ol org-keys oc org-compat
org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs iswitchb slime-fancy slime-indentation slime-cl-indent
cl-indent slime-trace-dialog slime-fontifying-fu slime-package-fu
slime-references slime-compiler-notes-tree slime-scratch
slime-presentations bridge slime-macrostep macrostep slime-mdot-fu
slime-enclosing-context slime-fuzzy slime-fancy-trace
slime-fancy-inspector slime-c-p-c slime-editing-commands slime-autodoc
slime-repl elp slime-parse slime compile text-property-search etags
fileloop generator xref project arc-mode archive-mode noutline outline
pp comint ansi-color ring hyperspec thingatpt image+ image-file
image-converter unicode-math-input quail comp comp-cstr rx git-blame
amber-theme cl-extra help-mode cyberpunk-theme rainbow-delimiters
easy-mmode yaml-mode derived edmacro kmacro warnings advice cl
finder-inf info slime-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 480397 22320)
 (symbols 48 28109 1)
 (strings 32 128262 12974)
 (string-bytes 1 4201587)
 (vectors 16 44072)
 (vector-slots 8 750050 47045)
 (floats 8 200 256)
 (intervals 56 760 0)
 (buffers 992 13))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in.
  2024-01-04 19:52 bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in Jeremy Phelps
@ 2024-01-05 11:47 ` Eli Zaretskii
       [not found]   ` <E2A1F4CF-2AC7-4772-8398-4A64EB5B40BB@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-01-05 11:47 UTC (permalink / raw)
  To: Jeremy Phelps; +Cc: 68255

> From: Jeremy Phelps <jeremyphelps077@gmail.com>
> Date: Thu, 4 Jan 2024 14:52:17 -0500
> 
> 1. Configure your session manager not to kill leftover user processes
>    after logging out. If you're using elogind, this can be done by
>    editing /etc/elogind/logind.conf and setting KillUserProcesses=no.
>    Same process for systemd-logind, except the file is located
>    at /etc/systemd/logind.conf.
> 2. Log into a new session and run "emacs --daemon".
> 3. Log out of all sessions for that user. This causes the directory
>    named in $XDG_RUNTIME_DIR to be deleted, and with it, the Emacs
>    daemon's socket.
> 4. Log back in.
> 5. Observe that the emacs daemon's process is still there, and that
>    its socket is gone.
> 
> Working around this problem is difficult because the XDG_RUNTIME_DIR
> variable whose use causes this problem is referenced in two places:
> 
> 1. The "server-socket-dir" variable in Elisp. This is fairly easy to
>    change because Emacs can take you right to the definition.
> 2. The emacsclient binary. Changing the behavior here requires
>    editing emacsclient.c, recompiling, and installing the resulting
>    binary. Except it's too hard to get Emacs to build on modern
>    Linux distros, so I hex-edited the emacsclient binary instead,
>    NUL-ing out all strings containing "XDG_RUNTIME_DIR".

I'm not sure I understand why you cannot successfully use the daemon
in the situation you described.  Basically, what your scenario means
is that XDG_RUNTIME_DIR cannot be trusted because it is ephemeral, so
you need to tell Emacs and emacsclient to use a directory for a socket
in a way that doesn't use XDG_RUNTIME_DIR.  Is that correct?

If the above analysis is correct, then you can customize 'server-name'
to be an absolute file name of the directory where you want the socket
to be created, and invoke emacsclient with the --socket-name=NAME
option (or set EMACS_SOCKET_NAME=NAME in the environment), where NAME
is the same directory as in the value of 'server-name' option.  Did
you try that?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in.
       [not found]   ` <E2A1F4CF-2AC7-4772-8398-4A64EB5B40BB@gmail.com>
@ 2024-01-06  6:54     ` Eli Zaretskii
  2024-02-11  8:50       ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-01-06  6:54 UTC (permalink / raw)
  To: Jeremy Phelps; +Cc: 68255

[Please use Reply All to reply, to keep the bug tracker CC'ed.]

> From: Jeremy Phelps <jeremyphelps077@gmail.com>
> Date: Fri, 5 Jan 2024 15:13:43 -0500
> 
> > If the above analysis is correct, then you can customize 'server-name'
> > to be an absolute file name of the directory where you want the socket
> > to be created, and invoke emacsclient with the --socket-name=NAME
> > option (or set EMACS_SOCKET_NAME=NAME in the environment), where NAME
> > is the same directory as in the value of 'server-name' option.  Did
> > you try that?
> 
> I did not try that, and I wouldn't be able to test it without reinstalling Emacs
> to get rid of my workaround.

Well, I'd encourage you to try this, because if it works, then there
is a solution to this situation, and if it doesn't work, we need to
fix whatever prevents it from working.

> But given that XDG_RUNTIME_DIR is ephemeral, and
> the Emacs daemon assumes it is not, it makes little sense to use it. It would
> make more sense to create a directory under ~/.emacs.d if security is the
> reason for using the XDG directory instead of /tmp.

I hear you, but other people disagree.  Some don't need to leave the
Emacs daemon running when they log off, and some say (AFAIU) that the
XDG directories don't get deleted when they log off.  So we support
both methods, and the XDG support takes precedence because most users
prefer it, AFAIU.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in.
  2024-01-06  6:54     ` Eli Zaretskii
@ 2024-02-11  8:50       ` Eli Zaretskii
  2024-02-17  8:34         ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2024-02-11  8:50 UTC (permalink / raw)
  To: jeremyphelps077; +Cc: 68255

> Cc: 68255@debbugs.gnu.org
> Date: Sat, 06 Jan 2024 08:54:24 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> [Please use Reply All to reply, to keep the bug tracker CC'ed.]
> 
> > From: Jeremy Phelps <jeremyphelps077@gmail.com>
> > Date: Fri, 5 Jan 2024 15:13:43 -0500
> > 
> > > If the above analysis is correct, then you can customize 'server-name'
> > > to be an absolute file name of the directory where you want the socket
> > > to be created, and invoke emacsclient with the --socket-name=NAME
> > > option (or set EMACS_SOCKET_NAME=NAME in the environment), where NAME
> > > is the same directory as in the value of 'server-name' option.  Did
> > > you try that?
> > 
> > I did not try that, and I wouldn't be able to test it without reinstalling Emacs
> > to get rid of my workaround.
> 
> Well, I'd encourage you to try this, because if it works, then there
> is a solution to this situation, and if it doesn't work, we need to
> fix whatever prevents it from working.

Any progress with this?

Thanks.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in.
  2024-02-11  8:50       ` Eli Zaretskii
@ 2024-02-17  8:34         ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-02-17  8:34 UTC (permalink / raw)
  To: jeremyphelps077; +Cc: 68255

Ping! Could you please try the suggestion below, so we could make some
progress in handling this bug?  TIA.

> Cc: 68255@debbugs.gnu.org
> Date: Sun, 11 Feb 2024 10:50:27 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> 
> > Cc: 68255@debbugs.gnu.org
> > Date: Sat, 06 Jan 2024 08:54:24 +0200
> > From: Eli Zaretskii <eliz@gnu.org>
> > 
> > [Please use Reply All to reply, to keep the bug tracker CC'ed.]
> > 
> > > From: Jeremy Phelps <jeremyphelps077@gmail.com>
> > > Date: Fri, 5 Jan 2024 15:13:43 -0500
> > > 
> > > > If the above analysis is correct, then you can customize 'server-name'
> > > > to be an absolute file name of the directory where you want the socket
> > > > to be created, and invoke emacsclient with the --socket-name=NAME
> > > > option (or set EMACS_SOCKET_NAME=NAME in the environment), where NAME
> > > > is the same directory as in the value of 'server-name' option.  Did
> > > > you try that?
> > > 
> > > I did not try that, and I wouldn't be able to test it without reinstalling Emacs
> > > to get rid of my workaround.
> > 
> > Well, I'd encourage you to try this, because if it works, then there
> > is a solution to this situation, and if it doesn't work, we need to
> > fix whatever prevents it from working.
> 
> Any progress with this?
> 
> Thanks.
> 
> 
> 
> 





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-17  8:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04 19:52 bug#68255: 28.2; Can't connect to emacs daemon after logging out and back in Jeremy Phelps
2024-01-05 11:47 ` Eli Zaretskii
     [not found]   ` <E2A1F4CF-2AC7-4772-8398-4A64EB5B40BB@gmail.com>
2024-01-06  6:54     ` Eli Zaretskii
2024-02-11  8:50       ` Eli Zaretskii
2024-02-17  8:34         ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.