From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cw9XM0w2W2BATQAA0tVLHw (envelope-from ) for ; Wed, 24 Mar 2021 12:53:32 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 8GmzLkw2W2DlMQAAB5/wlQ (envelope-from ) for ; Wed, 24 Mar 2021 12:53:32 +0000 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 3E2EC21F07 for ; Wed, 24 Mar 2021 13:53:32 +0100 (CET) Received: from localhost ([::1]:57992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lP30t-0000Vu-9p for larch@yhetil.org; Wed, 24 Mar 2021 08:53:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lP30T-0000Uk-F6 for guix-patches@gnu.org; Wed, 24 Mar 2021 08:53:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lP30R-0008KK-34 for guix-patches@gnu.org; Wed, 24 Mar 2021 08:53:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lP30R-0004Xc-1q for guix-patches@gnu.org; Wed, 24 Mar 2021 08:53:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47323] [PATCH] services: export sysctl-configuration record field accessors References: <877dlzb17k.fsf@muradm.net> In-Reply-To: <877dlzb17k.fsf@muradm.net> Resent-From: muradm Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 24 Mar 2021 12:53:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47323 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 47323@debbugs.gnu.org Received: via spool by 47323-submit@debbugs.gnu.org id=B47323.161659032517353 (code B ref 47323); Wed, 24 Mar 2021 12:53:03 +0000 Received: (at 47323) by debbugs.gnu.org; 24 Mar 2021 12:52:05 +0000 Received: from localhost ([127.0.0.1]:34230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP2zU-0004Vj-Nh for submit@debbugs.gnu.org; Wed, 24 Mar 2021 08:52:05 -0400 Received: from mail-wr1-f54.google.com ([209.85.221.54]:36716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lP1iC-0000PE-7n for 47323@debbugs.gnu.org; Wed, 24 Mar 2021 07:30:09 -0400 Received: by mail-wr1-f54.google.com with SMTP id k8so24059756wrc.3 for <47323@debbugs.gnu.org>; Wed, 24 Mar 2021 04:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=muradm-net.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=zhPmqa/hYID/bjj8aRiFfMTdSbWyhfX9dJVDEsZO37s=; b=j4fAWuBfnjsgniowXVvVZ9Mz4NR3FCsO5lT67HL5tSqdcL7bqFOqSafHXL8DoKuAYc bfwpc9CeLkAE/z4vGApB7BJEM/aNxVRT4z0naOcl4LHwPATVqm1YSbCN05jA7aJuA0Qv WsMaElC1FNCxxWkb3oSCT90teVz602Y8AC+5CQGtooKeUEvO6wgZ1u/mFDDz16+os6va vE5snTQWRa30bGPHXr3HJNbqTv1FG6oQ5YQ1Y1i2sIUk9PmUAX65xdxYtq5dna+SMKLA RqyH9RGcyIIKZDxjfGxaJTS9IML7fQgZf69AbVoMJ7SA3U6SFlPSYY6LObvYs70FCSiJ hpbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=zhPmqa/hYID/bjj8aRiFfMTdSbWyhfX9dJVDEsZO37s=; b=tB7gPBR6ZEK+Tthtw2nwN9K4a/Vjm2LY7JzKptusHTyvoze98AXfDZuyjJz1XBbPyn 4/JEP1H1ZJjiF5eUrQ4k7Rqu6aXUS+7fELEeGV4mZD1GehmTAygncNx0qiVqN5RUgFcM cvm7+lPnH3cFDQIsoqFIt2OIRy6LcueF1RzxeJbEueslmzhb37lmWWSGtbzmeTlnZQP3 IxWgsfStKZxFjns27XWfrMQl6zvAP4U6ydX1WW4w5qndAULCoKGj14P7p+QmaJkdsqyg uGCaq+CICl97ZTCF3FjSByQyABClOW9EOAOEJiQeltgqRjpb3Dv3+hljjRRJ3Yw1TnH7 wvWQ== X-Gm-Message-State: AOAM533auk+4BJvl05p7iHMjxVfUuotgscxBrHRDa1Icqc9RKSICrULf JTv5/H3FnnNQmy5I7JHsm/i3JPDMdyMNzj77 X-Google-Smtp-Source: ABdhPJxmvY2FKkniKDbxgV123z66Hp2yl0vS9V+hvMp9gOOCkxgu1LPv8za6Y3qFbpL2SKgq8Ujm3A== X-Received: by 2002:a05:6000:2c4:: with SMTP id o4mr2955477wry.190.1616585401919; Wed, 24 Mar 2021 04:30:01 -0700 (PDT) Received: from localhost ([217.131.81.96]) by smtp.gmail.com with ESMTPSA id b17sm2826049wrt.17.2021.03.24.04.30.00 for <47323@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 04:30:01 -0700 (PDT) Date: Wed, 24 Mar 2021 14:29:59 +0300 From: muradm Message-ID: <20210324112959.24dg3ywekxdrodes@muradm-aln1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline X-Mailman-Approved-At: Wed, 24 Mar 2021 08:51:39 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616590412; 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:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=zhPmqa/hYID/bjj8aRiFfMTdSbWyhfX9dJVDEsZO37s=; b=LNlhDVUTEVxD4OCjJuEqx3uiF1OG7A6c0YCzpFr+GaFh6F8ilNmv+wyyhke7aB7mJSwkE/ rsiiivO9foSQahSBf4laNolbnDpzjzF0Jt8IYi0nRTPOKIoEJ1Q+KxhV6lKSDf7mXg/L0T r2BSJET/UoGTOaRD8iJpXaH+Uut71uPxVM3bcJI2qsHbvWKa2eBSI6Bgvv12G3in/zVq2b OFg1IWShdAQpCKPLH1jRgpEtpwYbLcursAiCHks47gZPvtFsH5ErqtfkPnKLkfA08kNdE4 onViNxApRqI/u0o4dV1ghXx44Mgu/GoF/fhrVK9ESGI33rrCnVMTXKBpcFmLFA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616590412; a=rsa-sha256; cv=none; b=BKIE3MvCw/y0Yf20Z7oNiqCJNzev9VwbYcOw4GnIoYIupzstFaOW12CN+rZsOEwq5hLljb PzZpjAiQUntasOTvNuc5bfcpMRTm7k24Wp4+maajZgYN7FkfxFwrdwUw5XegId0FCG0DKz ZEIqm7f8dZjM1Ju3k93X/bYvu8ZjvKztEWDRD8crbHekGe7Yxv+1Qao8fbutkw03fUb/R9 mhgSAyaty8lSJvYX/DpZml3jRfD4RD8QSOL4zbnLNIhuZpl2oajbh29meVkYxX0znKhIl9 s7udC/+i6BUnRtkgiK8/El1yhxoNYtJA4v4VjJRhD1xNtypGrFjxj/D1KZlgjA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=j4fAWuBf; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.47 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=muradm-net.20150623.gappssmtp.com header.s=20150623 header.b=j4fAWuBf; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 3E2EC21F07 X-Spam-Score: -1.47 X-Migadu-Scanner: scn0.migadu.com X-TUID: wAFWkUNfESOU As per discussion with Leo on IRC #guix in relation to #47013 and #47323. There is a need to have important sysctl settings fs.protected_hardlinks and fs.protected_symlinks for all installations of Guix in the world unless explicitly stated otherwise. Currently in Linux kernel they are unset by default. It is also stated that other distributions do the same. In perfect world I would go for Solution 1 below, as it is most effectful, and clean. Solution 1: From this statement, it seems that the first resort whould be Linux kernel it self. If it would be possible to configure them with Kconfig, that would be best place. As of my brief look at linux/fs, they are not configurable, but may be I miss somthing. Any way preferred solution would be just compile kernel with protected hardlinks and symlinks set to 1. Since other distributions do the same, it could be reasonable to expose these two settings via Kconfig, and solve it there. - pros: great for the world - cons: have to do enhancement in mainline Linux Solution 2: If it is not possible to have these two settings in kernel as per Solution 1, Guix may maintain a patch to kernel that would do this. - pros: no need to enhance mainline Linux - cons: will impact users who do use Guix and compile Linux kernel them selves Solution 3: Handle in Guix configuration. Everything below related to solution 3 and current issue #47323. Currently it is set as folowing: ;; gnu/services/sysctl.scm (define-module .... #:export (.... %default-sysctl-settings) (define %default-sysctl-settings ;; Default kernel parameters enabled with sysctl. '(("fs.protected_hardlinks" . "1") ("fs.protected_symlinks" . "1"))) (define-record-type* sysctl-configuration make-sysctl-configuration sysctl-configuration? (sysctl sysctl-configuration-sysctl ; path of the 'sysctl' command (default (file-append procps "/sbin/sysctl"))) (settings sysctl-configuration-settings ; alist of string pairs (default %default-sysctl-settings))) ;; ends- gnu/services/sysctl.scm And sysctl-service-type it self is added to the %base-services. Since sysctl-configuration-settings function to access settings field of sysctl-configuration instance is not exported, I have to do the following in my configuration: (define nomad-gx1-os (operating-system (inherit my-base-nomad-os) ;; important line-#1 ... (services (modify-services my-base-nomad-services (sysctl-service-type config => (inherit config) (settings (append %default-sysctl-settings ;; from gnu/services/sysctl.scm '(("fs.inotify.max_user_watches" . "524288") ("fs.inotify.max_user_instances" . "16384") ("fs.inotify.max_queued_events" . "65536"))))))))) This is fine, until I extend sysctl-service-type in my-base-nomad-os. Then I have to export my-base-nomad-sysctl-settings and join them with %default-sysctl-settings and extra settings for nomad-gx1-os. While it is bearable for one or two levels of inheritance, it becomes hard to keep track for more levels and/or many hosts. If sysctl-configuration-settings would be exported, then my configuration would become simplier: (services (modify-services my-base-nomad-services (sysctl-service-type config => (inherit config) (settings (append (sysctl-configuration-settings config) ;; now I can't do this '(("fs.inotify.max_user_watches" . "524288") ("fs.inotify.max_user_instances" . "16384") ("fs.inotify.max_queued_events" . "65536"))))))))) In this case, if Guix documentation will include sysctl-configuration-settings, then most likely people won't forget use %default-sysctl-settings, and it is still possible to override them if one desires not to use protected symlinks and hardlinks. -- muradm