From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CBghCkh7AWI27wAAgWs5BA (envelope-from ) for ; Mon, 07 Feb 2022 21:04:24 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id YBL6Bkh7AWI9HQAAauVa8A (envelope-from ) for ; Mon, 07 Feb 2022 21:04:24 +0100 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 CCC0F2E51F for ; Mon, 7 Feb 2022 21:04:23 +0100 (CET) Received: from localhost ([::1]:55930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHAFK-0006RO-Vh for larch@yhetil.org; Mon, 07 Feb 2022 15:04:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHA0Y-0002NF-OU for bug-guix@gnu.org; Mon, 07 Feb 2022 14:49:06 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHA0T-0004mq-R2 for bug-guix@gnu.org; Mon, 07 Feb 2022 14:49:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHA0T-0007uy-M6 for bug-guix@gnu.org; Mon, 07 Feb 2022 14:49:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#53752: guix home symlink permissions Resent-From: Zacchaeus Scheffer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 07 Feb 2022 19:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53752 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Liliana Marie Prikler Received: via spool by 53752-submit@debbugs.gnu.org id=B53752.164426329830382 (code B ref 53752); Mon, 07 Feb 2022 19:49:01 +0000 Received: (at 53752) by debbugs.gnu.org; 7 Feb 2022 19:48:18 +0000 Received: from localhost ([127.0.0.1]:43837 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH9zl-0007ty-Rn for submit@debbugs.gnu.org; Mon, 07 Feb 2022 14:48:18 -0500 Received: from mail-ej1-f49.google.com ([209.85.218.49]:35560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nH9zi-0007tl-Sa for 53752@debbugs.gnu.org; Mon, 07 Feb 2022 14:48:16 -0500 Received: by mail-ej1-f49.google.com with SMTP id y3so24481162ejf.2 for <53752@debbugs.gnu.org>; Mon, 07 Feb 2022 11:48:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sOWfOqgPMEm6mtKVZ4vPea46YDPZkPrzfSNmO9klABQ=; b=AD8f5CDzXT9rRJPtwdGl+Pwg7/VtM4EGNzJl5yPjgVob2QYx/ZwqRyu9oVjX2p00ek ydmTqQ2I9svdYYI1/jdnM4rSV7p3g0tsxMpxbDneUPgoszfsn6J20dTRE0bOBRfRDqob qAMJXKJD+0KPi8thq2iT9kvh16kAJ0W6A50fobInGj3lV8hJvQl+zpoknKEeQ/09Lp9Q D3PJVtIi3KAn9TUSGEIprXHpUEIzRX73Ju3nBR0FhkzCFr2BPYFg6hXGoHb4qn3T79gq /WlKyXddTwfeiZx7cJUVTsyX2oVUVTZA6BD5ZE/PnzfSRV3skqEQQYvYCK2Kf4nCMxKE 7IbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sOWfOqgPMEm6mtKVZ4vPea46YDPZkPrzfSNmO9klABQ=; b=3Laydzrv4GFPAoMdWJPpaSdnqbPc6agk0MG2Hde1G+yIJUCAxA8g8C4zWBV7zg/pFK r1hLwtpPQpeFtEcLPBq9lF4T/JMHvcShuUF0218rAGXcRXQ09dOHziLn2ESm0Dm2mPFk fLVqDTRv3Rdncz2jCF6LpL2/5H0+kegI0ftGV6jBCsx9U6YSWyw7Ek3HwmoiVFf+pXBB NenzBM0cU3jhFtfyZdjc0pJi19STVkrmuKbJemKA4lbD13nyApAP1JGdBO+02MYv0GQQ CltZHIWMjU+91Z7i8ICET4fSnikRw14HniNEWjywsGVCVL0GHYe+xiMMXAS2y4b6lw9u 8dtA== X-Gm-Message-State: AOAM5334wf/1teFlmPSRYDx0v6Gm8ZmXzgMNjzZPZuMJhIlkikl+EJOB /unSvLYNeedwG/8YZw6/CG2xDfeUrSPWl0AO+3o= X-Google-Smtp-Source: ABdhPJxAcOro1yxP2gSD1HQwjVIFBPbEpwGU6QrzFgiF6dw0+GIPzVLGOwekoQ+RYVidPi9ypY0QQzfn/0zOa+wJei0= X-Received: by 2002:a17:907:60c9:: with SMTP id hv9mr954984ejc.670.1644263288716; Mon, 07 Feb 2022 11:48:08 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Zacchaeus Scheffer Date: Mon, 7 Feb 2022 14:47:57 -0500 Message-ID: Content-Type: multipart/alternative; boundary="0000000000003dc2f905d772e142" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 53752@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1644264263; 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: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=sOWfOqgPMEm6mtKVZ4vPea46YDPZkPrzfSNmO9klABQ=; b=Xlhj2fJL2PJI3amjOr9tzu3W7b/UtRMDyq6IVeIUeutWoesPC9EGZSA0s9/+hDi1/VTKos u0XKOxQLkQsOqxjZ5hWJkmtTBM8jtVMYeENS7vid3WDSnlVJZoZgT/r/xZwD32AL/xOIWF D3ir/bE7aCDHzJ2eNU4UJoBEbdMnx60YzsF22N2jps1rVsxj33XEqCwi5qm6ctfc0j4Tvj MPsnY8G/+K5+nWGGxBrPFCrG6QutoPEls/tRT6qTO8plsxaporPGdylCfgHvofuM0irVoU HnMtsfv9MqWQKcceBhM2KKi4KcZgQ4vivFsvGus2jhd+Wgx0Rzo4lMFwYp9LiQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644264263; a=rsa-sha256; cv=none; b=Q54YKP5dh5GW6U/nzDCezGXdQ1CW8pFKSrBGLB3FYxJKx9bTuSR03KSSLLgUkF1WyxROz/ w/fpykwcB1S+YzCq6Dy2HQcTD5E2PAvk24sP9DrCkdKOOMmAVu7TPwNBP/okwqgIaWgXF8 ewDuYugDz+Xe5NgrMU+4x9RcxRMB/n8V7ZKw1qs6ZT5gmqXR23ka423ljtx4svgTRuhxEU YCggpVSQn4vmymlXPRWKL5mKJVlPtKKs++z3big2M8XT4XCbFuyu0V5SZwzCjrGRgWE9cS cYwchL1/g94+vNKbwRciqzzwG1dkv5COYoQk8nSHbm/t96sCeawKOaVOLxw53w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=AD8f5CDz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.53 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=AD8f5CDz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CCC0F2E51F X-Spam-Score: -2.53 X-Migadu-Scanner: scn0.migadu.com X-TUID: mbr8ug5DXd9F --0000000000003dc2f905d772e142 Content-Type: text/plain; charset="UTF-8" > > > I finally migrated my home configuration to guix home. However, it >> > seems guix home creates all symlinks with 777 permissions. This causes >> > problems with openssh as it will not recognize my >> > ~/.ssh/authorized_keys. It seems the directories have reasonable >> > permissions (maybe because they already existed?), but it seems like >> > someone could in theory edit the symlinks in-place (though I wasn't >> > able to figure that out). >> Instead of using symllinks for ~/.ssh/authorized_keys, you could try to >> write a home-activation-service, which >> >> 1. creates ~/.ssh with chmod 700 >> 1a. if it already existed, enforces chmod 700 anyways >> 2. creates authorized_keys with chmod 600 if it doesn't exist >> 3. writes the authorized keys. >> > > I'll try that soon (next 1-3 days), and hopefully then we can close this > issue. > I was able create the desired effect with the following service definition: (simple-service 'my-activation-service home-activation-service-type (gexp (begin (chdir (ungexp user-home)) (if (not (file-exists? ".ssh")) (mkdir ".ssh")) (chmod ".ssh" #o700) (chdir ".ssh") (let ((port (open-output-file "authorized_keys"))) (display (ungexp authorized-keys) port) (close-port port)) (chmod "authorized_keys" #o600) (chdir "..")))) where 'user-home and 'authorized-keys are appropriate strings defined earlier in the file. I believe that resolves the issue, Zacchaeus Scheffer --0000000000003dc2f905d772e142 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> I finally migrated my home confi= guration to guix home.=C2=A0 However, it
> seems guix home creates all symlinks with 777 permissions.=C2=A0 This = causes
> problems with openssh as it will not recognize my
> ~/.ssh/authorized_keys.=C2=A0 It seems the directories have reasonable=
> permissions (maybe because they already existed?), but it seems like > someone could in theory edit the symlinks in-place (though I wasn'= t
> able to figure that out).
Instead of using symllinks for ~/.ssh/authorized_keys, you could try to
write a home-activation-service, which

1. creates ~/.ssh with chmod 700
1a. if it already existed, enforces chmod 700 anyways
2. creates authorized_keys with chmod 600 if it doesn't exist
3. writes the authorized keys.
=C2=A0
I'= ll try that soon (next 1-3 days), and hopefully then we can close this issu= e.

I= was able create the desired=C2=A0effect with the following service definit= ion:
(simple-service
=C2=A0'my-= activation-service
=C2=A0home-activation-service-type
=C2=A0(gexp
= =C2=A0 (begin
=C2=A0 =C2=A0 (chdir (ungexp user-home))
=C2=A0 =C2=A0 = (if (not (file-exists? ".ssh"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (m= kdir ".ssh"))
=C2=A0 =C2=A0 (chmod ".ssh" #o700)
= =C2=A0 =C2=A0 (chdir ".ssh")
=C2=A0 =C2=A0 (let ((port (open-o= utput-file "authorized_keys")))
=C2=A0 =C2=A0 =C2=A0 (display = (ungexp authorized-keys) port)
=C2=A0 =C2=A0 =C2=A0 (close-port port))=C2=A0 =C2=A0 (chmod "authorized_keys" #o600)
=C2=A0 =C2=A0 = (chdir ".."))))
where 'user-home and 'authorize= d-keys are appropriate strings defined earlier in the file.
=
I believe that resolves the i= ssue,
Zacchaeus Scheffer
--0000000000003dc2f905d772e142--