Bugzilla – Attachment 12763 Details for
Bug 8897
Optional GnuPG encryption of outgoing emails
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8897 [ENH] Optional GnuPG encryption of outgoing emails
Bug-8897-ENH-Optional-GnuPG-encryption-of-outgoing.patch (text/plain), 7.57 KB, created by
Mirko Tietgen
on 2012-10-10 18:33:25 UTC
(
hide
)
Description:
Bug 8897 [ENH] Optional GnuPG encryption of outgoing emails
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2012-10-10 18:33:25 UTC
Size:
7.57 KB
patch
obsolete
>From ecbf70b9c1949f1ca2b2e83a98ced0ffab9a677c Mon Sep 17 00:00:00 2001 >From: Mirko Tietgen <mirko@abunchofthings.net> >Date: Wed, 10 Oct 2012 20:29:45 +0200 >Subject: [PATCH] Bug 8897 [ENH] Optional GnuPG encryption of outgoing emails >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit >Content-Type: text/plain; charset="utf-8" > >This enhancement allows GnuPG encryption of emails sent by Koha. >Initial patch with some basic functionality. >TODO: key management, attachments ⦠>--- > C4/GnuPG.pm | 73 ++++++++++++++++++++ > C4/Letters.pm | 8 ++ > C4/Message.pm | 5 ++ > installer/data/mysql/sysprefs.sql | 2 + > installer/data/mysql/updatedatabase.pl | 8 ++ > .../prog/en/modules/admin/preferences/admin.pref | 8 ++ > 6 files changed, 104 insertions(+), 0 deletions(-) > create mode 100644 C4/GnuPG.pm > >diff --git a/C4/GnuPG.pm b/C4/GnuPG.pm >new file mode 100644 >index 0000000..0b76a66 >--- /dev/null >+++ b/C4/GnuPG.pm >@@ -0,0 +1,73 @@ >+package C4::GnuPG; >+ >+# Copyright 2012 Mirko Tietgen >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+ >+use C4::Context; >+use Crypt::GPG; >+ >+=head1 C4::GnuPG >+ >+C4::GnuPG >+ >+=head1 Description >+ >+Provides methods to interact with GnuPG via Crypt::GPG for the purpose of encrypting emails to patrons >+ >+=cut >+ >+my $gpg = new Crypt::GPG; >+ >+$gpg->gpgbin(C4::Context->preference('GnuPGPPath')); >+$gpg->secretkey(C4::Context->preference('KohaAdminEmailAddress')); >+$gpg->passphrase(C4::Context->preference('GnuPGPassphrase')); >+ >+ >+=head2 encrypt >+ >+Take email content and patron's email address, send back encrypted content. Call like >+$content = C4::GnuPG->encrypt($content, $patronemail); >+ >+=cut >+ >+sub encrypt { >+ my ($self, $content, $patronemail) = @_; >+ $content = $gpg->encrypt($content, $patronemail); >+ return $content; >+} >+ >+=head2 does_exist >+ >+Check if there is a GnuPG key for the patron's email address. Call like >+if ( C4::GnuPG->does_exist($useremail) = 1 ) { >+ # ⦠encrypt ⦠>+} >+ >+=cut >+ >+sub does_exist { >+ my ($self, $patronemail) = @_; >+ if ( $gpg->keydb($patronemail) ) { >+ return 1; >+ } >+ else { >+ return 0; >+ } >+} >diff --git a/C4/Letters.pm b/C4/Letters.pm >index f646241..93f7c66 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -36,6 +36,8 @@ use Carp; > > use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); > >+use C4::GnuPG; >+ > BEGIN { > require Exporter; > # set the version for version checking >@@ -782,6 +784,12 @@ sub EnqueueLetter { > ); > } > >+ # gnupg encrypt content if encryption enabled and key for patron present >+ my $useremail = $params->{'to_address'}; >+ if ( (C4::Context->preference("GnuPGPassphrase")) && (C4::Context->preference("GnuPGPassphrase") ne '') && (C4::GnuPG->does_exist($params->{'to_address'}) == 1) ) { >+ $params->{'letter'}->{'content'} = C4::GnuPG->encrypt($params->{'letter'}->{'content'}, $params->{'to_address'}); >+ } >+ > my $dbh = C4::Context->dbh(); > my $statement = << 'ENDSQL'; > INSERT INTO message_queue >diff --git a/C4/Message.pm b/C4/Message.pm >index a63b3ca..5b3caff 100644 >--- a/C4/Message.pm >+++ b/C4/Message.pm >@@ -25,6 +25,7 @@ use C4::Context; > use C4::Letters; > use YAML::Syck; > use Carp; >+use C4::GnuPG; > > =head1 NAME > >@@ -322,6 +323,10 @@ sub append { > push @{$metadata->{body}}, $item; > $self->metadata($metadata); > my $new_content = $self->render_metadata($format); >+ # gnupg encrypt content if encryption enabled and key for patron present >+ if ( (C4::Context->preference("GnuPGPassphrase")) && (C4::Context->preference("GnuPGPassphrase") ne '') && (C4::GnuPG->does_exist($self->{'to_address'}) == 1) ) { >+ $new_content = C4::GnuPG->encrypt($new_content, $self->{'to_address'}) >+ } > return $self->content($new_content); > } > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 178ff40..237836d 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -386,3 +386,5 @@ INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidy > INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free'); > INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('BlockReturnOfWithdrawnItems', '1', '0', 'If enabled, items that are marked as withdrawn cannot be returned.', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('HoldsToPullStartDate','2','Set the default start date for the Holds to pull list to this many days ago',NULL,'Integer'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPath','/usr/bin/gpg','Path to GnuPG','','free'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPassphrase','','Passphrase for GnuPG','','free'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index fb389da..5a55ebe 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6002,6 +6002,14 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = 'XXX'; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPath','/usr/bin/gpg','Path to GnuPG','','free');"); >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GnuPGPassphrase','','Passphrase for GnuPG','','free');"); >+ print "Upgrade to $DBversion done (Add GnuPGPath and GnuPGPassphrase sysprefs)\n"; >+ SetVersion ($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index 4e907e1..cf42fdf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -40,6 +40,14 @@ Administration: > yes: Allow > no: "Don't allow" > - staff and patrons to create and view saved lists of books. >+ - >+ - GnuPG passphrase used to encrypt outgoing emails from KohaAdminEmailAddress. Leave blank to disable encryption. You must have GnuPG running and a keypair setup for KohaAdminEmailAddress to use this. >+ - pref: GnuPGPassphrase >+ class: password >+ - >+ - Path to GnuPG >+ - pref: GnuPGPath >+ - class: textarea > Login options: > - > - pref: insecure >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8897
:
12763
|
12991
|
12992
|
12993
|
13954
|
13955
|
19820
|
19823
|
19835
|
19836
|
19840
|
19872
|
21235
|
27296
|
46640