From patchwork Thu Mar 18 07:27:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Famulari X-Patchwork-Id: 27958 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7B42427BC57; Thu, 18 Mar 2021 07:28:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9601027BC55 for ; Thu, 18 Mar 2021 07:28:09 +0000 (GMT) Received: from localhost ([::1]:35866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMn4i-0003ld-Pg for patchwork@mira.cbaines.net; Thu, 18 Mar 2021 03:28:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMn4c-0003lT-LF for guix-patches@gnu.org; Thu, 18 Mar 2021 03:28:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:33317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lMn4c-00074z-ED for guix-patches@gnu.org; Thu, 18 Mar 2021 03:28:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lMn4c-0004xb-BJ for guix-patches@gnu.org; Thu, 18 Mar 2021 03:28:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47013] [PATCH] gnu: Harden filesystem links. Resent-From: Leo Famulari Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 18 Mar 2021 07:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47013 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 47013@debbugs.gnu.org Received: via spool by 47013-submit@debbugs.gnu.org id=B47013.161605243119002 (code B ref 47013); Thu, 18 Mar 2021 07:28:02 +0000 Received: (at 47013) by debbugs.gnu.org; 18 Mar 2021 07:27:11 +0000 Received: from localhost ([127.0.0.1]:44863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMn3n-0004wQ-51 for submit@debbugs.gnu.org; Thu, 18 Mar 2021 03:27:11 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:35993) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lMn3k-0004wB-IX for 47013@debbugs.gnu.org; Thu, 18 Mar 2021 03:27:10 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5197E5C0092; Thu, 18 Mar 2021 03:27:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 18 Mar 2021 03:27:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=famulari.name; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=mesmtp; bh=UO2vJJqxV3s/E98nA96LpvnH P7FOB8gX049z0N5ruJg=; b=MWnQ0cycJ7SXF6LJLau2BGsy7Dpc1TL/VsISblvR jJ/0PC2mE7QZA7W5ASs4l3APEIbKtUap4JbyVbjk6RXZ6wr8i+Nj0yhoEtdVC75U TNOq+u/PPiJOyqyJizSM0rqtW+bUxRNd67E2PYZJS1teocJsau3cTRa2gtoCxcfc VxQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=UO2vJJ qxV3s/E98nA96LpvnHP7FOB8gX049z0N5ruJg=; b=cAE6J0NdT1yd5pckQ3ShTv 42amQo8wvQdvjONNJUrQndB8Hs8mQr2Y9YnHwQaSui4o+6lPnvWnL1Aaa1gQlxhd fpXII6CESPvhafQz1LaVeYiD3/uGL0ouMm96rthTXMdQYj6I7yUvoTKVYHVsEKJu KUv1d7aaiGAkeJd06ZSAmUnEdwAwgxmkOZ5Qge8Wd+VRJ7ISgdSu27DXDJy9gkEW JT7Cpfv3jufqMSAt3ylsIX6JT5XIhCHl8cImsDCJTxLyV3ciOTF2QAIJEviJ7qSV H00+wvkjgKRkUVGoETqXK3AeN5u8OVF8gTWEXjlyfjFK05nImfk5jUBjqlhWsU6A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudefhedguddtiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepnfgvohcu hfgrmhhulhgrrhhiuceolhgvohesfhgrmhhulhgrrhhirdhnrghmvgeqnecuggftrfgrth htvghrnhepudekveegteekleetgfeitdejgfejkeffudethedvhfeukeduleeikeejfeeh ffetnecukfhppedutddtrdduuddrudeiledruddukeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlvghosehfrghmuhhlrghrihdrnhgrmhgv X-ME-Proxy: Received: from localhost (pool-100-11-169-118.phlapa.fios.verizon.net [100.11.169.118]) by mail.messagingengine.com (Postfix) with ESMTPA id 0FE6E24005E; Thu, 18 Mar 2021 03:27:03 -0400 (EDT) Date: Thu, 18 Mar 2021 03:27:01 -0400 From: Leo Famulari Message-ID: References: <8735wu7nf9.fsf_-_@gnu.org> <875z1pzetb.fsf_-_@gnu.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches On Wed, Mar 17, 2021 at 05:01:54PM -0400, Leo Famulari wrote: > Sure, I'll implement your suggestions and send a v5 patch. Here is the revised patch. From 1817aec86076307f7b85cdc27b9ead572d0575e7 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Tue, 16 Mar 2021 21:36:36 -0400 Subject: [PATCH] system: Harden filesystem links. References: https://sysctl-explorer.net/fs/protected_hardlinks/ https://sysctl-explorer.net/fs/protected_symlinks/ * gnu/services/sysctl.scm (%default-sysctl-settings): New public variable. (): Use %default-sysctl-settings as the default value. * gnu/services/base.scm (%base-services): Add sysctl-service-type. * doc/guix.texi (Miscellaneous Services): Document the new defaults. --- doc/guix.texi | 22 +++++++++++++++++++++- gnu/services/base.scm | 3 +++ gnu/services/sysctl.scm | 10 ++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0a70ac7f11..73757be887 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -31378,6 +31378,21 @@ instantiated as: (sysctl-configuration (settings '(("net.ipv4.ip_forward" . "1"))))) @end lisp + +Since @code{sysctl-service-type} is used in the default lists of +services, @code{%base-services} and @code{%desktop-services}, you can +use @code{modify-services} to change its configuration and add the +kernel parameters that you want (@pxref{Service Reference, +@code{modify-services}}). + +@lisp +(modify-services %base-services + (sysctl-service-type config => + (sysctl-configuration + (settings (append '(("net.ipv4.ip_forward" . "1")) + %default-sysctl-settings))))) +@end lisp + @end defvr @deftp {Data Type} sysctl-configuration @@ -31387,11 +31402,16 @@ The data type representing the configuration of @command{sysctl}. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"}) The @command{sysctl} executable to use. -@item @code{settings} (default: @code{'()}) +@item @code{settings} (default: @code{%default-sysctl-settings}) An association list specifies kernel parameters and their values. @end table @end deftp +@defvr {Scheme Variable} %default-sysctl-settings +An association list specifying the default @command{sysctl} parameters +on Guix System. +@end defvr + @cindex pcscd @subsubheading PC/SC Smart Card Daemon Service diff --git a/gnu/services/base.scm b/gnu/services/base.scm index f6a490f712..f50bcfdcb4 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -35,6 +35,7 @@ #:use-module (gnu services) #:use-module (gnu services admin) #:use-module (gnu services shepherd) + #:use-module (gnu services sysctl) #:use-module (gnu system pam) #:use-module (gnu system shadow) ; 'user-account', etc. #:use-module (gnu system uuid) @@ -2532,6 +2533,8 @@ to handle." (udev-configuration (rules (list lvm2 fuse alsa-utils crda)))) + (service sysctl-service-type) + (service special-files-service-type `(("/bin/sh" ,(file-append bash "/bin/sh")) ("/usr/bin/env" ,(file-append coreutils "/bin/env")))))) diff --git a/gnu/services/sysctl.scm b/gnu/services/sysctl.scm index eb7a61b2a9..aaea7cc30d 100644 --- a/gnu/services/sysctl.scm +++ b/gnu/services/sysctl.scm @@ -25,20 +25,26 @@ #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (sysctl-configuration - sysctl-service-type)) + sysctl-service-type + %default-sysctl-settings)) ;;; ;;; System Control Service. ;;; +(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 %default-sysctl-settings))) (define (sysctl-configuration-settings->sysctl.conf settings) "Return a file for @command{sysctl} to set kernel parameters as specified by