Subject: Developers of Sympa
List archive
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough
- From: IKEDA Soji <address@concealed>
- To: address@concealed
- Subject: Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough
- Date: Tue, 22 Jul 2014 10:58:26 +0900
Hi,
I prefer to on-memory processing. I suppose secure information such
as private keys would not be unneccessarily written into storage if
at all possible --- even if they are removed soon, random blocks of
disk will keep information --- let alone passphrases.
Regards,
--- Soji
On Fri, 18 Jul 2014 15:26:04 +0200 (CEST)
address@concealed wrote:
> sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need
> to use a fifo, a simple temporary file with strict permission is enough
> Revision 11189 Author rousse Date 2014-07-18 15:26:03 +0200 (ven. 18 juil.
> 2014)
> Log Message[dev] simplification: no need to use a fifo, a simple temporary
> file with strict permission is enough
> Modified Paths
> trunk/src/lib/Sympa/Message.pm
> Diff
> Modified: trunk/src/lib/Sympa/Message.pm (11188 => 11189)
> --- trunk/src/lib/Sympa/Message.pm 2014-07-18 13:17:43 UTC (rev 11188)
> +++ trunk/src/lib/Sympa/Message.pm 2014-07-18 13:26:03 UTC (rev 11189)
> @@ -699,7 +699,6 @@
> }
>
> my $temporary_file = $tmpdir . "/decrypted_message" . "." . $PID;
> - my $temporary_pwd = $tmpdir . '/pass.' . $PID;
>
> ## dump the incoming message.
> if (!open(MSGDUMP, "> $temporary_file")) {
> @@ -712,38 +711,33 @@
>
> my $decrypted_string = '';
>
> + my $password_file;
> + if ($key_password) {
> + my $umask = umask;
> + umask 0077;
> + $password_file = File::Temp->new(
> + DIR => $tmpdir,
> + UNLINK => $main::options{'debug'} ? 0 : 1
> + );
> +
> + print $password_file $key_password;
> + close $password_file;
> + umask $umask;
> + }
> +
> ## try all keys/certs until one decrypts.
> my $decrypted_entity;
> while (my $certfile = shift @$certs) {
> my $keyfile = shift @$keys;
> $main::logger->do_log(Sympa::Logger::DEBUG, 'Trying decrypt with
> %s, %s',
> $certfile, $keyfile);
> - if ($key_password) {
> - unless (POSIX::mkfifo($temporary_pwd, 0600)) {
> - $main::logger->do_log(Sympa::Logger::ERR,
> - 'Unable to make fifo for %s',
> - $temporary_pwd);
> - return undef;
> - }
> - }
> +
> my $command = "$openssl smime -decrypt" .
> " -in $temporary_file -recip $certfile -inkey $keyfile" .
> - ($key_password ? " -passin file:$temporary_pwd" : "" );
> + ($password_file ? " -passin file:$password_file" : "" );
> $main::logger->do_log(Sympa::Logger::DEBUG3, '%s', $command);
> open(NEWMSG, "$command |");
>
> - if ($key_password) {
> - unless (open(FIFO, "> $temporary_pwd")) {
> - $main::logger->do_log(Sympa::Logger::ERR,
> - 'Unable to open fifo for %s',
> - $temporary_pwd);
> - return undef;
> - }
> - print FIFO $key_password;
> - close FIFO;
> - unlink($temporary_pwd);
> - }
> -
> while (<NEWMSG>) {
> $decrypted_string .= $_;
> }
> @@ -1453,15 +1447,23 @@
> $dup_msg->print(\*MSGDUMP);
> close(MSGDUMP);
>
> + my $password_file;
> if ($key_password) {
> - unless (POSIX::mkfifo($temporary_pwd, 0600)) {
> - $main::logger->do_log(Sympa::Logger::NOTICE, 'Unable to make
> fifo for %s',
> - $temporary_pwd);
> - }
> + my $umask = umask;
> + umask 0077;
> + $password_file = File::Temp->new(
> + DIR => $tmpdir,
> + UNLINK => $main::options{'debug'} ? 0 : 1
> + );
> +
> + print $password_file $key_password;
> + close $password_file;
> + umask $umask;
> }
> +
> my $command = "$openssl smime -sign -rand $tmpdir/rand" .
> " -signer $cert -inkey $key " . "-in $temporary_file" .
> - ($key_password ? " -passin file:$temporary_pwd" : "" );
> + ($password_file ? " -passin file:$password_file" : "" );
> $main::logger->do_log(Sympa::Logger::DEBUG2, '%s', $command);
> unless (open NEWMSG, "$command |") {
> $main::logger->do_log(Sympa::Logger::NOTICE,
> @@ -1469,17 +1471,6 @@
> return undef;
> }
>
> - if ($key_password) {
> - unless (open(FIFO, "> $temporary_pwd")) {
> - $main::logger->do_log(Sympa::Logger::NOTICE, 'Unable to open
> fifo for %s',
> - $temporary_pwd);
> - }
> -
> - print FIFO $key_password;
> - close FIFO;
> - unlink($temporary_pwd);
> - }
> -
> my $new_message_as_string = '';
> while (<NEWMSG>) {
> $new_message_as_string .= $_;
--
--
株式会社 コンバージョン セキュリティ&OSSソリューション部 池田荘児
〒231-0004 神奈川県横浜市中区元浜町3-21-2 ヘリオス関内ビル7F
e-mail address@concealed TEL 045-640-3550
http://www.conversion.co.jp/
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
IKEDA Soji, 07/22/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
Guillaume Rousse, 07/22/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
IKEDA Soji, 07/22/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
Guillaume Rousse, 07/28/2014
- Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough, Guillaume Rousse, 07/28/2014
- Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough, IKEDA Soji, 07/29/2014
- Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough, Marc Chantreux, 07/29/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
Guillaume Rousse, 07/28/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
IKEDA Soji, 07/22/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[11189] trunk/src/lib/Sympa/Message.pm: [dev] simplification: no need to use a fifo, a simple temporary file with strict permission is enough,
Guillaume Rousse, 07/22/2014
Archive powered by MHonArc 2.6.19+.