From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CPnHMXrdLGIgOgAAgWs5BA (envelope-from ) for ; Sat, 12 Mar 2022 18:50:50 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id YHw6KnrdLGLziAAAG6o9tA (envelope-from ) for ; Sat, 12 Mar 2022 18:50:50 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 293CE1383A for ; Sat, 12 Mar 2022 18:50:50 +0100 (CET) Received: from localhost ([::1]:57636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nT5tB-0004Jy-8R for larch@yhetil.org; Sat, 12 Mar 2022 12:50:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nT5sQ-0004Jb-Jf for guix-devel@gnu.org; Sat, 12 Mar 2022 12:50:02 -0500 Received: from [2a00:1450:4864:20::12e] (port=36359 helo=mail-lf1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nT5sO-0004tp-RY for guix-devel@gnu.org; Sat, 12 Mar 2022 12:50:02 -0500 Received: by mail-lf1-x12e.google.com with SMTP id bt26so20362198lfb.3 for ; Sat, 12 Mar 2022 09:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=mUZYbyJ92SMFhpGJadtT9KSAMhGv61fYyipQ6MZx+Ic=; b=W9yOTaVCjvj6BNO5FPqtu05XWzjxRC1Es61MtQkNiuloAuPwBzJZuzeW/AEE2TW8m+ fmki0dPaccxFhNtb2ZWiFK606YDISeDPLzIVlb7KgPblNxggaIj2AF2v/9ahZyU1SzVj ihxJd+HNpZJTOKo4JTOqBzoQiLqRXHy3Q5bmMLseX1YhvKEx4gM6ZMBZVQY/cNT0JNSE W8AKZ4v6IpNiRt9Q6f7CN/ffFAejrzWzxZVguKabJGSBMCL1bTOZ8wHiR5FQMpdDtVVS SH2Um3X3AuGUsLF6ou9Xt+2nkpD6XA322V4oV18c4fVv2hvUK2V0ipFPd5ORUET9AO32 lMOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=mUZYbyJ92SMFhpGJadtT9KSAMhGv61fYyipQ6MZx+Ic=; b=j3jf4472/kTO3xqecDDF0Qe182RPiyHxu3uSPnUxWRSLWKzGrUwy7+1U9pYHC5w/mZ n2+z3Hu8E9RSBeS1IbLQWwsdGdmr1GkZawbt04ds0lYxnZ29yJVinY8yQfki8p2joQ3C xG+FvVaYlM0w29vgQSX4mS+CeSUfWYSqCTKyhtnltB3IQq1BuxQvsIvLIUlimabqsYpk n1pEt7yUBGNPUB07ESGgOyJZ9KJYOkXnpGFeNlcCwtm2nEX10AlI3PUQuNLTr6u7hZ8L Tp7t4t0mcg7vJofekG6bjCP2nbcTnyXj3areOUkgkmnWn3h/xGfaL4Fv+75lq2CT5Qll MliA== X-Gm-Message-State: AOAM530Y6VTpEYWZzHkO96ovzHM9Rr5hpts1M2f57UQd19JknZf8HZ8S U4TtryjAd9zrJrwRoWTqK/pwoLCTlaG30QkqGqiC3nnT2Y4= X-Google-Smtp-Source: ABdhPJyM4RUocV224mTmrTPyPx6qTKkzjjhSHVoZ/JxByXTxZbS7lFkFQYl755pBSZN08lPyVyn8rpOf6PEYYVDR80k= X-Received: by 2002:a19:741a:0:b0:445:b9e7:6f1f with SMTP id v26-20020a19741a000000b00445b9e76f1fmr8948280lfe.504.1647107398244; Sat, 12 Mar 2022 09:49:58 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kevin Boulain Date: Sat, 12 Mar 2022 18:49:21 +0100 Message-ID: Subject: Re: Should Guix Home daemonize Shepherd? To: guix-devel@gnu.org Content-Type: multipart/mixed; boundary="00000000000061415a05da09133f" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::12e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=kevinboulain@gmail.com; helo=mail-lf1-x12e.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647107450; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=mUZYbyJ92SMFhpGJadtT9KSAMhGv61fYyipQ6MZx+Ic=; b=ML46Cz4yxvxrXq4XpNNtWb7Du/gvAP8efLnVre2G3MLCFgnVWdbsGZ6RJQ/tZNmbzrqSPu msC8uBqfsirrMKOkikgwO0x+yvfC+pegHPEBPoIANcpKYmchMo+JZSDLIpC6l406OWXsoN sSRhPBrx2tRBSPFxsQGGmpRTw/vjsaXb7s7TbxBA/3h5mGSQ3wtAZBMqDUgXgtEXzzZgPb HmdiDbh3LlHklgEUOLfiKhiED0AWCES1+fG/ho+imAGG0pu7CCu/sZXPQ3NljNhLRB/Coj uL6LW/a0w2fo7sjI9HCCrBwKF54j9i2tCXrOR8M+hdxWXFvh5tubARbhzrIhpA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647107450; a=rsa-sha256; cv=none; b=fkdLk61Fb3qqnf8W33z0gjLWfbp+Mw+Q8+4RgG9jZu0i2N31TWWdZddvcNEvJ0wsahmhlQ Gwk54BmLxHdMTMH/rNnXJmz13nFGmtjYjLaOAyfVp8rG1S3Mpt2ppiCuv+u6Ksmp4PUwgL OsiJJxIWM/FHosjZomqeXskzxrQO4JavCc1/l4R9WN07nGxMPATerAiD32jxT8xxwNdI1L v9sXjLBagjePeYS+CieXIMKyrh4eKXx2u/+MELRpDygD/qVeYVAkjA2wyYgZNiaDMXjrcG luQr8aGMo4XLZTxE9I3ZvXjGU7BD7/HxWekPNCCyvKjdjHIz+c5R4Tu8moOuTA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=W9yOTaVC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.18 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=W9yOTaVC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 293CE1383A X-Spam-Score: -3.18 X-Migadu-Scanner: scn1.migadu.com X-TUID: AuHZfHIK46EW --00000000000061415a05da09133f Content-Type: text/plain; charset="UTF-8" So, I've done some digging and I'm coming back with two findings :) First, Guix Home correctly tells the user Shepherd to daemonize itself via an 'action' (https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/home/services/shepherd.scm#n64) but, from my understanding, the daemonization process is missing at least a setsid call (https://git.savannah.gnu.org/cgit/shepherd.git/tree/modules/shepherd/service.scm#n1421), see the attached 'shepherd-setsid.patch'. This fixes the Shepherd dying when exiting the SSH session or the Shepherd catching the ^C. I guess it should also close std{in,out,err} like it's done for the regular services (https://git.savannah.gnu.org/cgit/shepherd.git/tree/modules/shepherd/service.scm#n806) but this answers a part of my initial post. Second, elogind (it's required by Guix Home to get the XDG_* environment variables and also part of %desktop-services) will remove /run/user/$uid when the session ends. It's standard, but the problem is that Guix Home's 'on-first-login-executed' is located there, alongside 'shepherd/socket' and probably the other user daemon's sockets. This easily results in duplicate services being rerun when the old ones haven't been killed because 'KillUserProcesses' is set to 'no' by default (https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/desktop.scm#n937). I don't think it's a bad idea to set KillUserProcesses=no (I remember that when this was first introduced a lot of users complained, see for example https://github.com/tmux/tmux/issues/428) but now we're in an awkward position unless Guix Home users move everything out of XDG_RUNTIME_DIR (for example, tmux's socket is in /tmp). Thoughts? I must admit, I'm not sure how to address the elogind issue, XDG_RUNTIME_DIR is ingrained in a lot of places (even in the Shepherd https://git.savannah.gnu.org/cgit/shepherd.git/tree/modules/shepherd/support.scm#n284) and asking users to override socket flags (and others) for all the services they run (if at all possible) sounds a bit counterintuitive. Or am I missing something obvious? --00000000000061415a05da09133f Content-Type: application/octet-stream; name="shepherd-setsid.patch" Content-Disposition: attachment; filename="shepherd-setsid.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l0o3qpcq0 RGV0YWNoIGZyb20gdGhlIGNvbnRyb2xsaW5nIHRlcm1pbmFsIHdoZW4gZGFlbW9uaXppbmcKCmh0 dHBzOi8vbGlzdHMuZ251Lm9yZy9hcmNoaXZlL2h0bWwvZ3VpeC1kZXZlbC8yMDIyLTAzL21zZzAw MDQwLmh0bWwKCmRpZmYgLS1naXQgYy9tb2R1bGVzL3NoZXBoZXJkL3NlcnZpY2Uuc2NtIHcvbW9k dWxlcy9zaGVwaGVyZC9zZXJ2aWNlLnNjbQppbmRleCBhZDg2MDhiLi42MmY5N2JjIDEwMDY0NAot LS0gYy9tb2R1bGVzL3NoZXBoZXJkL3NlcnZpY2Uuc2NtCisrKyB3L21vZHVsZXMvc2hlcGhlcmQv c2VydmljZS5zY20KQEAgLTE0MjAsOCArMTQyMCwxMiBAQCB3ZSB3YW50IHRvIHJlY2VpdmUgdGhl c2Ugc2lnbmFscy4iCiAgICAgICAgICAgKGVsc2UKICAgICAgICAgICAgKGlmICh6ZXJvPyAocHJp bWl0aXZlLWZvcmspKQogICAgICAgICAgICAgICAgKGJlZ2luCi0gICAgICAgICAgICAgICAgIChj YXRjaC1zeXN0ZW0tZXJyb3IgKHByY3RsIFBSX1NFVF9DSElMRF9TVUJSRUFQRVIgMSkpCi0gICAg ICAgICAgICAgICAgICN0KQorICAgICAgICAgICAgICAgICAoc2V0c2lkKQorICAgICAgICAgICAg ICAgICAoaWYgKHplcm8/IChwcmltaXRpdmUtZm9yaykpCisgICAgICAgICAgICAgICAgICAgICAo YmVnaW4KKyAgICAgICAgICAgICAgICAgICAgICAgKGNhdGNoLXN5c3RlbS1lcnJvciAocHJjdGwg UFJfU0VUX0NISUxEX1NVQlJFQVBFUiAxKSkKKyAgICAgICAgICAgICAgICAgICAgICAgI3QpCisg ICAgICAgICAgICAgICAgICAgICAocHJpbWl0aXZlLWV4aXQgMCkpKQogICAgICAgICAgICAgICAg KHByaW1pdGl2ZS1leGl0IDApKSkpKSkKICAgICAgKHBlcnNpc3RlbmN5CiAgICAgICAiU2F2ZSB0 aGUgY3VycmVudCBzdGF0ZSBvZiBydW5uaW5nIGFuZCBub24tcnVubmluZyBzZXJ2aWNlcy4K --00000000000061415a05da09133f--