unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: "Štěpán Němec" <stepnem@smrk.net>
To: meta@public-inbox.org
Subject: [PATCH 1/2] t/init.t: test newly created config permissions
Date: Mon, 28 Aug 2023 12:45:13 +0200	[thread overview]
Message-ID: <20230828104514.937030-1-stepnem@smrk.net> (raw)

Creating config 0600 disregarding umask breaks scenarios where daemons
run with credentials different from config owner (but need to read the
config).

Fixed in the next commit.
---
 t/init.t | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/t/init.t b/t/init.t
index 0096ca307962..82a2a4436261 100644
--- a/t/init.t
+++ b/t/init.t
@@ -19,7 +19,11 @@ sub quiet_fail {
 	my $cfgfile = "$ENV{PI_DIR}/config";
 	my $cmd = [ '-init', 'blist', "$tmpdir/blist",
 		   qw(http://example.com/blist blist@example.com) ];
+	my $umask = umask(070) // xbail "umask: $!";
 	ok(run_script($cmd), 'public-inbox-init OK');
+	umask($umask) // xbail "umask: $!";
+	my $mode = (stat($cfgfile))[2];
+	is(sprintf('0%03o', $mode & 0777), '0604', 'config respects umask');
 
 	is(read_indexlevel('blist'), '', 'indexlevel unset by default');
 

base-commit: a036772bdf732d4779f44974095bfdd0b30271ef
prerequisite-patch-id: ae82f21759a714a6b09181e43d7188ce161b0838
prerequisite-patch-id: 2e5b084feebccfac20ec7229d44f752a03378ce1
prerequisite-patch-id: f448c88e715000bd71f3728f4b41cc36966765e6
prerequisite-patch-id: 417d67853ab35049abd2be97e8ce6850397053f2
prerequisite-patch-id: 2b3a925b08e3c5d032536f81d7e899893da6247b
-- 
2.42.0


             reply	other threads:[~2023-08-28 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 10:45 Štěpán Němec [this message]
2023-08-28 10:45 ` [PATCH 2/2] public-inbox-init: honor umask when creating config file Štěpán Němec
2023-08-28 21:19 ` [PATCH 1/2] t/init.t: test newly created config permissions Eric Wong
2023-08-28 21:30   ` Štěpán Němec
2023-08-29  1:13     ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230828104514.937030-1-stepnem@smrk.net \
    --to=stepnem@smrk.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).