From nobody Tue Jul 23 13:04:18 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WSy5t3Y9Cz5RvgK; Tue, 23 Jul 2024 13:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WSy5t24Btz4GDP; Tue, 23 Jul 2024 13:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721739858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vfjyKdQ2h4S981mMl8iaB+XssxAWgepHF31yt+3aOi4=; b=RD+bOGlY+nc0NfhGDaLnWfMC6og643thjQJxAilirHbtmbdmNIp13Enrm8dZPijRhI4SMp nSqZrZ01KDvRiRjo9aBWC1DXNohos2nTBS0Scpjt+E5JAos+4L9xhCv7jwRg+1fVZIe8h1 RJAxjX3DcFaSgjE3YzxJBSXA8XG7SyQKsuDT3kffWoj1hmZpxZE8C+TVU9JM5lmw4t1B+N 2KXnjYZxOSEV2sIkOkXzkNPpiAJeMGk6kbF+y3gFO4UWXkNRBCQY2QX9+19uxTccHJNdSL 765vZ4IrnuC3qd+0GL3YT2XcAWXGPeRjm3SP93Q8Z/yZJO2CXRrKWPShX0QYwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721739858; a=rsa-sha256; cv=none; b=MvoB9Sss9tIxjcwm1aNQXVeypAHNpCii+NePGv4UV+b6P4HJkO5yhLyruj1PRd2dkZhP3S an0qYCLrg89V5iOAEIrYYFRFvsAtI36O+y8JxNFsyrNsSbSaRVZ+nEF26/rjRn+OISeila tjJh2AD45MKhioAYIyFM0s8Ooez2+SZcCwdFQm7Fhsi5XKZ+QQ0RPUEbmfmLlxKk+f0OFP jufI8yOJP1VI7TUlLmi2JS07fzKQXjoWd5wV+GTpHDri7xOHbnu6JyGvXWksAugQPoDCqp 6lFckkBFG9DhJxZNWdyM4kq4WSVVksQnR9PpiXzXsbCyyd9XwAABRS2xNXyPNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721739858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vfjyKdQ2h4S981mMl8iaB+XssxAWgepHF31yt+3aOi4=; b=JXCh/Ea8w4rX4Ht6jEBv3w4YollDgYOPhpCsxneD7ZstWngrUvxDlpJ4ahv49NaICBBjKC lDRrGqNWz84Cb+fUxCH5h4lYMfKrrRHPvo+aHvBbgrGWPpdyuww+KnofxNM/pKvohEcuL9 hTwtzcQLzgZYQ4oGW7xt2Tw1vGhdD28qqg+GcNKCvnbeUDvPhZAhj7xJOwXL+OWfTF0Pru Toc3OqSSfthJlAdgTOnfnL4rwvWgG8XuIwGYPo1lswxKzsmJ5EIrlT1B+QNU+bl0jPOiJY uOEwQqSWJ/SP9ON9OUybFqlHOsuk8r3o851D43GO1znxuHVz6Gyoeeq3w8gbKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WSy5t1ggvzV7c; Tue, 23 Jul 2024 13:04:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46ND4I8u086251; Tue, 23 Jul 2024 13:04:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46ND4IBd086248; Tue, 23 Jul 2024 13:04:18 GMT (envelope-from git) Date: Tue, 23 Jul 2024 13:04:18 GMT Message-Id: <202407231304.46ND4IBd086248@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Baptiste Daroussin Subject: git: 07d17ca189fc - main - nuageinit: Set recommended SSH permissions List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 07d17ca189fcf3cc44b7706040b05ca8135c3b85 Auto-Submitted: auto-generated The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=07d17ca189fcf3cc44b7706040b05ca8135c3b85 commit 07d17ca189fcf3cc44b7706040b05ca8135c3b85 Author: Jose Luis Duran AuthorDate: 2024-07-23 08:59:09 +0000 Commit: Baptiste Daroussin CommitDate: 2024-07-23 13:02:28 +0000 nuageinit: Set recommended SSH permissions As stated in sshd(8), the recommended permissions for ~/.ssh are read/write/execute for the user, and not accessible by others; and the recommended permissions for ~/.ssh/authorized_keys are read/write for the user, and not accessible by others. --- libexec/nuageinit/nuage.lua | 2 ++ libexec/nuageinit/tests/nuage.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libexec/nuageinit/nuage.lua b/libexec/nuageinit/nuage.lua index 81fb40c0d8eb..10451dc0bdc4 100644 --- a/libexec/nuageinit/nuage.lua +++ b/libexec/nuageinit/nuage.lua @@ -205,9 +205,11 @@ local function addsshkey(homedir, key) f:write(key .. "\n") f:close() if chownak then + os.execute("chmod 0600 " .. ak_path) pu.chown(ak_path, dirattrs.uid, dirattrs.gid) end if chowndotssh then + os.execute("chmod 0700 " .. dotssh_path) pu.chown(dotssh_path, dirattrs.uid, dirattrs.gid) end end diff --git a/libexec/nuageinit/tests/nuage.sh b/libexec/nuageinit/tests/nuage.sh index bbf306eae51f..531c171a3271 100644 --- a/libexec/nuageinit/tests/nuage.sh +++ b/libexec/nuageinit/tests/nuage.sh @@ -17,6 +17,8 @@ addsshkey_body() { if [ ! -f .ssh/authorized_keys ]; then atf_fail "ssh key not added" fi + atf_check -o inline:".ssh: 040700 [drwx------ ] -> 040700 [drwx------ ]\n" chmod -vv 0700 .ssh + atf_check -o inline:".ssh/authorized_keys: 0100600 [-rw------- ] -> 0100600 [-rw------- ]\n" chmod -vv 0600 .ssh/authorized_keys atf_check -o inline:"mykey\n" cat .ssh/authorized_keys atf_check /usr/libexec/flua $(atf_get_srcdir)/addsshkey.lua atf_check -o inline:"mykey\nmykey\n" cat .ssh/authorized_keys