From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id yI1vJtwndGbtCgEA62LTzQ:P1 (envelope-from ) for ; Thu, 20 Jun 2024 13:00:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id yI1vJtwndGbtCgEA62LTzQ (envelope-from ) for ; Thu, 20 Jun 2024 15:00:12 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=ikherbers.com header.s=strato-dkim-0002 header.b=QZ5Bzd3V; dkim=fail ("headers eddsa verify failed") header.d=ikherbers.com header.s=strato-dkim-0003 header.b=cdhZzhA8; dmarc=none; 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"; arc=reject ("signature check failed: fail, {[1] = sig:strato.com:reject}") ARC-Seal: i=2; s=key1; d=yhetil.org; t=1718888412; a=rsa-sha256; cv=fail; b=mjH5Jzp0wBbhkdBFWUa9B0W15SHqt+sOKEvq1vJt1FX7zUKhUDMmzmHv1PjpHAvketyN8+ jgTo7KG8UnXnQ5VwFskDLeJtWaA1wTx7/tvyB/RvaQXtAcVQkUvtbpU5k8DC67SIdW3Y3G Mj/ZrM9wcfC/p+mxNrNRFjwmhloTI7IxFvmfVsz0f4/qcIdC8oc1VsNL7Rp3XzmTOADiN4 GAMFy9as8OfnnADevhWje8OVYsrWUIUsLhSjHhFvzOhL032OrAXJGkAyVAwWkZcv6lZNun vmImp5vDS+FXgCI/5SZICtOJzTAum27YtboGm7sR4Wmjkzqpzy/SlCZOIqWXpg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=ikherbers.com header.s=strato-dkim-0002 header.b=QZ5Bzd3V; dkim=fail ("headers eddsa verify failed") header.d=ikherbers.com header.s=strato-dkim-0003 header.b=cdhZzhA8; dmarc=none; 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"; arc=reject ("signature check failed: fail, {[1] = sig:strato.com:reject}") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1718888412; 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=1QH0lAIaTcHQrQzC0zOw+cn4sb0+hNnj3IqUmkoSLY4=; b=oad7lAXu/hm0fexSqg+r+8xbbc9/hvY4MPWMh360HzIzHzEvUu0PJ78LuglWfJJpauXudA k9q7aYG/GGRAlsdJWsRbVOCRQ2JKX5ARN4rZVb6KH5ubQePTk5jHsUM4KBbSo0DeM+gnPF Iu+cRpp19ciVpFR0cO0XGe2glTgmdYPWgMIJELTv/0rAbVoPUYq4swEaroliHiMgfc8Eli aHxNoxeYJUs7cKN2bsTyMAjOpEkoT1rQ+9qmfE0/pxs+MtXm9zN0xi5jCcWsKuLH8lzmaK cuNfQtqgy0Gp1G1w0SST5EC94sDDKEJKB9LEeIDm4FAn2WmAGW9XLFMfyWAd8w== 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 3232169643 for ; Thu, 20 Jun 2024 15:00:12 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKHOU-0000ie-B4; Thu, 20 Jun 2024 09:00:02 -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 1sKHOS-0000hm-8a for guix-patches@gnu.org; Thu, 20 Jun 2024 09:00:00 -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 1sKHOR-0005u1-GB for guix-patches@gnu.org; Thu, 20 Jun 2024 08:59:59 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sKHOU-0007fw-U6 for guix-patches@gnu.org; Thu, 20 Jun 2024 09:00:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71594] [PATCH v2] file-systems: Allow specifying CIFS credentials in a file. References: <434a45cea2afc5e4de5af5b15bc732b7587a979a.1718550930.git.guix@ikherbers.com> In-Reply-To: <434a45cea2afc5e4de5af5b15bc732b7587a979a.1718550930.git.guix@ikherbers.com> Resent-From: vicvbcun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 20 Jun 2024 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71594 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 71594@debbugs.gnu.org Cc: vicvbcun Received: via spool by 71594-submit@debbugs.gnu.org id=B71594.171888836529408 (code B ref 71594); Thu, 20 Jun 2024 13:00:02 +0000 Received: (at 71594) by debbugs.gnu.org; 20 Jun 2024 12:59:25 +0000 Received: from localhost ([127.0.0.1]:55852 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKHNt-0007eF-1O for submit@debbugs.gnu.org; Thu, 20 Jun 2024 08:59:25 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.219]:39971) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKHNq-0007e0-Qw for 71594@debbugs.gnu.org; Thu, 20 Jun 2024 08:59:23 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1718888357; cv=none; d=strato.com; s=strato-dkim-0002; b=iT0Cs0WU2si01imXQrTISizeL6OPXgMYfKkOxda5qQ4cTFIIbqFqDdhVRg+4eoBLO5 0w42gm1GLxvYSrQTzSQJKBCP2YNUb25pRakUQrgXMNG66mxQahUwYVJ/+eTF9/ipe8rj ofjhGbIOOK8QtZ3mE5iKT/0k5NxwE7w1pDlV2Sppo8JuiivbeBpIB9pw61fGEk+j+jfW 4upAAClN6u0javXqIqy77q4fqnY4wg0sgO3Pe6h0MqKjtOb2s1YAnORDVPw9i6qsehdr uj2PjnPR5EkvqGBQf57AOUdozjXtSh4Xt3OVjhlqXh/JQ97bxuAaeKRFqBhh9nfYXxO7 ckaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1718888357; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=1QH0lAIaTcHQrQzC0zOw+cn4sb0+hNnj3IqUmkoSLY4=; b=cNrnEkFf6N1mRzpt+LpbnYZJr/su5fh/o5bTvl5CPVdYZpRytB/UGEq6WfwT7xPtfq QWyvLwTg8Q/jT9tsihmUbxBY4Sa3agWPO9vvJpOS2mo5zkagcUKLagnYXMEhTkVlQ/ks 0OA4e+4WkE2TA3+5QPodKsmBONY7ffUKaG1loTpfeGXxT4JivvZsZkZPjRFh6ddfE07W EfHgrY1bBKlVao3OHQTRJEZhZ2MWdJ4DQUT5ATaWd7HYhmSK6DlQqLnneMWMFftBuW2g 50lP8yfb0kbl3t4llRM0BSq7nghE3KMBS4MvaDhoaS+leV0aFrU0nEgH7gyBXXIzhoE+ jTCg== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1718888356; s=strato-dkim-0002; d=ikherbers.com; h=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=1QH0lAIaTcHQrQzC0zOw+cn4sb0+hNnj3IqUmkoSLY4=; b=QZ5Bzd3VA3ythdaygFBAp0wuQACHOzhRrGO4jfpMLpVOR8vsyOwlNUyCSORuvC/Rg1 bJIE66QzQASJ+gY027yvUXb3mvTAUEjkIi0nVwfo2+MIzjCMmilKmDWcOvOfRLdyQibH HGbCIE9PVNrTD+PvMPIcWczGxQLmPr5nfi81jVHr6kkvhX9RYmDzDrywhD/6+/KtqMIt ipsoMSqT1dBxkF1VgcWgEtWIOvXRt+bBMG43I4qKlk58s67roPgbFTBa6REsD/Bvdmh7 z6I+HG8aut6WIS2Jao/ArARHasNB8FG2hc/fr+EG8MBsXVEChWR5lz1Fgx+3SBp1dhUd pfDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1718888356; s=strato-dkim-0003; d=ikherbers.com; h=Message-ID:Date:Subject:Cc:To:From:Cc:Date:From:Subject:Sender; bh=1QH0lAIaTcHQrQzC0zOw+cn4sb0+hNnj3IqUmkoSLY4=; b=cdhZzhA8fxfRV6tkIjaBD2DV4POTM1fmvhmIbLmBNCtAeqGT7OFrNwV67Jh94SMRJc uboEpRBMOh5vLwYvjOCg== X-RZG-AUTH: ":IUwNfkitaf3qOWm2b/jA5tveVwUUcwH3PkiYp6DPxTDDEo4xO9elHknIgunRQh05vKLMci5dxXOIVKBfWRxZRSbO659f/07G5A9nYA==" Received: from lambda.localdomain by smtp.strato.de (RZmta 50.5.0 AUTH) with ESMTPSA id 507f1505KCxFjnC (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 20 Jun 2024 14:59:15 +0200 (CEST) From: vicvbcun Date: Thu, 20 Jun 2024 14:58:23 +0200 Message-ID: X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="us-ascii" 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.46 X-Migadu-Scanner: mx12.migadu.com X-Spam-Score: -3.46 X-Migadu-Queue-Id: 3232169643 X-TUID: tdSmOFqlKqSC From: vicvbcun As files in the store and /etc/fstab are world readable, specifying the password in the file-system record is suboptimal. To mitigate this, `mount.cifs' supports reading `username', `password' and `domain' options from a file named by the `credentials' or `cred' option. * gnu/build/file-systems.scm (mount-file-system): Read mount options from the file specified via the `credentials' or `cred' option if specified. Change-Id: I786c5da373fc26d45fe7a876c56a8c4854d18532 --- Changes since v1: - rename `read-credential-file' to `read-cifs-credential-file' and rewrite using `match' - break lines earlier gnu/build/file-systems.scm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index ae29b36c4e..387b4c1af4 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -39,6 +39,7 @@ (define-module (gnu build file-systems) #:use-module (ice-9 match) #:use-module (ice-9 rdelim) #:use-module (ice-9 regex) + #:use-module (ice-9 string-fun) #:use-module (system foreign) #:autoload (system repl repl) (start-repl) #:use-module (srfi srfi-1) @@ -1186,6 +1187,31 @@ (define* (mount-file-system fs #:key (root "/root") (string-append "," options) ""))))) + (define (read-cifs-credential-file file) + ;; Read password, user and domain options from file + (with-input-from-file file + (lambda () + (let loop + ((next-line (read-line)) + (lines '())) + (match next-line + ((? eof-object?) + lines) + ((= string-trim line) + (loop (read-line) + (cond + ((string-prefix? "pass" line) + ;; mount.cifs escapes commas in the password by doubling + ;; them + (cons (string-replace-substring line "," ",,") + lines)) + ((or (string-prefix? "user" line) + (string-prefix? "dom" line)) + (cons line lines)) + ;; Ignore all other lines. + (else + lines))))))))) + (define (mount-cifs source mount-point type flags options) ;; Source is of form "///" (let* ((regex-match (string-match "//([^/]+)/(.+)" source)) @@ -1194,6 +1220,9 @@ (define* (mount-file-system fs #:key (root "/root") ;; Match ",guest,", ",guest$", "^guest,", or "^guest$," not ;; e.g. user=foo,pass=notaguest (guest? (string-match "(^|,)(guest)($|,)" options)) + (credential-file (and=> (string-match "(^|,)(credentials|cred)=([^,]+)(,|$)" + options) + (cut match:substring <> 3))) ;; Perform DNS resolution now instead of attempting kernel dns ;; resolver upcalling. /sbin/request-key does not exist and the ;; kernel hardcodes the path. @@ -1218,6 +1247,11 @@ (define* (mount-file-system fs #:key (root "/root") ;; ignores it. Also, avoiding excess commas ;; when deleting is a pain. (string-append "," options) + "") + (if credential-file + ;; The "credentials" option is ignored too. + (string-join (read-cifs-credential-file credential-file) + "," 'prefix) ""))))) (let* ((type (file-system-type fs)) base-commit: 2195f70936b7aeec123d4e95345f1007d3a7bb06 -- 2.45.1