commit 53bed50154a249d1263a3066d28500b3541539d5 from: Omar Polo date: Wed Mar 29 17:16:30 2023 UTC use $mid.$partno.$ext for attachments rather than random strings Keeps the attachment file names stable while it also allows to drop the dep on Tempfile, the unveil of /tmp and the fattr pledge promise too. commit - 70b47196e34f4f26bce03cb299d75aee2b6e34f6 commit + 53bed50154a249d1263a3066d28500b3541539d5 blob - 56d7c607a3cfd9f8e92396ffd70c7bce43d193af blob + 8f291686b1442a49b81b17cfe468f87b9a6d5084 --- mexp +++ mexp @@ -9,7 +9,6 @@ use utf8; use strict; use warnings; use v5.32; -use File::Temp qw(tempfile); use OpenBSD::Pledge; use OpenBSD::Unveil; @@ -23,12 +22,9 @@ die 'Set $OUTDIR' unless defined $outdir; unveil("/usr/local/bin/mshow", "rx") or die "unveil mshow: $!"; unveil($outdir, "rwc") or die "unveil $outdir: $!"; -# can't use tmppath because File::Temp checks whether /tmp exists. -unveil("/tmp", "rwc") or die "unveil /tmp: $!"; unveil(".", "r") or die "unveil .: $!"; -# fattr for File::Temp -pledge("stdio rpath wpath cpath proc exec fattr") or die "pledge: $!"; +pledge("stdio rpath wpath cpath proc exec") or die "pledge: $!"; sub export_part { my ($fh, $n, $fname) = @_; @@ -103,7 +99,7 @@ while (<>) { open(my $parts, '-|', 'mshow', '-t', $fname) or die "can't exec mshow: $!"; - my $part_seen = 0; + my $partno = 0; while (<$parts>) { my ($n, $mime, $size, $name) = m/(\d+): ([^ ]+) size=(\d+) name="(.*)"/ or next; @@ -128,25 +124,22 @@ while (<>) { # text/* is bundled in the body by mshow(1). - if (!$part_seen) { - $part_seen = 1; - say $fh "" if $partno > 0; my $encmid = urlencode $mid; my $enctid = urlencode $tid;