From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: Unable to get dbus.el to work with the Gentoo OpenRC 'emacs' service Date: Sat, 10 Jun 2023 18:16:36 +0200 Message-ID: <877csb1ee3.fsf@gmx.de> References: <87edmudofk.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24777"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Alexis Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 10 18:17:44 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q81Hb-0006Dd-NQ for ged-emacs-devel@m.gmane-mx.org; Sat, 10 Jun 2023 18:17:43 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q81Gf-0001bD-41; Sat, 10 Jun 2023 12:16:45 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q81Gd-0001az-En for emacs-devel@gnu.org; Sat, 10 Jun 2023 12:16:43 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q81Gb-0006qC-H2 for emacs-devel@gnu.org; Sat, 10 Jun 2023 12:16:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1686413797; x=1687018597; i=michael.albinus@gmx.de; bh=B/jUW6vjnLfp+c3ichEXSxmq1evquU0bgZ/fsyN0RP4=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=YB7GUGR8Y/qqikcmUfGxGJ/IP55OUgfeZpjaInRqo49TzZimGJXlv2tpoBH/jwvtI0UrqaE bsCghf3aYboQxRRCIgPYn/O7w6g18TbhRTBziilhXeWLyRWjxsYJeZgyZON6sJqa1fJWLzzB+ nUpnSEOecBZsVDs8p22K+k9//5vFW0np3k5kZeYHcSMzqdWQwp4cbngImifpnM6/5FEGrY8zK bY76HTcNefPGkr0nX0r3hkH4lydj+po1kP+l1jURBn9T473LbIws3A6A9cHyBmq2ukxeIKzom 54cYJi2qIwUEKJJqyQRitJ/6WZzp6NDnEvvxo1nWCyZwtKqSc+Fg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.13]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1My32F-1pwhsw2dLz-00zXWU; Sat, 10 Jun 2023 18:16:37 +0200 In-Reply-To: <87edmudofk.fsf@gmail.com> (Alexis's message of "Fri, 02 Jun 2023 22:39:52 +1000") X-Provags-ID: V03:K1:BJruPej5nKex8tRqVMHoGdHgw/K6qWsRvRB8CD9hR0btncQ+bQ4 /7b9sKQz3KzcO4UVkMActv1y0jxtAYSa2Z6G6887KdEOo2gZ1F6Py59JVRy6uR4rZzyGqhv e2EtkOXbuMx8/j5jktnmV+732bUCbZOQorj3C6TmzfwvB7PnAB4sNC+3v7yJfGQqOPUVJWp SsnzZSD/Jtignk/oT0NOQ== UI-OutboundReport: notjunk:1;M01:P0:ZTj0JwGXH0M=;IfMEAwwJgNwbc94jzCFtnAnGf3F tzmIhyeuud/I7HMLt7owvFkJpOCAPxcA0KJK0rDi4gXkhOcjD0ck8q/IGFTKkzoIvXXTKAaKB Ip5MyTQi/Nby44PpHR5AyVqno4M+YurZmnwUvCR73Nt+uzLaY2a47ewCku8BbQql3kwaqK42J CiDS74R0EPRflj1h7VKcUeN5acwzQVm5VXUzgA1PZ6UKSqml4rfo8jLqVOp3x0tSTWw3or4wx w7Dmjd2JDXXTEocqD/+RbVE9Z+wR9QPHtJ3jtnOrF0mZiO6wgNNH7T/tf5A+TPxh4eh4b/kZC 5dq9FRJPrgxWHUVFujio+56GP30c1J8oHRj6u+mgj8q7yvl9n/hHdZ+koZakheXKUGgnjyPAs VFWxDsIU2d/6O5krfJcQSgPa8nwCbtfjpGhYQZK0/VEnbKQ3yOffwMIiDCmv+fxQ1/1OkPeM/ cCeQOOAXIKDQX83WibKs74EcRYcZ0T4Xin2H01dq8gTR7Um3SW3elSM4IGz3uZa62W35OhFk9 SiFVtd5Xgg+0VzZ0oP8fPwsgnIl2FuQYbS+5TnboOjVl+oeySA7bNP910iBGeVtDhPBcu9S9E UrFjC65QLBkZFgcg8RCnZ7YAPY5kzxiv/pa1uW8M4ujpCSJdol41vlxUJGGw5EuJmwyJef1A8 7FOt2FcBTYheLp+j0Mhp5F0ezuama+5uC9c7zHTbcyXF8RZAPR1PU6X0WOo2+NRQ5VhF5SCD4 ncfu0f7lzQp7vREgcRcehdfyx9qW6DGGIiiWmYtut/alP6a+rq01tWHEQVQO7LqKqTDF9t+r Received-SPF: pass client-ip=212.227.17.20; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306722 Archived-At: --=-=-= Content-Type: text/plain Alexis writes: > Hi all, Hi Alexis, > For a while i've been manually starting an Emacs server on login (via > my .zlogin), after a D-Bus session has been started (also via my > .zlogin). However, i recently tried moving to the Gentoo OpenRC > service, and have run into a problem regarding D-Bus. > > The 'emacs' OpenRC service gets started at boot, prior to login. There > is thus no D-Bus session bus available at that time; the > DBUS_SESSION_BUS_ADDRESS env var isn't set. As noted above, this > changes once i log in; the DBUS_SESSION_BUS_ADDRESS variable gets > set. However, the Emacs server still thinks that var is unset. > > i had assumed that running: > > emacsclient --eval "(setenv \"DBUS_SESSION_BUS_ADDRESS\" > \"${DBUS_SESSION_BUS_ADDRESS}\")" > > in my WM startup script, to set that var in the environment of the > server process, would address this. > > However, while it addresses some issues - such as Emacs being able to > open a new tab in an existing Firefox instance - it doesn't seem to > affect the D-Bus environment in Emacs more generally: > > (dbus-get-unique-name :session) > -> (dbus-error "No connection to bus" :session) I can reproduce it. On my Fedora desktop, I have reproduced it with running from a shell --8<---------------cut here---------------start------------->8--- # unsetenv DBUS_SESSION_BUS_ADDRESS # emacs -Q --8<---------------cut here---------------end--------------->8--- If I now eval the following in the *scratch* buffer --8<---------------cut here---------------start------------->8--- (setenv "DBUS_SESSION_BUS_ADDRESS" "unix:path=/run/user/1000/bus") (dbus--init-bus :session) --8<---------------cut here---------------end--------------->8--- I get the same error like you --8<---------------cut here---------------start------------->8--- -> (dbus-error "No connection to bus" :session) --8<---------------cut here---------------end--------------->8--- Debugging Fdbus__init_bus in dbusbind.c shows, that the error happens in XD_DBUS_VALIDATE_BUS_ADDRESS. This macro calls on C level --8<---------------cut here---------------start------------->8--- getenv ("DBUS_SESSION_BUS_ADDRESS") --8<---------------cut here---------------end--------------->8--- However, the (setenv ...) form above is on Lisp level, and it writes the change into the internal Lisp variable process-environment. This doesn't match. > What am i missing? Or is it simply not possible to 'restart' dbus.el > from ELisp in order to get it to create a :session bus based on the > updated value of DBUS_SESSION_BUS_ADDRESS in the server process > environment? The appended patch has fixed this for me. Could you, please, check? > Alexis. Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/src/dbusbind.c b/src/dbusbind.c index d96b735c79a..96f9329a97e 100644 =2D-- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -276,7 +276,9 @@ XD_OBJECT_TO_STRING (Lisp_Object object) #define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \ do { \ - char const *session_bus_address =3D getenv ("DBUS_SESSION_BUS_ADDRESS= "); \ + Lisp_Object session_bus_address \ + =3D Fgetenv_internal (build_string ("DBUS_SESSION_BUS_ADDRESS"), \ + Qnil); \ if (STRINGP (bus)) \ { \ DBusAddressEntry **entries; \ @@ -289,9 +291,8 @@ #define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \ dbus_error_free (&derror); \ dbus_address_entries_free (entries); \ /* Canonicalize session bus address. */ \ - if ((session_bus_address !=3D NULL) \ - && (!NILP (Fstring_equal \ - (bus, build_string (session_bus_address))))) \ + if ((STRINGP (session_bus_address)) \ + && (!NILP (Fstring_equal (bus, session_bus_address)))) \ bus =3D QCsession; \ } \ \ @@ -304,7 +305,7 @@ #define XD_DBUS_VALIDATE_BUS_ADDRESS(bus) \ XD_SIGNAL2 (build_string ("Wrong bus name"), bus); \ /* We do not want to have an autolaunch for the session bus. */ \ if ((EQ (bus, QCsession) || EQ (bus, QCsession_private)) \ - && session_bus_address =3D=3D NULL) \ + && NILP (session_bus_address)) \ XD_SIGNAL2 (build_string ("No connection to bus"), bus); \ } \ } while (0) --=-=-=--