user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 0/3] clone+fetch stuff
@ 2021-10-14  4:32  7% Eric Wong
  2021-10-14  4:32  6% ` [PATCH 2/3] lei add-external --mirror: respect client umask Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-14  4:32 UTC (permalink / raw)
  To: meta

Eric Wong (3):
  clone+fetch: respect umask for all downloaded files
  lei add-external --mirror: respect client umask
  lei: give workers their own process group

 lib/PublicInbox/Fetch.pm      |  5 ++---
 lib/PublicInbox/LEI.pm        | 21 +++++++++++++++++----
 lib/PublicInbox/LeiMirror.pm  | 35 +++++++++++++++++++++--------------
 lib/PublicInbox/LeiXSearch.pm |  2 +-
 script/lei                    |  2 ++
 5 files changed, 43 insertions(+), 22 deletions(-)

^ permalink raw reply	[relevance 7%]

* [PATCH 2/3] lei add-external --mirror: respect client umask
  2021-10-14  4:32  7% [PATCH 0/3] clone+fetch stuff Eric Wong
@ 2021-10-14  4:32  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-14  4:32 UTC (permalink / raw)
  To: meta

While lei is intended for non-public mail and runs umask(077)
by default, externals are one area which can safely defer to
the user's umask.

Instead of sending it unconditionally with every command, only
have lei-daemon request it when necessary.
---
 lib/PublicInbox/LEI.pm       | 11 +++++++++++
 lib/PublicInbox/LeiMirror.pm |  2 ++
 script/lei                   |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index bd8a6bef632b..635cd0c5508a 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -1518,4 +1518,15 @@ sub cfg_dump ($$) {
 	undef;
 }
 
+sub request_umask {
+	my ($lei) = @_;
+	my $s = $lei->{sock} // return;
+	send($s, 'umask', MSG_EOR) // die "send: $!";
+	vec(my $rvec = '', fileno($s), 1) = 1;
+	select($rvec, undef, undef, 2) or die 'timeout waiting for umask';
+	recv($s, my $v, 5, 0) // die "recv: $!";
+	(my $u, $lei->{client_umask}) = unpack('AV', $v);
+	$u eq 'u' or warn "E: recv $v has no umask";
+}
+
 1;
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index 1369c00c57fd..fb73d8631670 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -424,6 +424,7 @@ sub start_clone_url {
 sub do_mirror { # via wq_io_do
 	my ($self) = @_;
 	my $lei = $self->{lei};
+	umask($lei->{client_umask}) if defined $lei->{client_umask};
 	eval {
 		my $iv = $lei->{opt}->{'inbox-version'};
 		if (defined $iv) {
@@ -448,6 +449,7 @@ sub start {
 	require PublicInbox::Inbox;
 	require PublicInbox::Admin;
 	require PublicInbox::InboxWritable;
+	$lei->request_umask;
 	my ($op_c, $ops) = $lei->workers_start($self, 1);
 	$lei->{wq1} = $self;
 	$self->wq_io_do('do_mirror', []);
diff --git a/script/lei b/script/lei
index bc43779821e7..8f6e8aacb86b 100755
--- a/script/lei
+++ b/script/lei
@@ -122,6 +122,8 @@ while (1) {
 		$exec_cmd->(\@fds, split(/\0/, $1));
 	} elsif ($buf eq '-WINCH') {
 		kill($buf, @parent); # for MUA
+	} elsif ($buf eq 'umask') {
+		send($sock, 'u'.pack('V', umask), MSG_EOR) or die "send: $!"
 	} elsif ($buf =~ /\Ax_it ([0-9]+)\z/) {
 		$x_it_code ||= $1 + 0;
 		last;

^ permalink raw reply related	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-14  4:32  7% [PATCH 0/3] clone+fetch stuff Eric Wong
2021-10-14  4:32  6% ` [PATCH 2/3] lei add-external --mirror: respect client umask Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).