Skip to content

Commit

Permalink
remove uuencode in favor of pack()
Browse files Browse the repository at this point in the history
  • Loading branch information
lskatz committed Jul 8, 2024
1 parent 754c0b9 commit ea516be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 11 additions & 4 deletions SneakerNet.plugins/emailWhoever.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use SneakerNet qw/exitOnSomeSneakernetOptions recordProperties readConfig passfail command logmsg version/;
use List::MoreUtils qw/uniq/;

our $VERSION = "3.3";
our $VERSION = "3.4";
our $CITATION= "Email whoever by Lee Katz";

my $snVersion=version();
Expand All @@ -36,7 +36,7 @@ sub main{
$$settings{tempdir}||=File::Temp::tempdir(basename($0).".XXXXXX",TMPDIR=>1,CLEANUP=>1);
#$$settings{tempdir}||=File::Temp::tempdir(basename($0).".XXXXXX",TMPDIR=>1);

my @exe = qw(sendmail uuencode);
my @exe = qw(sendmail);
exitOnSomeSneakernetOptions({
_CITATION => $CITATION,
_VERSION => $VERSION,
Expand Down Expand Up @@ -228,7 +228,6 @@ sub emailWhoever{
for my $file(@finalAttachment){
append_attachment($fh, $file);
}


close $fh;
command("sendmail -t < $emailFile");
Expand Down Expand Up @@ -294,10 +293,18 @@ sub append_attachment {

# Encode the attachment content using base64 encoding
my $attachment_name = basename($file_path);
my $encoded_content = `uuencode $file_path $attachment_name`;

open(my $attachment_fh, "<", $file_path) or die "Failed to open attachment file $file_path: $!";
binmode $attachment_fh;
my $attachment_content = do { local $/; <$attachment_fh> };
close $attachment_fh;

my $encoded_content = pack("u", $attachment_content);
die "Failed to encode attachment content from $file_path: $!" if $?;

print $fh "begin 644 $attachment_name\n";
print $fh $encoded_content . "\n";
print $fh "end\n";

# Print a newline to separate MIME parts
print $fh "\n";
Expand Down
14 changes: 11 additions & 3 deletions SneakerNet.plugins/sn_immediateStatus.pl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Text::Fuzzy;

our $VERSION = "1.8";
our $VERSION = "1.9";
our $CITATION= "Immediate status report by Lee Katz";

local $0=fileparse $0;
Expand All @@ -24,7 +24,7 @@
sub main{
my $settings=readConfig();
GetOptions($settings,qw(version emails=s citation check-dependencies help force tempdir=s debug numcpus=i)) or die $!;
my @exe = qw(sendmail uuencode);
my @exe = qw(sendmail);
exitOnSomeSneakernetOptions({
_CITATION => $CITATION,
_VERSION => $VERSION,
Expand Down Expand Up @@ -194,10 +194,18 @@ sub append_attachment {

# Encode the attachment content using base64 encoding
my $attachment_name = basename($file_path);
my $encoded_content = `uuencode $file_path $attachment_name`;

open(my $attachment_fh, "<", $file_path) or die "Failed to open attachment file $file_path: $!";
binmode $attachment_fh;
my $attachment_content = do { local $/; <$attachment_fh> };
close $attachment_fh;

my $encoded_content = pack("u", $attachment_content);
die "Failed to encode attachment content from $file_path: $!" if $?;

print $fh "begin 644 $attachment_name\n";
print $fh $encoded_content . "\n";
print $fh "end\n";

# Print a newline to separate MIME parts
print $fh "\n";
Expand Down

0 comments on commit ea516be

Please sign in to comment.