diff options
author | Miquel Lionel <lionel@les-miquelots.net> | 2021-06-23 14:28:20 +0100 |
---|---|---|
committer | Miquel Lionel <lionelmiquel@sfr.fr> | 2021-06-23 14:32:18 +0100 |
commit | 3da6985b6b9598e8fb4b5f71e09c4460c23d4255 (patch) | |
tree | 0843525115c4b58ab9149ed512546ff7cc4293ef /link-tmpl-template.cgi | |
parent | 3ba254bbaf0be04c237c5aae5dfcb43538202dc2 (diff) | |
download | gpigeon-3da6985b6b9598e8fb4b5f71e09c4460c23d4255.tar.gz gpigeon-3da6985b6b9598e8fb4b5f71e09c4460c23d4255.zip |
Fix auto deletion flow in link-tmpl-template.cgi
- The file auto-deletion flow was *inside*
the HAS_MAILSERVER check... oops, fixing that
- fixing the indenting in the same file, it was
a clusterfuck (still is but way less).
- removed an useless for(1) in ValidCookie function
in gpigeon-template.cgi.
- Makefile change: I trust more the GNUPGHOME variable
than the --homedir options of gpg for importing a key and creating
a GPG directory at the same time.
Diffstat (limited to 'link-tmpl-template.cgi')
-rw-r--r-- | link-tmpl-template.cgi | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/link-tmpl-template.cgi b/link-tmpl-template.cgi index b2fe3b3..2984e9f 100644 --- a/link-tmpl-template.cgi +++ b/link-tmpl-template.cgi @@ -36,48 +36,48 @@ elsif (defined $length_msg_form and $length_msg_form eq 0 ){ } else { if (defined $length_msg_form and $ENV{REQUEST_METHOD} eq 'POST'){ - $msg_form =~ tr/\r//d; - my $gpg = new GPG(gnupg_path => "/usr/bin", homedir => $GPG_HOMEDIR); - $enc_msg = $gpg->encrypt("$linkuser:\n\n$msg_form", $mymail_gpgid) or die $gpg->error(); + $msg_form =~ tr/\r//d; + my $gpg = new GPG(gnupg_path => "/usr/bin", homedir => $GPG_HOMEDIR); + $enc_msg = $gpg->encrypt("$linkuser:\n\n$msg_form", $mymail_gpgid) or die $gpg->error(); - if ($HAS_MAILSERVER){ - undef $mymailaddr_escaped; - use Mail::Sendmail; - my %mail = ( To => "$mymailaddr" - From => "$mailsender" - Subject => '.' - Message => "$enc_msg\n" - ); - sendmail(%mail) or die $Mail::Sendmail::error; - } - else { - use Net::SMTP; - use Net::SMTPS; - my $smtp = Net::SMTPS->new($mailsender_smtp, Port => $mailsender_port, doSSL => 'ssl', Debug_SSL => 0); - my $mymailaddr_escaped = EscapeArobase{$mymailaddr}; - my $mailsender_escaped = EscapeArobase($mailsender); + if ($HAS_MAILSERVER){ + undef $mymailaddr_escaped; + use Mail::Sendmail; + my %mail = ( To => "$mymailaddr" + From => "$mailsender" + Subject => '.' + Message => "$enc_msg\n" + ); + sendmail(%mail) or die $Mail::Sendmail::error; + } + else { + use Net::SMTP; + use Net::SMTPS; + my $smtp = Net::SMTPS->new($mailsender_smtp, Port => $mailsender_port, doSSL => 'ssl', Debug_SSL => 0); + my $mymailaddr_escaped = EscapeArobase{$mymailaddr}; + my $mailsender_escaped = EscapeArobase($mailsender); - $smtp->auth($mailsender, $mailsender_pw) or die; - $smtp->mail($mailsender) or die "Net::SMTP module has broke: $!."; - if ($smtp->to($mymailaddr)){ - $smtp->data(); - $smtp->datasend("From: $mailsender_escaped\n"); - $smtp->datasend("To: $mymailaddr_escaped\n"); - $smtp->datasend("Subject: .\n"); - $smtp->datasend("\n"); - $smtp->datasend("$enc_msg\n"); - $smtp->dataend(); - } - else { - die $smtp->message(); - } - my $f = $0; - if ($f =~ /^([\w]+)$/){ - unlink "$1"; - } - print "Location: /merci/index.html\n\n"; - } - } + $smtp->auth($mailsender, $mailsender_pw) or die; + $smtp->mail($mailsender) or die "Net::SMTP module has broke: $!."; + if ($smtp->to($mymailaddr)){ + $smtp->data(); + $smtp->datasend("From: $mailsender_escaped\n"); + $smtp->datasend("To: $mymailaddr_escaped\n"); + $smtp->datasend("Subject: .\n"); + $smtp->datasend("\n"); + $smtp->datasend("$enc_msg\n"); + $smtp->dataend(); + } + else { + die $smtp->message(); + } + } + + if ($0 =~ /([\w]+)\.cgi$/){ + unlink "$1.cgi"; + } + print "Location: /merci/index.html\n\n"; + } } print "Content-type: text/html", "\n\n"; print qq{<!DOCTYPE html> |