From patchwork Tue Apr 29 07:17:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 42134 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 C6EAF27BC4B; Tue, 29 Apr 2025 08:20:54 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1806327BC49 for ; Tue, 29 Apr 2025 08:20:54 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u9fGR-00005W-M3; Tue, 29 Apr 2025 03:20:29 -0400 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 1u9fFD-0008IB-Mt for guix-patches@gnu.org; Tue, 29 Apr 2025 03:19:25 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1u9fFC-0004sV-I9; Tue, 29 Apr 2025 03:19:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=NnwFb4SwueYZqVnITeYzLBrkzbN5D9MX3frq+axuH7c=; b=ihrCEoiy6uqJTTAXlJhbRVI+na1y3ciMe7GQ/QdnSaB/u6jCZ0l1AUTM4Gg3YEgMD7HorW3K9pFYsJDHCl0kOBF+U7/HLCy4MVxQrMHxkGG+eYoT8p6dgq2AaIemL97rsJbCP4ivF44ABCl1VMx84YNehsHGL4d5nMtJj48M7B0yTUC16DKoK2U+n5jFL7b+FXriGN5N0AYRIFiZnQmlvJ0hS54zJRLsUU+Ypp7ov13j/7XY5RQk4gNp8lvpGNQ7MnwnTJbuiAnI38LiM10orKCnytBq65xaNu9oW/fHRRFLgbdvt/gqOYk9wEU9ll2OI8tggvl7kIl8hY3rKKHPVw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1u9fF8-00007Y-7O; Tue, 29 Apr 2025 03:19:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73494] [PATCH v4 2/3] services: cleanup: Bind mount /var/run to /run. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: hako@ultrarare.space, maxim.cournoyer@gmail.com, ludo@gnu.org, vagrant@debian.org, zhengjunjie@iscas.ac.cn, guix-patches@gnu.org Resent-Date: Tue, 29 Apr 2025 07:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73494 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73494@debbugs.gnu.org Cc: Hilton Chain , Maxim Cournoyer , Hilton Chain , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Vagrant Cascadian , Z572 X-Debbugs-Original-Xcc: Hilton Chain , Maxim Cournoyer , Ludovic =?utf-8?q?Court=C3=A8s?= , Vagrant Cascadian , Z572 Received: via spool by 73494-submit@debbugs.gnu.org id=B73494.174591111232697 (code B ref 73494); Tue, 29 Apr 2025 07:19:02 +0000 Received: (at 73494) by debbugs.gnu.org; 29 Apr 2025 07:18:32 +0000 Received: from localhost ([127.0.0.1]:47032 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u9fEe-0008VH-3d for submit@debbugs.gnu.org; Tue, 29 Apr 2025 03:18:32 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:50345) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1u9fEX-0008TV-EF for 73494@debbugs.gnu.org; Tue, 29 Apr 2025 03:18:27 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-22c33e5013aso67244685ad.0 for <73494@debbugs.gnu.org>; Tue, 29 Apr 2025 00:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745911099; x=1746515899; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NnwFb4SwueYZqVnITeYzLBrkzbN5D9MX3frq+axuH7c=; b=WG6keXPAQQ+6FDOwupjt9J3i7Ku3kJKdAPKw001xiPasQ2OgU8h7NOTLNxjYUUw3sL hye0rqZsLK1BB2iqpUSmnhcJaGmGFvZV12tGIZjaOZy0W2bMaqaiasur7yueObljlhmX yslAeSkh+T+tL5e8yphWe8iiZ2ri+HSrHPer04nywjKgM69Tma7xrIAmjho2BFwImbwa awhE6rVdJRkhB1sY4tqA8WTKoeEMgktrawQ6RF43DFn19sXZmlnvPfTZs3NOQgBdK73M FtA9WorWXj8VLwkt3Vkd+YTL/htRdvW4TxQa1Kghq9UxcHe3CijhfuptpyjHp+cCyX8F iijA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745911099; x=1746515899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NnwFb4SwueYZqVnITeYzLBrkzbN5D9MX3frq+axuH7c=; b=uJBgHnBa8r7m1T+IXgWH2Zthil434v0DAG2M33bjyo01PtUfCMkC83Fly/YBkxSgnk GLd0YJWSaCjdguS+1S8bJLc8p2OWacITOpgVIABoY5iv0bVAWpf53z8wRiPD6ake1/vY ozjzi0phZ2dpCHomXJ7hwd4vbuBW2t3qeoVChFXKwq2nvJ1IQCvIacLhpDURWaVXU5gc S5q9tugF5zS/PmMRwnj1htKkAhSJdLArWPWPPWr2vkKLirzTmK2QxBy3xKgIo2myrjvX g99VTqbPtZh5TezlB7miaoZmSTp/F9DmiP0aKDww/eWIvmKrfAho45KbFNZFtNjjgcms XJsw== X-Gm-Message-State: AOJu0Ywtoe1rZEiS5q3vthbng0QawwG94WXTQbgPkYseyDrFDjLsiwxE Kb57thCnOOpttUlxjynobbz0KucXnICcovQwPbuzFy7RZSlFqpcATLINLQ== X-Gm-Gg: ASbGnct/aVPvJ7QJeGspPLHzSD/4+kW2zvdX2cw9I4B201wQnY8OnXXR6k0cCZ/rIDH s7Aagiz0Jcxtey9dEikDXjljb9UV05/OILqy2DzK0m9ZFZlCtX0wuqaUmgVvGLPHUDO63kmPKJ2 adlGSbAVKBJ41aGz5gzHyJybAOvQMbhi0E/C9N+xFCLYaVMYl+GL2KGzZpc9Tk8to0nnZDDe6BK TOzVTHi2E02f4+JZ6RAUPWvPc3U8tIRDYVDlIQE28b8iWpJN8vQ/kpQuKW48AajIi+ehXD84ORr saA5Xrohm+F+xvLHW4kWKv8g6mKSrrh0Wj+YG+0yOLAyzs6VIl+LqEBESsoW X-Google-Smtp-Source: AGHT+IERKDigj1RlG5mbgLn2K6DjAy9GeI1AuKtgbaiYluKXh7dNDAXVCFkR2xHoT2/veq6PG6gYGQ== X-Received: by 2002:a17:903:1aab:b0:216:53fa:634f with SMTP id d9443c01a7336-22dc6a8977cmr193501125ad.48.1745911098643; Tue, 29 Apr 2025 00:18:18 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:83c8:d31d:2cec:f542]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22db4d76f4bsm95399495ad.49.2025.04.29.00.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Apr 2025 00:18:17 -0700 (PDT) From: Maxim Cournoyer Date: Tue, 29 Apr 2025 16:17:44 +0900 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: <597361035150296c6051f6f78fc8cc8ff3af8b61.1745911065.git.maxim.cournoyer@gmail.com> References: <597361035150296c6051f6f78fc8cc8ff3af8b61.1745911065.git.maxim.cournoyer@gmail.com> MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches From: Hilton Chain * gnu/system/file-systems.scm (%runtime-variable-data) (%runtime-variable-data/bind-mount): New variables. * gnu/system/file-systems.scm (%base-file-systems): Register %runtime-variable-data. * gnu/services.scm (cleanup-gexp): Bind mount /var/run to /run. Remove now extraneous cleanups. * doc/guix.texi (File Systems): Document it. Change-Id: Ie462347935569acddfba68441cf58815a5087cff Modified-by: Maxim Cournoyer --- doc/guix.texi | 7 +++++++ gnu/services.scm | 21 +++++++++++++-------- gnu/services/dbus.scm | 31 ------------------------------- gnu/system/file-systems.scm | 29 +++++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 41 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 7b418a40892..7c8903dcdf7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -18379,6 +18379,13 @@ File Systems read-write in its own ``name space.'' @end defvar +@defvar %runtime-variable-data +This file system is mounted as @file{/run} and contains system +information data describing the system since it was booted. +@file{/var/run} is bind mounted to @file{/run}, for backward +compatibility. +@end defvar + @defvar %binary-format-file-system The @code{binfmt_misc} file system, which allows handling of arbitrary executable file types to be delegated to user space. This requires the diff --git a/gnu/services.scm b/gnu/services.scm index ed17981ffdd..e07b3c24626 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -628,9 +628,14 @@ (define (system-provenance system) (define (cleanup-gexp _) "Return a gexp to clean up /tmp and similar places upon boot." - (with-imported-modules '((guix build utils)) + (with-imported-modules (source-module-closure + '((guix build utils) + (gnu build file-systems) + (gnu system file-systems))) #~(begin - (use-modules (guix build utils)) + (use-modules (guix build utils) + (gnu build file-systems) + (gnu system file-systems)) ;; Clean out /tmp, /var/run, and /run. ;; @@ -662,17 +667,17 @@ (define (cleanup-gexp _) "/lib/locale")) (setlocale LC_CTYPE "en_US.utf8") (delete-file-recursively "/tmp") - (delete-file-recursively "/var/run") - (delete-file-recursively "/run") ;; Note: The second argument to 'mkdir' is and'ed with umask, ;; hence the 'chmod' calls. (mkdir "/tmp" #o1777) (chmod "/tmp" #o1777) - (mkdir "/var/run" #o755) - (chmod "/var/run" #o755) - (mkdir "/run" #o755) - (chmod "/var/run" #o755)))))) + + ;; XXX: It'd be cleaner if we could simply register + ;; %runtime-variable-data/bind-mount in %base-file-systems, that + ;; fails with: 'statfs-raw: No such file or directory' when + ;; checking for "/run". + (mount-file-system %runtime-variable-data/bind-mount #:root "/")))))) (define cleanup-service-type ;; Service that cleans things up in /tmp and similar. diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm index 76e04bf2215..9292172e01a 100644 --- a/gnu/services/dbus.scm +++ b/gnu/services/dbus.scm @@ -190,37 +190,6 @@ (define (dbus-activation config) ;; world-readable. (mkdir-p/perms "/run/dbus" user #o755)) - (catch 'system-error - (lambda () - (symlink "/run/dbus" "/var/run/dbus")) - (lambda args - (let ((errno (system-error-errno args))) - (cond - ((= errno EEXIST) - (let ((existing-name - (false-if-exception - (readlink "/var/run/dbus")))) - (unless (equal? existing-name "/run/dbus") - ;; Move the content of /var/run/dbus to /run/dbus, and - ;; retry. - (let ((dir (opendir "/var/run/dbus"))) - (let loop ((next (readdir dir))) - (cond - ((eof-object? next) (closedir dir)) - ((member next '("." "..")) (loop (readdir dir))) - (else - (begin - (rename-file (string-append "/var/run/dbus/" next) - (string-append "/run/dbus/" next)) - (loop (readdir dir))))))) - (rmdir "/var/run/dbus") - (symlink "/run/dbus" "/var/run/dbus")))) - (else - (format (current-error-port) - "Failed to symlink /run/dbus to /var/run/dbus: ~s~%" - (strerror errno)) - (error "cannot create /var/run/dbus")))))) - (unless (file-exists? "/etc/machine-id") (format #t "creating /etc/machine-id...~%") (invoke (string-append #$(dbus-configuration-dbus config) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 4ea8237c70d..c75ef39377f 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2013-2022 Ludovic Courtès ;;; Copyright © 2020 Google LLC ;;; Copyright © 2020 Jakub Kądziołka -;;; Copyright © 2020, 2021 Maxim Cournoyer +;;; Copyright © 2020, 2021, 2025 Maxim Cournoyer ;;; Copyright © 2021 Tobias Geerinckx-Rice ;;; Copyright © 2022 Oleg Pykhalov ;;; @@ -82,6 +82,8 @@ (define-module (gnu system file-systems) %pseudo-terminal-file-system %tty-gid %immutable-store + %runtime-variable-data + %runtime-variable-data/bind-mount %control-groups %elogind-file-systems @@ -448,6 +450,28 @@ (define %immutable-store (check? #f) (flags '(read-only bind-mount no-atime)))) +(define %runtime-variable-data + (file-system + (type "tmpfs") + (mount-point "/run") + (device "tmpfs") + ;; Don't use no-suid here as /run/privileged/bin may contain SUID + ;; executables. + (flags '(no-dev strict-atime)) + (options "mode=0755,nr_inodes=800k,size=20%") + (needed-for-boot? #t) + (check? #f) + (create-mount-point? #t))) + +(define %runtime-variable-data/bind-mount + (file-system + (device "/run") + (mount-point "/var/run") + (type "tmpfs") + (flags '(bind-mount)) + (check? #f) + (create-mount-point? #t))) + (define %control-groups ;; The cgroup2 file system. (list (file-system @@ -497,7 +521,8 @@ (define %base-file-systems %debug-file-system %shared-memory-file-system %efivars-file-system - %immutable-store)) + %immutable-store + %runtime-variable-data)) (define %base-live-file-systems ;; This is the bare minimum to use live file-systems.