From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id +Gi0A5quW2ZpsAAAe85BDQ:P1 (envelope-from ) for ; Sun, 02 Jun 2024 01:28:26 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id +Gi0A5quW2ZpsAAAe85BDQ (envelope-from ) for ; Sun, 02 Jun 2024 01:28:26 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=freakingpenguin.com header.s=x header.b=EpKAjvkV; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1717284505; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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=vs0ksIXRLil2Wu6ptR0iYB7JH/lgfD33tOt8ohbEIV4=; b=Z5K+85/lHulr6vE0jQHTNumzJcGPPj2oTZDF9rGN69voz1d8oWTAr6eCDaEwcTx88JbFmN OSACoxyqzEqM/kdq4xMzmOJOLBENB9mvYtNHnId6rYNzzhkAfw3WtnUxoiJIAHR+HlXMy/ 3HiYa7kuV+Rp7hRa3V1M7wXm0IH1dmJhcAPeoHgCPMsHLXKdchxuXYeui8Y5Tm3qcgsKzS ucguvl/3NlrvJatvkI6dWlVInQWbe9BoK/SygA/NIV3FMcjnhkEuKrP+gSvgUCAhkxkeio berSekOoESKppExTjDUW59m/E5+xqm0dn1XVkoeaFX2qqPQeVq8vHcXvmUb1iw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=freakingpenguin.com header.s=x header.b=EpKAjvkV; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1717284505; a=rsa-sha256; cv=none; b=dnAgbzR7PF7ky6cQLirPbw2OucsA6qJ5vpcJwhLrmgp87oAMCKxA14UeBQs3kAyqrKn0yr cikomswWy/oGzZW1aiWj8BnOafbLnoZUFjnrCbFp4BFprluWIrL6q4WIu1TD9L4djlJvmV Tn0jHie3/lTRbqOJEBynCPRivhTYCSyT+8FPgsiwgCeMyEQH93J9Ty3foDIhqHrG+guMEN MtXcRq/4mpvb81SA+YZ+PE791cxy1pbmFIFZbFkg/ieqdB25o2CJcAK3hTaVU/XrRKHhXh EvGjh3W09Tg04NoVMGpnvE3OLE/GEgWyLxJmteGrVHvuQcQJdCSUdcyEp125hA== 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 9829F14254 for ; Sun, 2 Jun 2024 01:28:25 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sDY8i-000348-0h; Sat, 01 Jun 2024 19:27:56 -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 1sDY8g-00033Y-Uj for guix-patches@gnu.org; Sat, 01 Jun 2024 19:27:54 -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 1sDY8g-000448-JJ; Sat, 01 Jun 2024 19:27:54 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sDY8p-0003uT-PG; Sat, 01 Jun 2024 19:28:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70542] [PATCH v3 3/3] file-systems: Add support for mounting CIFS file systems Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Sat, 01 Jun 2024 23:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70542 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70542@debbugs.gnu.org Cc: Richard Sent , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 70542-submit@debbugs.gnu.org id=B70542.171728443314937 (code B ref 70542); Sat, 01 Jun 2024 23:28:03 +0000 Received: (at 70542) by debbugs.gnu.org; 1 Jun 2024 23:27:13 +0000 Received: from localhost ([127.0.0.1]:57533 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDY80-0003sn-Hl for submit@debbugs.gnu.org; Sat, 01 Jun 2024 19:27:13 -0400 Received: from mail-108-mta17.mxroute.com ([136.175.108.17]:36475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sDY7x-0003sU-Uu for 70542@debbugs.gnu.org; Sat, 01 Jun 2024 19:27:11 -0400 Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta17.mxroute.com (ZoneMTA) with ESMTPSA id 18fd620ae72000e2b6.001 for <70542@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sat, 01 Jun 2024 23:26:57 +0000 X-Zone-Loop: 0f629324437261765c86d6d917a31091273f3c21b2f9 X-Originating-IP: [136.175.111.3] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vs0ksIXRLil2Wu6ptR0iYB7JH/lgfD33tOt8ohbEIV4=; b=EpKAjvkVhWnqYaw55HpBVovXhZ /ydh2vIVUgvbUVbYkZk1bVuq+nI4Ub2XEL3oKSoPdFWjY+TpRPteI1Al5jLMcv5MQWCcNyAkemfW1 fsiftKXlx3HEwzfn7QdQ90XA2p5aX6CfSsoGyxiiz+AXBkUrfq0ny8qnC3OqCS0iAcS0O5Zsqj18+ pIqrqcYMB1YYzwOyusYUYl6Uw8hRb1zN7bqWpcQiwZPvwQP0tuDBkDm176ylqiiLt2DeIcjaFUytX VeiriaSXhHtliy1/212bHiurISb7kVYvxme0DNM6PZi6Lw7+h48QvzHMUQLMrHCet7JQjwJUI/YK4 uOgXpEiQ==; From: Richard Sent Date: Sat, 1 Jun 2024 19:26:18 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Authenticated-Id: richard@freakingpenguin.com 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.84 X-Spam-Score: -3.84 X-Migadu-Queue-Id: 9829F14254 X-Migadu-Scanner: mx13.migadu.com X-TUID: w6ZLW9ko70B1 * gnu/build/file-systems (canonicalize-device-name): Do not attempt to resolve CIFS formatted device specifications. (mount-file-systems): Add mount-cifs nested function. * gnu/machine/ssh.scm (machine-check-file-system-availability): Skip checking for CIFS availability, similar to NFS. * guix/scripts/system.scm (check-file-system-availability): Likewise. Change-Id: I182e290eba64bbe5d1332815eb93bb68c01e0c3c --- gnu/build/file-systems.scm | 45 ++++++++++++++++++++++++++++++++++++-- gnu/machine/ssh.scm | 3 ++- guix/scripts/system.scm | 3 ++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index e47ac39ab0..ae29b36c4e 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -8,6 +8,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2022 Oleg Pykhalov ;;; Copyright © 2024 Nicolas Graves +;;; Copyright © 2024 Richard Sent ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,6 +38,7 @@ (define-module (gnu build file-systems) #:use-module (rnrs bytevectors) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) + #:use-module (ice-9 regex) #:use-module (system foreign) #:autoload (system repl repl) (start-repl) #:use-module (srfi srfi-1) @@ -1047,8 +1049,11 @@ (define (canonicalize-device-spec spec) (match spec ((? string?) - (if (or (string-contains spec ":/") (string=? spec "none")) - spec ; do not resolve NFS / tmpfs devices + (if (or (string-contains spec ":/") ;nfs + (and (>= (string-length spec) 2) + (equal? (string-take spec 2) "//")) ;cifs + (string=? spec "none")) + spec ; do not resolve NFS / CIFS / tmpfs devices ;; Nothing to do, but wait until SPEC shows up. (resolve identity spec identity))) ((? file-system-label?) @@ -1181,6 +1186,40 @@ (define* (mount-file-system fs #:key (root "/root") (string-append "," options) ""))))) + (define (mount-cifs source mount-point type flags options) + ;; Source is of form "///" + (let* ((regex-match (string-match "//([^/]+)/(.+)" source)) + (server (match:substring regex-match 1)) + (share (match:substring regex-match 2)) + ;; Match ",guest,", ",guest$", "^guest,", or "^guest$," not + ;; e.g. user=foo,pass=notaguest + (guest? (string-match "(^|,)(guest)($|,)" options)) + ;; Perform DNS resolution now instead of attempting kernel dns + ;; resolver upcalling. /sbin/request-key does not exist and the + ;; kernel hardcodes the path. + ;; + ;; (getaddrinfo) doesn't support cifs service, so omit it. + (inet-addr (host-to-ip server))) + (mount source mount-point type flags + (string-append "ip=" + inet-addr + ;; As of Linux af1a3d2ba9 (v5.11) unc is ignored + ;; and source is parsed by the kernel + ;; directly. Pass it for compatibility. + ",unc=" + ;; Match format of mount.cifs's mount syscall. + "\\\\" server "\\" share + (if guest? + ",user=,pass=" + "") + (if options + ;; No need to delete "guest" from options. + ;; linux/fs/smb/client/fs_context.c explicitly + ;; ignores it. Also, avoiding excess commas + ;; when deleting is a pain. + (string-append "," options) + ""))))) + (let* ((type (file-system-type fs)) (source (canonicalize-device-spec (file-system-device fs))) (target (string-append root "/" @@ -1215,6 +1254,8 @@ (define* (mount-file-system fs #:key (root "/root") (cond ((string-prefix? "nfs" type) (mount-nfs source target type flags options)) + ((string-prefix? "cifs" type) + (mount-cifs source target type flags options)) ((memq 'shared (file-system-flags fs)) (mount source target type flags options) (mount "none" target #f MS_SHARED)) diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index b47ce7c225..0be9ebbc0d 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -222,7 +222,8 @@ (define (machine-check-file-system-availability machine) (not (member (file-system-type fs) %pseudo-file-system-types)) ;; Don't try to validate network file systems. - (not (string-prefix? "nfs" (file-system-type fs))) + (not (or (string-prefix? "nfs" (file-system-type fs)) + (string-prefix? "cifs" (file-system-type fs)))) (not (memq 'bind-mount (file-system-flags fs))))) (operating-system-file-systems (machine-operating-system machine)))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 2260bcf985..99c58f3812 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -591,7 +591,8 @@ (define (check-file-system-availability file-systems) (not (member (file-system-type fs) %pseudo-file-system-types)) ;; Don't try to validate network file systems. - (not (string-prefix? "nfs" (file-system-type fs))) + (not (or (string-prefix? "nfs" (file-system-type fs)) + (string-prefix? "cifs" (file-system-type fs)))) (not (memq 'bind-mount (file-system-flags fs))))) file-systems)) -- 2.41.0