diff options
author | intrigeri <intrigeri@boum.org> | 2015-04-27 09:23:12 +0000 |
---|---|---|
committer | intrigeri <intrigeri@boum.org> | 2015-04-27 09:23:12 +0000 |
commit | b528cc9c9bb8a277708ef8f5420c89baa437f067 (patch) | |
tree | e39dc38699010f707d13019f127bb2c448d68c1b | |
parent | ba502b274ef7966a38655717d7d0a6abf6fbcb34 (diff) |
Imported Upstream version 0.52
35 files changed, 921 insertions, 765 deletions
@@ -1,5 +1,19 @@ Revision history for GnuPG-Interface +0.52 - 2016-02-16 + - Skip "grp" records, generated by GPG 2.1; this suppresses "unknown + record type" warnings + - Add explicit Fatal dependency; though nominally part of code perl, + RedHat's perl does not ship with it + - Ensure that the trustdb is created before attempting to encrypt; gpg2 + requires that it exist, even for commands with --trust-model=always. + See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751266 + +0.51 - 2014-12-17 + - Update README file + - Work around gpg2 bug by omitting --homedir during symmetric + encryption + 0.50 - 2014-03-14 - Version 0.49 implicitly required Moose; switch to a technique that does not @@ -5,6 +5,7 @@ inc/Module/Install/Can.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm +inc/Module/Install/ReadmeFromPod.pm inc/Module/Install/Win32.pm inc/Module/Install/WriteAll.pm lib/GnuPG/Fingerprint.pm @@ -8,7 +8,7 @@ configure_requires: ExtUtils::MakeMaker: 6.36 distribution_type: module dynamic_config: 1 -generated_by: 'Module::Install version 1.06' +generated_by: 'Module::Install version 1.14' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -20,10 +20,11 @@ no_index: - t - test requires: - Math::BigInt: 1.78 - Moo: 0.091011 - MooX::HandlesVia: 0.001004 - MooX::late: 0.014 + Fatal: 0 + Math::BigInt: '1.78' + Moo: '0.091011' + MooX::HandlesVia: '0.001004' + MooX::late: '0.014' resources: license: http://dev.perl.org/licenses/ -version: 0.50 +version: '0.52' diff --git a/Makefile.PL b/Makefile.PL index 00b9e29..38aca27 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,10 +16,12 @@ author 'Frank J. Tobin'; abstract 'supply object methods for interacting with GnuPG'; name 'GnuPG-Interface'; version_from 'lib/GnuPG/Interface.pm'; +readme_from 'lib/GnuPG/Interface.pm'; requires 'Moo' => '0.091011'; requires 'MooX::HandlesVia' => '0.001004'; requires 'MooX::late' => '0.014'; requires 'Math::BigInt' => '1.78'; +requires 'Fatal'; license 'perl'; @@ -1,456 +1,434 @@ -GnuPG::Interface(3) User Contributed Perl Documentation GnuPG::Interface(3) - - - -NNAAMMEE - GnuPG::Interface − Perl interface to GnuPG - -SSYYNNOOPPSSIISS - # A simple example - use IO::Handle; - use GnuPG::Interface; - - # settting up the situation - my $gnupg = GnuPG::Interface‐>new(); - $gnupg‐>options‐>hash_init( armor => 1, - homedir => ’/home/foobar’ ); - - # Note you can set the recipients even if you aren’t encrypting! - $gnupg‐>options‐>push_recipients( ’ftobin@cpan.org’ ); - $gnupg‐>options‐>meta_interactive( 0 ); - - # how we create some handles to interact with GnuPG - my $input = IO::Handle‐>new(); - my $output = IO::Handle‐>new(); - my $handles = GnuPG::Handles‐>new( stdin => $input, - stdout => $output ); - - # Now we’ll go about encrypting with the options already set - my @plaintext = ( ’foobar’ ); - my $pid = $gnupg‐>encrypt( handles => $handles ); - - # Now we write to the input of GnuPG - print $input @plaintext; - close $input; - - # now we read the output - my @ciphertext = <$output>; - close $output; - - waitpid $pid, 0; - -DDEESSCCRRIIPPTTIIOONN - GnuPG::Interface and its associated modules are designed to provide an - object‐oriented method for interacting with GnuPG, being able to per‐ - form functions such as but not limited to encrypting, signing, decryp‐ - tion, verification, and key‐listing parsing. - - HHooww DDaattaa MMeemmbbeerr AAcccceessssoorr MMeetthhooddss aarree CCrreeaatteedd - - Each module in the GnuPG::Interface bundle relies on Class::MethodMaker - to generate the get/set methods used to set the object’s data members. - _T_h_i_s _i_s _v_e_r_y _i_m_p_o_r_t_a_n_t _t_o _r_e_a_l_i_z_e_. This means that any data member - which is a list has special methods assigned to it for pushing, pop‐ - ping, and clearing the list. - - UUnnddeerrssttaannddiinngg BBiiddiirreeccttiioonnaall CCoommmmuunniiccaattiioonn - - It is also imperative to realize that this package uses interprocess - communication methods similar to those used in IPC::Open3 and "Bidirec‐ - tional Communication with Another Process" in perlipc, and that users - of this package need to understand how to use this method because this - package does not abstract these methods for the user greatly. This - package is not designed to abstract this away entirely (partly for - security purposes), but rather to simply help create ’proper’, clean - calls to GnuPG, and to implement key‐listing parsing. Please see - "Bidirectional Communication with Another Process" in perlipc to learn - how to deal with these methods. - - Using this package to do message processing generally invovlves creat‐ - ing a GnuPG::Interface object, creating a GnuPG::Handles object, set‐ - ting some options in its ooppttiioonnss data member, and then calling a method - which invokes GnuPG, such as cclleeaarrssiiggnn. One then interacts with with - the handles appropriately, as described in "Bidirectional Communication - with Another Process" in perlipc. - -OOBBJJEECCTT MMEETTHHOODDSS - IInniittiiaalliizzaattiioonn MMeetthhooddss - - - new( _%_i_n_i_t_i_a_l_i_z_a_t_i_o_n___a_r_g_s ) - This methods creates a new object. The optional arguments are ini‐ - tialization of data members; the initialization is done in a manner - according to the method created as described in "new_hash_init" in - Class::MethodMaker. - - hash_init( _%_a_r_g_s ). - This methods work as described in "new_hash_init" in Class::Method‐ - Maker. - - OObbjjeecctt MMeetthhooddss wwhhiicchh uussee aa GGnnuuPPGG::::HHaannddlleess OObbjjeecctt - - - list_public_keys( % ) - list_sigs( % ) - list_secret_keys( % ) - encrypt( % ) - encrypt_symmetrically( % ) - sign( % ) - clearsign( % ) - detach_sign( % ) - sign_and_encrypt( % ) - decrypt( % ) - verify( % ) - import_keys( % ) - export_keys( % ) - recv_keys( % ) - send_keys( % ) - These methods each correspond directly to or are very similar to a - GnuPG command described in gpg. Each of these methods takes a - hash, which currently must contain a key of hhaannddlleess which has the - value of a GnuPG::Handles object. Another optional key is ccoomm‐‐ - mmaanndd__aarrggss which should have the value of an array reference; these - arguments will be passed to GnuPG as command arguments. These com‐ - mand arguments are used for such things as determining the keys to - list in the eexxppoorrtt__kkeeyyss method. _P_l_e_a_s_e _n_o_t_e _t_h_a_t _G_n_u_P_G _c_o_m_m_a_n_d - _a_r_g_u_m_e_n_t_s _a_r_e _n_o_t _t_h_e _s_a_m_e _a_s _G_n_u_P_G _o_p_t_i_o_n_s. To understand what - are options and what are command arguments please read "COMMANDS" - in gpg and "OPTIONS" in gpg. - - Each of these calls returns the PID for the resulting GnuPG - process. One can use this PID in a "waitpid" call instead of a - "wait" call if more precise process reaping is needed. - - These methods will attach the handles specified in the hhaannddlleess - object to the running GnuPG object, so that bidirectional communi‐ - cation can be established. That is, the optionally‐defined ssttddiinn, - ssttddoouutt, ssttddeerrrr, ssttaattuuss, llooggggeerr, and ppaasssspphhrraassee handles will be - attached to GnuPG’s input, output, standard error, the handle cre‐ - ated by setting ssttaattuuss‐‐ffdd, the handle created by setting llooggggeerr‐‐ffdd, - and the handle created by setting ppaasssspphhrraassee‐‐ffdd respectively. This - tying of handles of similar to the process done in _I_P_C_:_:_O_p_e_n_3. - - If you want the GnuPG process to read or write directly to an - already‐opened filehandle, you cannot do this via the normal - _I_P_C_:_:_O_p_e_n_3 mechanisms. In order to accomplish this, set the appro‐ - priate hhaannddlleess data member to the already‐opened filehandle, and - then set the option ddiirreecctt to be true for that handle, as described - in "options" in GnuPG::Handles. For example, to have GnuPG read - from the file _i_n_p_u_t_._t_x_t and write to _o_u_t_p_u_t_._t_x_t, the following - snippet may do: - - my $infile = IO::File‐>new( ’input.txt’ ); - my $outfile = IO::File‐>new( ’>output.txt’ ); - my $handles = GnuPG::Handles‐>new( stdin => $infile, - stdout => $outfile, - ); - $handles‐>options( ’stdin’ )‐>{direct} = 1; - $handles‐>options( ’stdout’ )‐>{direct} = 1; - - If any handle in the hhaannddlleess object is not defined, GnuPG’s input, - output, and standard error will be tied to the running program’s - standard error, standard output, or standard error. If the ssttaattuuss - or llooggggeerr handle is not defined, this channel of communication is - never established with GnuPG, and so this information is not gener‐ - ated and does not come into play. If the ppaasssspphhrraassee data member - handle of the hhaannddlleess object is not defined, but the the ppaasssspphhrraassee - data member handle of GnuPG::Interface object is, GnuPG::Interface - will handle passing this information into GnuPG for the user as a - convience. Note that this will result in GnuPG::Interface storing - the passphrase in memory, instead of having it simply - ’pass−through’ to GnuPG via a handle. - - OOtthheerr MMeetthhooddss - - - get_public_keys( @search_strings ) - get_secret_keys( @search_strings ) - get_public_keys_with_sigs( @search_strings ) - These methods create and return objects of the type GnuPG::Pub‐ - licKey or GnuPG::SecretKey respectively. This is done by parsing - the output of GnuPG with the option wwiitthh‐‐ccoolloonnss enabled. The - objects created do or do not have signature information stored in - them, depending if the method ends in ___s_i_g_s; this separation of - functionality is there because of performance hits when listing - information with signatures. - - _t_e_s_t___d_e_f_a_u_l_t___k_e_y___p_a_s_s_p_h_r_a_s_e_(_) - This method will return a true or false value, depending on whether - GnuPG reports a good passphrase was entered while signing a short - message using the values of the ppaasssspphhrraassee data member, and the - default key specified in the ooppttiioonnss data member. - -IInnvvookkiinngg GGnnuuPPGG wwiitthh aa ccuussttoomm ccaallll - GnuPG::Interface attempts to cover a lot of the commands of GnuPG that - one would want to perform; however, there may be a lot more calls that - GnuPG is and will be capable of, so a generic command interface is pro‐ - vided, "wrap_call". - - wrap_call( %args ) - Call GnuPG with a custom command. The %args hash must contain at - least the following keys: - - commands - The value of this key in the hash must be a reference to a a - list of commands for GnuPG, such as "[ qw( −−encrypt −−sign ) - ]". - - handles - As with most other GnuPG::Interface methods, hhaannddlleess must be a - GnuPG::Handles object. - - The following keys are optional. - - command_args - As with other GnuPG::Interface methods, the value in hash for - this key must be a reference to a list of arguments to be - passed to the GnuPG command, such as which keys to list in a - key−listing. - -OOBBJJEECCTT DDAATTAA MMEEMMBBEERRSS - Note that these data members are interacted with via object methods - created using the methods described in "get_set" in Class::MethodMaker, - or "object" in Class::MethodMaker. Please read there for more informa‐ - tion. - - call - This defines the call made to invoke GnuPG. Defaults to ’gpg’; - this should be changed if ’gpg’ is not in your path, or there is a - different name for the binary on your system. - - passphrase - In order to lessen the burden of using handles by the user of this - package, setting this option to one’s passphrase for a secret key - will allow the package to enter the passphrase via a handle to - GnuPG by itself instead of leaving this to the user. See also - "passphrase" in GnuPG::Handles. - - options - This data member, of the type GnuPG::Options; the setting stored in - this data member are used to determine the options used when call‐ - ing GnuPG via _a_n_y of the object methods described in this package. - See GnuPG::Options for more information. - -EEXXAAMMPPLLEESS - The following setup can be done before any of the following examples: - - use IO::Handle; - use GnuPG::Interface; - - my @original_plaintext = ( "How do you doo?" ); - my $passphrase = "Three Little Pigs"; - - my $gnupg = GnuPG::Interface‐>new(); - - $gnupg‐>options‐>hash_init( armor => 1, - recipients => [ ’ftobin@uiuc.edu’, - ’0xABCD1234’ ], - meta_interactive( 0 ), - ); - - EEnnccrryyppttiinngg - - # We’ll let the standard error of GnuPG pass through - # to our own standard error, by not creating - # a stderr‐part of the $handles object. - my ( $input, $output ) = ( IO::Handle‐>new(), - IO::Handle‐>new() ); - - my $handles = GnuPG::Handles‐>new( stdin => $input, - stdout => $output ); - - # this sets up the communication - # Note that the recipients were specified earlier - # in the ’options’ data member of the $gnupg object. - my $pid = $gnupg‐>encrypt( handles => $handles ); - - # this passes in the plaintext - print $input @original_plaintext; - - # this closes the communication channel, - # indicating we are done - close $input; - - my @ciphertext = <$output>; # reading the output - - waitpid $pid, 0; # clean up the finished GnuPG process - - SSiiggnniinngg +NAME + GnuPG::Interface - Perl interface to GnuPG + +SYNOPSIS + # A simple example + use IO::Handle; + use GnuPG::Interface; + + # settting up the situation + my $gnupg = GnuPG::Interface->new(); + $gnupg->options->hash_init( armor => 1, + homedir => '/home/foobar' ); + + # Note you can set the recipients even if you aren't encrypting! + $gnupg->options->push_recipients( 'ftobin@cpan.org' ); + $gnupg->options->meta_interactive( 0 ); + + # how we create some handles to interact with GnuPG + my $input = IO::Handle->new(); + my $output = IO::Handle->new(); + my $handles = GnuPG::Handles->new( stdin => $input, + stdout => $output ); + + # Now we'll go about encrypting with the options already set + my @plaintext = ( 'foobar' ); + my $pid = $gnupg->encrypt( handles => $handles ); + + # Now we write to the input of GnuPG + print $input @plaintext; + close $input; + + # now we read the output + my @ciphertext = <$output>; + close $output; + + waitpid $pid, 0; + +DESCRIPTION + GnuPG::Interface and its associated modules are designed to provide an + object-oriented method for interacting with GnuPG, being able to perform + functions such as but not limited to encrypting, signing, decryption, + verification, and key-listing parsing. + + How Data Member Accessor Methods are Created + Each module in the GnuPG::Interface bundle relies on Moo to generate the + get/set methods used to set the object's data members. *This is very + important to realize.* This means that any data member which is a list + has special methods assigned to it for pushing, popping, and clearing + the list. + + Understanding Bidirectional Communication + It is also imperative to realize that this package uses interprocess + communication methods similar to those used in IPC::Open3 and + "Bidirectional Communication with Another Process" in perlipc, and that + users of this package need to understand how to use this method because + this package does not abstract these methods for the user greatly. This + package is not designed to abstract this away entirely (partly for + security purposes), but rather to simply help create 'proper', clean + calls to GnuPG, and to implement key-listing parsing. Please see + "Bidirectional Communication with Another Process" in perlipc to learn + how to deal with these methods. + + Using this package to do message processing generally invovlves creating + a GnuPG::Interface object, creating a GnuPG::Handles object, setting + some options in its options data member, and then calling a method which + invokes GnuPG, such as clearsign. One then interacts with with the + handles appropriately, as described in "Bidirectional Communication with + Another Process" in perlipc. + +OBJECT METHODS + Initialization Methods + new( *%initialization_args* ) + This methods creates a new object. The optional arguments are + initialization of data members. + + hash_init( *%args* ). + + Object Methods which use a GnuPG::Handles Object + list_public_keys( % ) + list_sigs( % ) + list_secret_keys( % ) + encrypt( % ) + encrypt_symmetrically( % ) + sign( % ) + clearsign( % ) + detach_sign( % ) + sign_and_encrypt( % ) + decrypt( % ) + verify( % ) + import_keys( % ) + export_keys( % ) + recv_keys( % ) + send_keys( % ) + search_keys( % ) + These methods each correspond directly to or are very similar to a + GnuPG command described in gpg. Each of these methods takes a hash, + which currently must contain a key of handles which has the value of + a GnuPG::Handles object. Another optional key is command_args which + should have the value of an array reference; these arguments will be + passed to GnuPG as command arguments. These command arguments are + used for such things as determining the keys to list in the + export_keys method. *Please note that GnuPG command arguments are + not the same as GnuPG options*. To understand what are options and + what are command arguments please read "COMMANDS" in gpg and + "OPTIONS" in gpg. + + Each of these calls returns the PID for the resulting GnuPG process. + One can use this PID in a "waitpid" call instead of a "wait" call if + more precise process reaping is needed. + + These methods will attach the handles specified in the handles + object to the running GnuPG object, so that bidirectional + communication can be established. That is, the optionally-defined + stdin, stdout, stderr, status, logger, and passphrase handles will + be attached to GnuPG's input, output, standard error, the handle + created by setting status-fd, the handle created by setting + logger-fd, and the handle created by setting passphrase-fd + respectively. This tying of handles of similar to the process done + in *IPC::Open3*. + + If you want the GnuPG process to read or write directly to an + already-opened filehandle, you cannot do this via the normal + *IPC::Open3* mechanisms. In order to accomplish this, set the + appropriate handles data member to the already-opened filehandle, + and then set the option direct to be true for that handle, as + described in "options" in GnuPG::Handles. For example, to have GnuPG + read from the file input.txt and write to output.txt, the following + snippet may do: + + my $infile = IO::File->new( 'input.txt' ); + my $outfile = IO::File->new( '>output.txt' ); + my $handles = GnuPG::Handles->new( stdin => $infile, + stdout => $outfile, + ); + $handles->options( 'stdin' )->{direct} = 1; + $handles->options( 'stdout' )->{direct} = 1; + + If any handle in the handles object is not defined, GnuPG's input, + output, and standard error will be tied to the running program's + standard error, standard output, or standard error. If the status or + logger handle is not defined, this channel of communication is never + established with GnuPG, and so this information is not generated and + does not come into play. If the passphrase data member handle of the + handles object is not defined, but the the passphrase data member + handle of GnuPG::Interface object is, GnuPG::Interface will handle + passing this information into GnuPG for the user as a convience. + Note that this will result in GnuPG::Interface storing the + passphrase in memory, instead of having it simply 'pass-through' to + GnuPG via a handle. + + Other Methods + get_public_keys( @search_strings ) + get_secret_keys( @search_strings ) + get_public_keys_with_sigs( @search_strings ) + These methods create and return objects of the type GnuPG::PublicKey + or GnuPG::SecretKey respectively. This is done by parsing the output + of GnuPG with the option with-colons enabled. The objects created do + or do not have signature information stored in them, depending if + the method ends in *_sigs*; this separation of functionality is + there because of performance hits when listing information with + signatures. + + test_default_key_passphrase() + This method will return a true or false value, depending on whether + GnuPG reports a good passphrase was entered while signing a short + message using the values of the passphrase data member, and the + default key specified in the options data member. + + version() + Returns the version of GnuPG that GnuPG::Interface is running. + +Invoking GnuPG with a custom call + GnuPG::Interface attempts to cover a lot of the commands of GnuPG that + one would want to perform; however, there may be a lot more calls that + GnuPG is and will be capable of, so a generic command interface is + provided, "wrap_call". + + wrap_call( %args ) + Call GnuPG with a custom command. The %args hash must contain at + least the following keys: + + commands + The value of this key in the hash must be a reference to a a + list of commands for GnuPG, such as "[ qw( --encrypt --sign ) + ]". + + handles + As with most other GnuPG::Interface methods, handles must be a + GnuPG::Handles object. + + The following keys are optional. + + command_args + As with other GnuPG::Interface methods, the value in hash for + this key must be a reference to a list of arguments to be passed + to the GnuPG command, such as which keys to list in a + key-listing. + +OBJECT DATA MEMBERS + call + This defines the call made to invoke GnuPG. Defaults to 'gpg'; this + should be changed if 'gpg' is not in your path, or there is a + different name for the binary on your system. + + passphrase + In order to lessen the burden of using handles by the user of this + package, setting this option to one's passphrase for a secret key + will allow the package to enter the passphrase via a handle to GnuPG + by itself instead of leaving this to the user. See also "passphrase" + in GnuPG::Handles. + + options + This data member, of the type GnuPG::Options; the setting stored in + this data member are used to determine the options used when calling + GnuPG via *any* of the object methods described in this package. See + GnuPG::Options for more information. + +EXAMPLES + The following setup can be done before any of the following examples: + + use IO::Handle; + use GnuPG::Interface; + + my @original_plaintext = ( "How do you doo?" ); + my $passphrase = "Three Little Pigs"; + + my $gnupg = GnuPG::Interface->new(); + + $gnupg->options->hash_init( armor => 1, + recipients => [ 'ftobin@uiuc.edu', + '0xABCD1234' ], + meta_interactive => 0 , + ); + + Encrypting + # We'll let the standard error of GnuPG pass through + # to our own standard error, by not creating + # a stderr-part of the $handles object. + my ( $input, $output ) = ( IO::Handle->new(), + IO::Handle->new() ); + + my $handles = GnuPG::Handles->new( stdin => $input, + stdout => $output ); + + # this sets up the communication + # Note that the recipients were specified earlier + # in the 'options' data member of the $gnupg object. + my $pid = $gnupg->encrypt( handles => $handles ); + + # this passes in the plaintext + print $input @original_plaintext; + + # this closes the communication channel, + # indicating we are done + close $input; + + my @ciphertext = <$output>; # reading the output + + waitpid $pid, 0; # clean up the finished GnuPG process + + Signing + # This time we'll catch the standard error for our perusing + my ( $input, $output, $error ) = ( IO::Handle->new(), + IO::Handle->new(), + IO::Handle->new(), + ); + + my $handles = GnuPG::Handles->new( stdin => $input, + stdout => $output, + stderr => $error, + ); + + # indicate our pasphrase through the + # convience method + $gnupg->passphrase( $passphrase ); + + # this sets up the communication + my $pid = $gnupg->sign( handles => $handles ); + + # this passes in the plaintext + print $input @original_plaintext; + + # this closes the communication channel, + # indicating we are done + close $input; + + my @ciphertext = <$output>; # reading the output + my @error_output = <$error>; # reading the error + + close $output; + close $error; + + waitpid $pid, 0; # clean up the finished GnuPG process + + Decryption + # This time we'll catch the standard error for our perusing + # as well as passing in the passphrase manually + # as well as the status information given by GnuPG + my ( $input, $output, $error, $passphrase_fh, $status_fh ) + = ( IO::Handle->new(), + IO::Handle->new(), + IO::Handle->new(), + IO::Handle->new(), + IO::Handle->new(), + ); + + my $handles = GnuPG::Handles->new( stdin => $input, + stdout => $output, + stderr => $error, + passphrase => $passphrase_fh, + status => $status_fh, + ); + + # this time we'll also demonstrate decrypting + # a file written to disk + # Make sure you "use IO::File" if you use this module! + my $cipher_file = IO::File->new( 'encrypted.gpg' ); + + # this sets up the communication + my $pid = $gnupg->decrypt( handles => $handles ); + + # This passes in the passphrase + print $passphrase_fh $passphrase; + close $passphrase_fh; + + # this passes in the plaintext + print $input $_ while <$cipher_file>; + + # this closes the communication channel, + # indicating we are done + close $input; + close $cipher_file; + + my @plaintext = <$output>; # reading the output + my @error_output = <$error>; # reading the error + my @status_info = <$status_fh>; # read the status info + + # clean up... + close $output; + close $error; + close $status_fh; + + waitpid $pid, 0; # clean up the finished GnuPG process + + Printing Keys + # This time we'll just let GnuPG print to our own output + # and read from our input, because no input is needed! + my $handles = GnuPG::Handles->new(); + + my @ids = ( 'ftobin', '0xABCD1234' ); + + # this time we need to specify something for + # command_args because --list-public-keys takes + # search ids as arguments + my $pid = $gnupg->list_public_keys( handles => $handles, + command_args => [ @ids ] ); + + waitpid $pid, 0; + + Creating GnuPG::PublicKey Objects + my @ids = [ 'ftobin', '0xABCD1234' ]; + + my @keys = $gnupg->get_public_keys( @ids ); + + # no wait is required this time; it's handled internally + # since the entire call is encapsulated + + Custom GnuPG call + # assuming $handles is a GnuPG::Handles object + my $pid = $gnupg->wrap_call + ( commands => [ qw( --list-packets ) ], + command_args => [ qw( test/key.1.asc ) ], + handles => $handles, + ); + + my @out = <$handles->stdout()>; + waitpid $pid, 0; + +FAQ + How do I get GnuPG::Interface to read/write directly from a filehandle? + You need to set GnuPG::Handles direct option to be true for the + filehandles in concern. See "options" in GnuPG::Handles and "Object + Methods which use a GnuPG::Handles Object" for more information. + + Why do you make it so difficult to get GnuPG to write/read from a + filehandle? In the shell, I can just call GnuPG with the --outfile + option! + There are lots of issues when trying to tell GnuPG to read/write + directly from a file, such as if the file isn't there, or there is a + file, and you want to write over it! What do you want to happen + then? Having the user of this module handle these questions + beforehand by opening up filehandles to GnuPG lets the user know + fully what is going to happen in these circumstances, and makes the + module less error-prone. + + When having GnuPG process a large message, sometimes it just hanges + there. + Your problem may be due to buffering issues; when GnuPG reads/writes + to non-direct filehandles (those that are sent to filehandles which + you read to from into memory, not that those access the disk), + buffering issues can mess things up. I recommend looking into + "options" in GnuPG::Handles. + +NOTES + This package is the successor to PGP::GPG::MessageProcessor, which I + found to be too inextensible to carry on further. A total redesign was + needed, and this is the resulting work. + + After any call to a GnuPG-command method of GnuPG::Interface in which + one passes in the handles, one should all wait to clean up GnuPG from + the process table. + +BUGS + Currently there are problems when transmitting large quantities of + information over handles; I'm guessing this is due to buffering issues. + This bug does not seem specific to this package; IPC::Open3 also appears + affected. + + I don't know yet how well this modules handles parsing OpenPGP v3 keys. + +SEE ALSO + GnuPG::Options, GnuPG::Handles, GnuPG::PublicKey, GnuPG::SecretKey, gpg, + "Bidirectional Communication with Another Process" in perlipc + +LICENSE + This module is free software; you can redistribute it and/or modify it + under the same terms as Perl itself. + +AUTHOR + GnuPg::Interface is currently maintained by Jesse Vincent + <jesse@cpan.org>. + + Frank J. Tobin, ftobin@cpan.org was the original author of the package. - # This time we’ll catch the standard error for our perusing - my ( $input, $output, $error ) = ( IO::Handle‐>new(), - IO::Handle‐>new(), - IO::Handle‐>new(), - ); - - my $handles = GnuPG::Handles‐>new( stdin => $input, - stdout => $output, - stderr => $error, - ); - - # indicate our pasphrase through the - # convience method - $gnupg‐>passphrase( $passphrase ); - - # this sets up the communication - my $pid = $gnupg‐>sign( handles => $handles ); - - # this passes in the plaintext - print $input @original_plaintext; - - # this closes the communication channel, - # indicating we are done - close $input; - - my @ciphertext = <$output>; # reading the output - my @error_output = <$error>; # reading the error - - close $output; - close $error; - - waitpid $pid, 0; # clean up the finished GnuPG process - - DDeeccrryyppttiioonn - - # This time we’ll catch the standard error for our perusing - # as well as passing in the passphrase manually - # as well as the status information given by GnuPG - my ( $input, $output, $error, $passphrase_fh, $status_fh ) - = ( IO::Handle‐>new(), - IO::Handle‐>new(), - IO::Handle‐>new(), - IO::Handle‐>new(), - IO::Handle‐>new(), - ); - - my $handles = GnuPG::Handles‐>new( stdin => $input, - stdout => $output, - stderr => $error, - passphrase => $passphrase_fh, - status => $status_fh, - ); - - # this time we’ll also demonstrate decrypting - # a file written to disk - # Make sure you "use IO::File" if you use this module! - my $cipher_file = IO::File‐>new( ’encrypted.gpg’ ); - - # this sets up the communication - my $pid = $gnupg‐>decrypt( handles => $handles ); - - # This passes in the passphrase - print $passphrase_fd $passphrase; - close $passphrase_fd; - - # this passes in the plaintext - print $input $_ while <$cipher_file> - - # this closes the communication channel, - # indicating we are done - close $input; - close $cipher_file; - - my @plaintext = <$output>; # reading the output - my @error_output = <$error>; # reading the error - my @status_info = <$status_fh> # read the status info - - # clean up... - close $output; - close $error; - close $status_fh; - - waitpid $pid, 0; # clean up the finished GnuPG process - - PPrriinnttiinngg KKeeyyss - - # This time we’ll just let GnuPG print to our own output - # and read from our input, because no input is needed! - my $handles = GnuPG::Handles‐>new(); - - my @ids = [ ’ftobin’, ’0xABCD1234’ ]; - - # this time we need to specify something for - # command_args because ‐‐list‐public‐keys takes - # search ids as arguments - my $pid = $gnupg‐>list_public_keys( handles => $handles, - command_args => [ @ids ] ); - - waitpid $pid, 0; - - CCrreeaattiinngg GGnnuuPPGG::::PPuubblliiccKKeeyy OObbjjeeccttss - - my @ids = [ ’ftobin’, ’0xABCD1234’ ]; - - my @keys = $gnupg‐>get_public_keys( @ids ); - - # no wait is required this time; it’s handled internally - # since the entire call is encapsulated - - CCuussttoomm GGnnuuPPGG ccaallll - - # assuming $handles is a GnuPG::Handles object - my $pid = $gnupg‐>wrap_call - ( commands => [ qw( ‐‐list‐packets ) ], - command_args => [ qw( test/key.1.asc ) ], - handles => $handles, - ); - - my @out = <$handles‐>stdout()>; - waitpid $pid, 0; - -FFAAQQ - How do I get GnuPG::Interface to read/write directly from a filehandle? - You need to set GnuPG::Handles ddiirreecctt option to be true for the - filehandles in concern. See "options" in GnuPG::Handles and - "Object Methods which use a GnuPG::Handles Object" for more infor‐ - mation. - - Why do you make it so difficult to get GnuPG to write/read from a file‐ - handle? In the shell, I can just call GnuPG with the −−outfile option! - There are lots of issues when trying to tell GnuPG to read/write - directly from a file, such as if the file isn’t there, or there is - a file, and you want to write over it! What do you want to happen - then? Having the user of this module handle these questions - beforehand by opening up filehandles to GnuPG lets the user know - fully what is going to happen in these circumstances, and makes the - module less error−prone. - - When having GnuPG process a large message, sometimes it just hanges - there. - Your problem may be due to buffering issues; when GnuPG - reads/writes to nnoonn‐‐ddiirreecctt filehandles (those that are sent to - filehandles which you read to from into memory, not that those - access the disk), buffering issues can mess things up. I recommend - looking into "options" in GnuPG::Handles. - -NNOOTTEESS - This package is the successor to PGP::GPG::MessageProcessor, which I - found to be too inextensible to carry on further. A total redesign was - needed, and this is the resulting work. - - After any call to a GnuPG‐command method of GnuPG::Interface in which - one passes in the handles, one should all wwaaiitt to clean up GnuPG from - the process table. - -BBUUGGSS - Currently there are problems when transmitting large quantities of - information over handles; I’m guessing this is due to buffering issues. - This bug does not seem specific to this package; IPC::Open3 also - appears affected. - - I don’t know yet how well this modules handles parsing OpenPGP v3 keys. - -SSEEEE AALLSSOO - GnuPG::Options, GnuPG::Handles, GnuPG::PublicKey, GnuPG::SecretKey, - gpg, Class::MethodMaker, "Bidirectional Communication with Another - Process" in perlipc - -AAUUTTHHOORR - GnuPg::Interface is currently maintained by Jesse Vincent - <jesse@cpan.org>. - - Frank J. Tobin, ftobin@cpan.org was the original author of the package. - - - -perl v5.8.8 2007‐04‐24 GnuPG::Interface(3) @@ -1,5 +1,5 @@ This file contains message digests of all files listed in MANIFEST, -signed via the Module::Signature module, version 0.69. +signed via the Module::Signature module, version 0.73. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: @@ -14,24 +14,25 @@ not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -SHA1 c447ff09e2126edb92c84b58aeed26ef0d17f5dd Changes -SHA1 338c5d15bbbf3e4772b8c5cc8fbdda7a47553dd9 MANIFEST +SHA1 e890ff9e89a43f20c7bbe6501ca9eee9e0a34cc5 Changes +SHA1 53b4359060763a93e39261003c33f21ee78ca263 MANIFEST SHA1 01aaeb25c70093c04dd0b27f8619332393830652 MANIFEST.SKIP -SHA1 ae0d42bcf64f7a740a4e1099423731db56ef9a20 META.yml -SHA1 5bc6888b1495f726acc49d82aebd6ddf1ed5757a Makefile.PL -SHA1 1047dc54823b1321e939274dd261d8e40febee24 README -SHA1 8a924add836b60fb23b25c8506d45945e02f42f4 inc/Module/Install.pm -SHA1 2d0fad3bf255f8c1e7e1e34eafccc4f595603ddc inc/Module/Install/Base.pm -SHA1 f0e01fff7d73cd145fbf22331579918d4628ddb0 inc/Module/Install/Can.pm -SHA1 7328966e4fda0c8451a6d3850704da0b84ac1540 inc/Module/Install/Fetch.pm -SHA1 b62ca5e2d58fa66766ccf4d64574f9e1a2250b34 inc/Module/Install/Makefile.pm -SHA1 1aa925be410bb3bfcd84a16985921f66073cc1d2 inc/Module/Install/Metadata.pm -SHA1 e4196994fa75e98bdfa2be0bdeeffef66de88171 inc/Module/Install/Win32.pm -SHA1 c3a6d0d5b84feb3280622e9599e86247d58b0d18 inc/Module/Install/WriteAll.pm +SHA1 045613a39cbe7175a8aed8aea6442e7bfce202c1 META.yml +SHA1 86643cffc4d799993109646b1d7e2e9bac64cdf7 Makefile.PL +SHA1 429370a90369dce9cc5e1ba9f820406f0f0ca8d4 README +SHA1 d2664c57b65686abbfbbe1e71229761625be4922 inc/Module/Install.pm +SHA1 da41a8d9904f7b409b49a5f6c338d3eb305a2b4b inc/Module/Install/Base.pm +SHA1 0db0afe19cd298abba248fa089e5525bd5ab3ab6 inc/Module/Install/Can.pm +SHA1 e7152bfd5ca67d0e33f96d09c59d600bca5c1f15 inc/Module/Install/Fetch.pm +SHA1 29ee1cb0dc262b00983e3a2f5cf00b538dff5069 inc/Module/Install/Makefile.pm +SHA1 e963f80cfe255f16e55067d1feb6841cff3ed2fe inc/Module/Install/Metadata.pm +SHA1 79f5b4199f622e8b05aac266b0c39f6a85bb303f inc/Module/Install/ReadmeFromPod.pm +SHA1 65a1f09af1f4f9e47a98b6b45667c328b1b2f9c0 inc/Module/Install/Win32.pm +SHA1 f191c49475b3f51775180cd4f7e41e3bdab7f85a inc/Module/Install/WriteAll.pm SHA1 d1cf614274e3b01254379758123b75034e1d2e80 lib/GnuPG/Fingerprint.pm SHA1 9508207dbd2a4b36a38e08b72f39fc4d26c49615 lib/GnuPG/Handles.pm SHA1 b2fe771ca9a1d719b222013e08b93ab57f7452e8 lib/GnuPG/HashInit.pm -SHA1 d2e7cd1165714f052d85c9be03c9526e3c012119 lib/GnuPG/Interface.pm +SHA1 1258ef1ec5e9586d48809ba53139c58373289d66 lib/GnuPG/Interface.pm SHA1 41cc5278e62c3298248cefbd27179d0322e65011 lib/GnuPG/Key.pm SHA1 c5a7cc8c23f009fee6f615c2e5966c4d0336ab5c lib/GnuPG/Options.pm SHA1 c6a1f74f35c4f2ea0dfc163202fa1c650acf6d2d lib/GnuPG/PrimaryKey.pm @@ -44,26 +45,26 @@ SHA1 acfec9fd5e879711280d5ac8ebfd667fde8d4f1e lib/GnuPG/UserAttribute.pm SHA1 d70a9e4c89b2fe445c733dc9c177d62cc9f44826 lib/GnuPG/UserId.pm SHA1 367fdb308292a9c005afffef49ff9096a20a4da3 t/Fingerprint.t SHA1 8791d014e4efd4cf11998386e1651cc4eb16dd26 t/Interface.t -SHA1 698ec633be083b7e762331f1a5106c1618c74dd3 t/MyTest.pm -SHA1 a3aef62cb9ec31d2d398548114685ba8c5cdeb93 t/MyTestSpecific.pm +SHA1 980fcd5a1d302e65cc2414be96d5f3a4266e8308 t/MyTest.pm +SHA1 e12da2a4da6d98e80d91278790eca9dc82e610ee t/MyTestSpecific.pm SHA1 ccd942d9f00627253d7eb9c011116dc5671639b8 t/UserId.t -SHA1 16ac3a802f059cad9b7a0567eebe8b9599cc2551 t/clearsign.t -SHA1 fab3deb7f60a0b5aae2f92b1c39804d1a4df2848 t/decrypt.t -SHA1 67364d69fda2826735c8e39d50ea81a80d529a6c t/detach_sign.t -SHA1 54d40d0d5233ad3097c5ca79032f38171334c7a4 t/encrypt.t -SHA1 eeb2c355817cf641ad9e90e90f01007efce29cbe t/encrypt_symmetrically.t -SHA1 a95b669219675ac2fadc8b5d3c49dcfd69609fe2 t/export_keys.t -SHA1 889e4ea15ae0ddd169f03ee03307ece5f0debbe7 t/get_public_keys.t -SHA1 fdca3db7bb332108d5a9011cb0f2c61f123c04fa t/get_secret_keys.t -SHA1 a0f7dfa3778defadaf3600a7cfd69bfd027fdad2 t/import_keys.t -SHA1 3355815cd188313a39116a661669ff92cebd701f t/list_public_keys.t -SHA1 2ccb69c8a216e7f6db9faa2d6127561aeaa8130c t/list_secret_keys.t -SHA1 17bccf75d6920c3d75dc3c8dbcdc0d0855275350 t/list_sigs.t -SHA1 a8d213b81f23469460d8466520590bbeaee14aed t/passphrase_handling.t -SHA1 1a20b9dac32bb1b40294e966de09eb89589a8891 t/sign.t -SHA1 fa87a1405c58a951518003efd95700a9ca4b60ed t/sign_and_encrypt.t -SHA1 6732202eb77e2d90af01f557d3e534812ec672af t/verify.t -SHA1 09f7e2320231cfb923325fd474d76ff20d8c6c6b t/wrap_call.t +SHA1 e2e53ab9458c61d32b973a16d32573a954e13769 t/clearsign.t +SHA1 6808b2b88bb2f1aa9398d7bb32993ae679cf869c t/decrypt.t +SHA1 b828dfb74321c117264b4418cf57d2da3d96f7c4 t/detach_sign.t +SHA1 194562685ecfe0ba09b8238bbd6b86f0bd6f9d7d t/encrypt.t +SHA1 2d8d00e2bd767c658c2a795ec970398af3c87ebe t/encrypt_symmetrically.t +SHA1 8d3cf3e7433e59c393193ae7df4ef16b094e3f96 t/export_keys.t +SHA1 02f4685776d8556fafc88644ff51677ce6b4b4c6 t/get_public_keys.t +SHA1 a0c8a3a1b653593b96ad511d2b348acf84411501 t/get_secret_keys.t +SHA1 5a4cbcdac983766a60f5f25db20bf81f251c9b3a t/import_keys.t +SHA1 7d4b60343a07ab530adbfc02acc3212463a46190 t/list_public_keys.t +SHA1 489784ddcc8c1baf5857bb535394935f0472c7f5 t/list_secret_keys.t +SHA1 10b57083d7767a6d13285e18449bb37333cd9676 t/list_sigs.t +SHA1 07a602cbb5a78518cd4cccfb7007e80564a19e1e t/passphrase_handling.t +SHA1 99c53aa0a919cbf16cba74be84c6cff3af0cd097 t/sign.t +SHA1 8b6aec0a94d6ac5a0d40dffc52cc2a21a9c934e8 t/sign_and_encrypt.t +SHA1 cabbf4e667027f9bb7958673bc9b8be2d1577e29 t/verify.t +SHA1 8fd17bc4ad8ac4c4357503edfe2d1a952a44c28b t/wrap_call.t SHA1 58f58338a2922798c59c5e852bd0110541f27e2d test/encrypted.1.gpg SHA1 b012a47f295ee9dcc955560b9a78c0ad3a61e137 test/key.1.asc SHA1 1290379acadab2cc713d659c7c3feff2b0923f75 test/options @@ -83,9 +84,9 @@ SHA1 3bd6135279f9ae23e32680707c6170910421e5de test/secret-keys/2.0.test SHA1 9ce5508cd8cefadc4c9bf2842864b52e87b1826e test/secring.gpg SHA1 981418a80bf7dab91b63608cfd1ddf5091f89ad7 test/signed.1.asc -----BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.11 (GNU/Linux) +Version: GnuPG v2.0.22 (GNU/Linux) -iEYEARECAAYFAlMjMvoACgkQMflWJZZAbqC1AQCgrdiQgvrUsnHu3XbvDvDzu2SI -jD8AoLvxI7D7LusGz2ZQX4SQZ+sq+WZr -=+p6L +iEYEARECAAYFAlTioEQACgkQMflWJZZAbqAlGwCcDi0uU+q3nG9DQqg/1nQLdUxa +BVsAn1DqJdBvYqKtHr/XWn6T0Km0dLBp +=6yHK -----END PGP SIGNATURE----- diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm index 4ecf46b..ff767fa 100644 --- a/inc/Module/Install.pm +++ b/inc/Module/Install.pm @@ -17,7 +17,7 @@ package Module::Install; # 3. The ./inc/ version of Module::Install loads # } -use 5.005; +use 5.006; use strict 'vars'; use Cwd (); use File::Find (); @@ -31,7 +31,7 @@ BEGIN { # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. - $VERSION = '1.06'; + $VERSION = '1.14'; # Storage for the pseudo-singleton $MAIN = undef; @@ -156,10 +156,10 @@ END_DIE sub autoload { my $self = shift; my $who = $self->_caller; - my $cwd = Cwd::cwd(); + my $cwd = Cwd::getcwd(); my $sym = "${who}::AUTOLOAD"; $sym->{$cwd} = sub { - my $pwd = Cwd::cwd(); + my $pwd = Cwd::getcwd(); if ( my $code = $sym->{$pwd} ) { # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; @@ -239,7 +239,7 @@ sub new { # ignore the prefix on extension modules built from top level. my $base_path = Cwd::abs_path($FindBin::Bin); - unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) { + unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) { delete $args{prefix}; } return $args{_self} if $args{_self}; @@ -338,7 +338,7 @@ sub find_extensions { if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) { my $content = Module::Install::_read($subpath . '.pm'); my $in_pod = 0; - foreach ( split //, $content ) { + foreach ( split /\n/, $content ) { $in_pod = 1 if /^=\w/; $in_pod = 0 if /^=cut/; next if ($in_pod || /^=cut/); # skip pod text @@ -378,6 +378,7 @@ eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _read { local *FH; open( FH, '<', $_[0] ) or die "open($_[0]): $!"; + binmode FH; my $string = do { local $/; <FH> }; close FH or die "close($_[0]): $!"; return $string; @@ -386,6 +387,7 @@ END_NEW sub _read { local *FH; open( FH, "< $_[0]" ) or die "open($_[0]): $!"; + binmode FH; my $string = do { local $/; <FH> }; close FH or die "close($_[0]): $!"; return $string; @@ -416,6 +418,7 @@ eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@; sub _write { local *FH; open( FH, '>', $_[0] ) or die "open($_[0]): $!"; + binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } @@ -425,6 +428,7 @@ END_NEW sub _write { local *FH; open( FH, "> $_[0]" ) or die "open($_[0]): $!"; + binmode FH; foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!"; } @@ -434,7 +438,7 @@ END_OLD # _version is for processing module versions (eg, 1.03_05) not # Perl versions (eg, 5.8.1). -sub _version ($) { +sub _version { my $s = shift || 0; my $d =()= $s =~ /(\.)/g; if ( $d >= 2 ) { @@ -450,12 +454,12 @@ sub _version ($) { return $l + 0; } -sub _cmp ($$) { +sub _cmp { _version($_[1]) <=> _version($_[2]); } # Cloned from Params::Util::_CLASS -sub _CLASS ($) { +sub _CLASS { ( defined $_[0] and diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm index 802844a..4206347 100644 --- a/inc/Module/Install/Base.pm +++ b/inc/Module/Install/Base.pm @@ -4,7 +4,7 @@ package Module::Install::Base; use strict 'vars'; use vars qw{$VERSION}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; } # Suspend handler for "redefined" warnings diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm index 22167b8..9929b1b 100644 --- a/inc/Module/Install/Can.pm +++ b/inc/Module/Install/Can.pm @@ -8,7 +8,7 @@ use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm index bee0c4f..3d8de76 100644 --- a/inc/Module/Install/Fetch.pm +++ b/inc/Module/Install/Fetch.pm @@ -6,7 +6,7 @@ use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm index 7052f36..66993af 100644 --- a/inc/Module/Install/Makefile.pm +++ b/inc/Module/Install/Makefile.pm @@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/; use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } @@ -133,7 +133,7 @@ sub makemaker_args { return $args; } -# For mm args that take multiple space-seperated args, +# For mm args that take multiple space-separated args, # append an argument to the current list. sub makemaker_append { my $self = shift; diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm index 58430f3..e547fa0 100644 --- a/inc/Module/Install/Metadata.pm +++ b/inc/Module/Install/Metadata.pm @@ -6,7 +6,7 @@ use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } @@ -347,7 +347,7 @@ sub name_from { ^ \s* package \s* ([\w:]+) - \s* ; + [\s|;]* /ixms ) { my ($name, $module_name) = ($1, $1); @@ -705,7 +705,7 @@ sub _write_mymeta_data { my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); my $meta = $yaml[0]; - # Overwrite the non-configure dependency hashs + # Overwrite the non-configure dependency hashes delete $meta->{requires}; delete $meta->{build_requires}; delete $meta->{recommends}; diff --git a/inc/Module/Install/ReadmeFromPod.pm b/inc/Module/Install/ReadmeFromPod.pm new file mode 100644 index 0000000..b5e03c3 --- /dev/null +++ b/inc/Module/Install/ReadmeFromPod.pm @@ -0,0 +1,138 @@ +#line 1 +package Module::Install::ReadmeFromPod; + +use 5.006; +use strict; +use warnings; +use base qw(Module::Install::Base); +use vars qw($VERSION); + +$VERSION = '0.22'; + +sub readme_from { + my $self = shift; + return unless $self->is_admin; + + # Input file + my $in_file = shift || $self->_all_from + or die "Can't determine file to make readme_from"; + + # Get optional arguments + my ($clean, $format, $out_file, $options); + my $args = shift; + if ( ref $args ) { + # Arguments are in a hashref + if ( ref($args) ne 'HASH' ) { + die "Expected a hashref but got a ".ref($args)."\n"; + } else { + $clean = $args->{'clean'}; + $format = $args->{'format'}; + $out_file = $args->{'output_file'}; + $options = $args->{'options'}; + } + } else { + # Arguments are in a list + $clean = $args; + $format = shift; + $out_file = shift; + $options = \@_; + } + + # Default values; + $clean ||= 0; + $format ||= 'txt'; + + # Generate README + print "readme_from $in_file to $format\n"; + if ($format =~ m/te?xt/) { + $out_file = $self->_readme_txt($in_file, $out_file, $options); + } elsif ($format =~ m/html?/) { + $out_file = $self->_readme_htm($in_file, $out_file, $options); + } elsif ($format eq 'man') { + $out_file = $self->_readme_man($in_file, $out_file, $options); + } elsif ($format eq 'pdf') { + $out_file = $self->_readme_pdf($in_file, $out_file, $options); + } + + if ($clean) { + $self->clean_files($out_file); + } + + return 1; +} + + +sub _readme_txt { + my ($self, $in_file, $out_file, $options) = @_; + $out_file ||= 'README'; + require Pod::Text; + my $parser = Pod::Text->new( @$options ); + open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; + $parser->output_fh( *$out_fh ); + $parser->parse_file( $in_file ); + close $out_fh; + return $out_file; +} + + +sub _readme_htm { + my ($self, $in_file, $out_file, $options) = @_; + $out_file ||= 'README.htm'; + require Pod::Html; + Pod::Html::pod2html( + "--infile=$in_file", + "--outfile=$out_file", + @$options, + ); + # Remove temporary files if needed + for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') { + if (-e $file) { + unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n"; + } + } + return $out_file; +} + + +sub _readme_man { + my ($self, $in_file, $out_file, $options) = @_; + $out_file ||= 'README.1'; + require Pod::Man; + my $parser = Pod::Man->new( @$options ); + $parser->parse_from_file($in_file, $out_file); + return $out_file; +} + + +sub _readme_pdf { + my ($self, $in_file, $out_file, $options) = @_; + $out_file ||= 'README.pdf'; + eval { require App::pod2pdf; } + or die "Could not generate $out_file because pod2pdf could not be found\n"; + my $parser = App::pod2pdf->new( @$options ); + $parser->parse_from_file($in_file); + open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; + select $out_fh; + $parser->output; + select STDOUT; + close $out_fh; + return $out_file; +} + + +sub _all_from { + my $self = shift; + return unless $self->admin->{extensions}; + my ($metadata) = grep { + ref($_) eq 'Module::Install::Metadata'; + } @{$self->admin->{extensions}}; + return unless $metadata; + return $metadata->{values}{all_from} || ''; +} + +'Readme!'; + +__END__ + +#line 254 + diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm index eeaa3fe..9706e5f 100644 --- a/inc/Module/Install/Win32.pm +++ b/inc/Module/Install/Win32.pm @@ -6,7 +6,7 @@ use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = 'Module::Install::Base'; $ISCORE = 1; } diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm index 85d8018..dbedc00 100644 --- a/inc/Module/Install/WriteAll.pm +++ b/inc/Module/Install/WriteAll.pm @@ -6,7 +6,7 @@ use Module::Install::Base (); use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '1.06'; + $VERSION = '1.14'; @ISA = qw{Module::Install::Base}; $ISCORE = 1; } diff --git a/lib/GnuPG/Interface.pm b/lib/GnuPG/Interface.pm index 6a382d3..f952f3e 100644 --- a/lib/GnuPG/Interface.pm +++ b/lib/GnuPG/Interface.pm @@ -28,7 +28,7 @@ use Math::BigInt try => 'GMP'; use GnuPG::Options; use GnuPG::Handles; -$VERSION = '0.50'; +$VERSION = '0.52'; has $_ => ( isa => 'Any', @@ -595,7 +595,7 @@ sub get_keys { my ($pos, $size, $data) = @fields[ 1,2,3 ]; $current_key->pubkey_data->[$pos+0] = Math::BigInt->from_hex('0x'.$data); } - elsif ( $record_type ne 'tru' ) { + elsif ( $record_type ne 'tru' and $record_type ne 'grp' ) { warn "unknown record type $record_type"; } } @@ -659,10 +659,16 @@ sub encrypt( $% ) { sub encrypt_symmetrically( $% ) { my ( $self, %args ) = @_; - return $self->wrap_call( + # Strip the homedir and put it back after encrypting; gpg 2.0.x + # fails symmetric encryption when one is passed. + my $homedir = $self->options->homedir; + $self->options->clear_homedir; + my $pid = $self->wrap_call( %args, commands => ['--symmetric'] ); + $self->options->homedir($homedir); + return $pid; } sub sign( $% ) { diff --git a/t/MyTest.pm b/t/MyTest.pm index 4c6efa6..235d729 100644 --- a/t/MyTest.pm +++ b/t/MyTest.pm @@ -33,9 +33,9 @@ my $counter = 0; sub TEST ( & ) { my ( $code ) = @_; - + $counter++; - + &$code or print "not "; print "ok $counter\n"; } @@ -45,17 +45,17 @@ sub COUNT_TESTS { my ( $file ) = @_; $file ||= $PROGRAM_NAME; - + my $tests = 0; - + my $in = IO::File->new( $file ); - + while ( $_ = $in->getline() ) { - $tests++ - if /^\s*TEST\s*/; + $tests++ + if /^\s*TEST\s*/; } - + return $tests; } diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm index 7894ccc..053b749 100644 --- a/t/MyTestSpecific.pm +++ b/t/MyTestSpecific.pm @@ -27,25 +27,25 @@ use GnuPG::Interface; use GnuPG::Handles; use vars qw( @ISA @EXPORT - $stdin $stdout $stderr - $gpg_program $handles $gnupg - %texts - ); + $stdin $stdout $stderr + $gpg_program $handles $gnupg + %texts + ); @ISA = qw( Exporter ); @EXPORT = qw( stdin stdout stderr - gnupg_program handles reset_handles - texts file_match - ); + gnupg_program handles reset_handles + texts file_match + ); $gnupg = GnuPG::Interface->new( passphrase => 'test' ); $gnupg->options->hash_init( homedir => 'test', - armor => 1, - meta_interactive => 0, - meta_signing_key_id => '0xF950DA9C', - always_trust => 1, - ); + armor => 1, + meta_interactive => 0, + meta_signing_key_id => '0xF950DA9C', + always_trust => 1, + ); struct( Text => { fn => "\$", fh => "\$", data => "\$" } ); @@ -78,30 +78,30 @@ sub reset_handles { foreach ( $stdin, $stdout, $stderr ) { - $_ = IO::Handle->new(); + $_ = IO::Handle->new(); } - + $handles = GnuPG::Handles->new ( stdin => $stdin, - stdout => $stdout, - stderr => $stderr + stdout => $stdout, + stderr => $stderr ); - + foreach my $name ( qw( plain encrypted signed key ) ) { - my $entry = $texts{$name}; - my $filename = $entry->fn(); - my $fh = IO::File->new( $filename ) - or die "cannot open $filename: $ERRNO"; - $entry->fh( $fh ); + my $entry = $texts{$name}; + my $filename = $entry->fn(); + my $fh = IO::File->new( $filename ) + or die "cannot open $filename: $ERRNO"; + $entry->fh( $fh ); } - + { - my $entry = $texts{temp}; - my $filename = $entry->fn(); - my $fh = IO::File->new( $filename, 'w' ) - or die "cannot open $filename: $ERRNO"; - $entry->fh( $fh ); + my $entry = $texts{temp}; + my $filename = $entry->fn(); + my $fh = IO::File->new( $filename, 'w' ) + or die "cannot open $filename: $ERRNO"; + $entry->fh( $fh ); } } @@ -110,15 +110,15 @@ sub reset_handles sub file_match { my ( $orig, @compares ) = @_; - + my $found_match = 0; - + foreach my $file ( @compares ) { - return 1 - if compare( $file, $orig ) == 0; + return 1 + if compare( $file, $orig ) == 0; } - + return 0; } diff --git a/t/clearsign.t b/t/clearsign.t index cc47b4f..8f27ebc 100644 --- a/t/clearsign.t +++ b/t/clearsign.t @@ -13,13 +13,13 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->clearsign( handles => $handles ); - + print $stdin @{ $texts{plain}->data }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -27,12 +27,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->clearsign( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/decrypt.t b/t/decrypt.t index 9a10e8a..b2639ed 100644 --- a/t/decrypt.t +++ b/t/decrypt.t @@ -16,22 +16,22 @@ my $compare; TEST { reset_handles(); - + my $pid = $gnupg->decrypt( handles => $handles ); - + print $stdin @{ $texts{encrypted}->data() }; close $stdin; - + $compare = compare( $texts{plain}->fn(), $stdout ); close $stdout; waitpid $pid, 0; - + return $CHILD_ERROR == 0;; }; TEST -{ +{ return $compare == 0; }; @@ -39,17 +39,17 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{encrypted}->fh() ); $handles->options( 'stdin' )->{direct} = 1; - + $handles->stdout( $texts{temp}->fh() ); $handles->options( 'stdout' )->{direct} = 1; - + my $pid = $gnupg->decrypt( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/detach_sign.t b/t/detach_sign.t index 5011394..f3bde63 100644 --- a/t/detach_sign.t +++ b/t/detach_sign.t @@ -13,13 +13,13 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->detach_sign( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -27,12 +27,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->detach_sign( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/encrypt.t b/t/encrypt.t index 0c26e7c..3183ac4 100644 --- a/t/encrypt.t +++ b/t/encrypt.t @@ -13,17 +13,28 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->wrap_call( + handles => $handles, + commands => ['--update-trustdb'], + ); + waitpid $pid, 0; + return $CHILD_ERROR == 0; +}; + +TEST +{ + reset_handles(); + $gnupg->options->clear_recipients(); $gnupg->options->clear_meta_recipients_keys(); $gnupg->options->push_recipients( '0x2E854A6B' ); - + my $pid = $gnupg->encrypt( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -31,18 +42,18 @@ TEST TEST { reset_handles(); - + my @keys = $gnupg->get_public_keys( '0xF950DA9C' ); $gnupg->options->clear_recipients(); $gnupg->options->clear_meta_recipients_keys(); $gnupg->options->push_meta_recipients_keys( @keys ); - + my $pid = $gnupg->encrypt( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -50,16 +61,16 @@ TEST TEST { reset_handles(); - + $gnupg->options->clear_recipients(); $gnupg->options->clear_meta_recipients_keys(); $gnupg->options->push_recipients( '0x2E854A6B' ); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->encrypt( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/encrypt_symmetrically.t b/t/encrypt_symmetrically.t index eeaea57..61535ac 100644 --- a/t/encrypt_symmetrically.t +++ b/t/encrypt_symmetrically.t @@ -13,13 +13,13 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->encrypt_symmetrically( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -28,12 +28,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->encrypt_symmetrically( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/export_keys.t b/t/export_keys.t index faab50b..cf5c82b 100644 --- a/t/export_keys.t +++ b/t/export_keys.t @@ -13,12 +13,12 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->export_keys( handles => $handles, - command_args => '0xF950DA9C' ); + command_args => '0xF950DA9C' ); close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -26,12 +26,12 @@ TEST TEST { reset_handles(); - + $handles->stdout( $texts{temp}->fh() ); $handles->options( 'stdout' )->{direct} = 1; - + my $pid = $gnupg->export_keys( handles => $handles, - command_args => '0xF950DA9C' ); + command_args => '0xF950DA9C' ); waitpid $pid, 0; return $CHILD_ERROR == 0; }; diff --git a/t/get_public_keys.t b/t/get_public_keys.t index 38661b7..53db021 100644 --- a/t/get_public_keys.t +++ b/t/get_public_keys.t @@ -18,11 +18,11 @@ my ( $given_key, $handmade_key ); TEST { reset_handles(); - + my @returned_keys = $gnupg->get_public_keys_with_sigs( '0xF950DA9C' ); - + return 0 unless @returned_keys == 1; - + $given_key = shift @returned_keys; my $pubkey_data = [ @@ -35,24 +35,24 @@ TEST Math::BigInt->from_hex('0x'. '80DE04C85E30C9D62C13F90CFF927A84A5A59D0900B3533D4D6193FEF8C5DAEF9FF8A7D5F76B244FBC17644F50D524E0B19CD3A4B5FC2D78DAECA3FE58FA1C1A64E6C7B96C4EE618173543163A72EF954DFD593E84342699096E9CA76578AC1DE3D893BCCD0BF470CEF625FAF816A0F503EF75C18C6173E35C8675AF919E5704') ]; - + $handmade_key = GnuPG::PrimaryKey->new ( length => 1024, - algo_num => 17, - hex_id => '53AE596EF950DA9C', + algo_num => 17, + hex_id => '53AE596EF950DA9C', creation_date => 949813093, - creation_date_string => '2000-02-06', - owner_trust => '-', + creation_date_string => '2000-02-06', + owner_trust => '-', usage_flags => 'scaESCA', pubkey_data => $pubkey_data, ); - + $handmade_key->fingerprint ( GnuPG::Fingerprint->new( as_hex_string => - '93AFC4B1B0288A104996B44253AE596EF950DA9C', - ) + '93AFC4B1B0288A104996B44253AE596EF950DA9C', + ) ); - + my $uid0 = GnuPG::UserId->new( as_string => 'GnuPG test key (for testing purposes only)', validity => '-'); @@ -123,14 +123,14 @@ TEST my $subkey_signature = GnuPG::Signature->new ( validity => '!', algo_num => 17, - hex_id => '53AE596EF950DA9C', + hex_id => '53AE596EF950DA9C', date => 1177086380, - date_string => '2007-04-20', + date_string => '2007-04-20', user_id_string => 'GnuPG test key (for testing purposes only)', sig_class => 0x18, is_exportable => 1, ); - + my $uid2_signature = GnuPG::Signature->new ( validity => '!', algo_num => 17, @@ -138,33 +138,33 @@ TEST date => 953179891, date_string => '2000-03-16', ); - + my $ftobin_signature = GnuPG::Signature->new ( validity => '!', algo_num => 17, - hex_id => '56FFD10A260C4FA3', + hex_id => '56FFD10A260C4FA3', date => 953180097, - date_string => '2000-03-16', - ); - + date_string => '2000-03-16', + ); + my $designated_revoker_sig = GnuPG::Signature->new ( validity => '!', algo_num => 17, - hex_id => '53AE596EF950DA9C', + hex_id => '53AE596EF950DA9C', date => 978325209, - date_string => '2001-01-01', + date_string => '2001-01-01', sig_class => 0x1f, is_exportable => 1 - ); + ); my $revoker = GnuPG::Revoker->new ( algo_num => 17, class => 0x80, - fingerprint => GnuPG::Fingerprint->new( as_hex_string => + fingerprint => GnuPG::Fingerprint->new( as_hex_string => '4F863BBBA8166F0A340F600356FFD10A260C4FA3'), - ); + ); $revoker->push_signatures($designated_revoker_sig); - + my $subkey_pub_data = [ Math::BigInt->from_hex('0x'. '8831982DADC4C5D05CBB01D9EAF612131DDC9C24CEA7246557679423FB0BA42F74D10D8E7F5564F6A4FB8837F8DC4A46571C19B122E6DF4B443D15197A6A22688863D0685FADB6E402316DAA9B560D1F915475364580A67E6DF0A727778A5CF3'), @@ -176,27 +176,27 @@ TEST my $subkey = GnuPG::SubKey->new ( validity => 'u', - length => 768, - algo_num => 16, - hex_id => 'ADB99D9C2E854A6B', + length => 768, + algo_num => 16, + hex_id => 'ADB99D9C2E854A6B', creation_date => 949813119, - creation_date_string => '2000-02-06', + creation_date_string => '2000-02-06', usage_flags => 'e', pubkey_data => $subkey_pub_data, ); - + $subkey->fingerprint ( GnuPG::Fingerprint->new( as_hex_string => - '7466B7E98C4CCB64C2CE738BADB99D9C2E854A6B' - ) + '7466B7E98C4CCB64C2CE738BADB99D9C2E854A6B' + ) ); - + $subkey->push_signatures( $subkey_signature ); - + $handmade_key->push_subkeys( $subkey ); $handmade_key->push_revokers( $revoker ); - + $handmade_key->compare( $given_key ); }; @@ -204,19 +204,19 @@ TEST { my $subkey1 = $given_key->subkeys()->[0]; my $subkey2 = $handmade_key->subkeys()->[0]; - + bless $subkey1, 'GnuPG::SubKey'; my $equal = $subkey1->compare( $subkey2 ); - + warn 'subkeys fail comparison; this is a known issue with GnuPG 1.0.1' if not $equal; - + return $equal; }; TEST -{ +{ $handmade_key->compare( $given_key, 1 ); }; diff --git a/t/get_secret_keys.t b/t/get_secret_keys.t index acfeaa2..3a1d99f 100644 --- a/t/get_secret_keys.t +++ b/t/get_secret_keys.t @@ -17,27 +17,27 @@ my ( $given_key, $handmade_key ); TEST { reset_handles(); - + my @returned_keys = $gnupg->get_secret_keys( '0xF950DA9C' ); - + return 0 unless @returned_keys == 1; - + $given_key = shift @returned_keys; - + $handmade_key = GnuPG::PrimaryKey->new ( length => 1024, - algo_num => 17, - hex_id => '53AE596EF950DA9C', + algo_num => 17, + hex_id => '53AE596EF950DA9C', creation_date => 949813093, - creation_date_string => '2000-02-06', - owner_trust => '', # secret keys do not report ownertrust? + creation_date_string => '2000-02-06', + owner_trust => '', # secret keys do not report ownertrust? usage_flags => 'scaESCA', ); - + $handmade_key->fingerprint - ( GnuPG::Fingerprint->new( as_hex_string => - '93AFC4B1B0288A104996B44253AE596EF950DA9C', - ) + ( GnuPG::Fingerprint->new( as_hex_string => + '93AFC4B1B0288A104996B44253AE596EF950DA9C', + ) ); $handmade_key->push_user_ids( @@ -49,22 +49,22 @@ TEST my $subkey = GnuPG::SubKey->new ( validity => 'u', - length => 768, - algo_num => 16, - hex_id => 'ADB99D9C2E854A6B', + length => 768, + algo_num => 16, + hex_id => 'ADB99D9C2E854A6B', creation_date => 949813119, - creation_date_string => '2000-02-06', + creation_date_string => '2000-02-06', usage_flags => 'e', ); - + $subkey->fingerprint ( GnuPG::Fingerprint->new( as_hex_string => - '7466B7E98C4CCB64C2CE738BADB99D9C2E854A6B', - ) + '7466B7E98C4CCB64C2CE738BADB99D9C2E854A6B', + ) ); - + $handmade_key->push_subkeys( $subkey ); - + $handmade_key->compare( $given_key ); }; diff --git a/t/import_keys.t b/t/import_keys.t index 17ae665..dc4a5a2 100644 --- a/t/import_keys.t +++ b/t/import_keys.t @@ -13,14 +13,14 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->import_keys( handles => $handles ); - + print $stdin @{ $texts{key}->data() }; close $stdin; my @output = <$stdout>; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -28,12 +28,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{key}->fh() ); $handles->options( 'stdin' )->{direct} = 1; - + my $pid = $gnupg->import_keys( handles => $handles ); waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/list_public_keys.t b/t/list_public_keys.t index 8232df9..7e563c1 100644 --- a/t/list_public_keys.t +++ b/t/list_public_keys.t @@ -16,19 +16,19 @@ my $outfile; TEST { reset_handles(); - + my $pid = $gnupg->list_public_keys( handles => $handles ); close $stdin; - + $outfile = 'test/public-keys/1.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; $out->print( <$stdout> ); close $stdout; $out->close(); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -36,21 +36,21 @@ TEST TEST { reset_handles(); - + my $pid = $gnupg->list_public_keys( handles => $handles, - ommand_args => '0xF950DA9C' - ); + ommand_args => '0xF950DA9C' + ); close $stdin; - + $outfile = 'test/public-keys/2.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; $out->print( <$stdout> ); close $stdout; $out->close(); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -59,18 +59,18 @@ TEST TEST { reset_handles(); - + $handles->stdout( $texts{temp}->fh() ); $handles->options( 'stdout' )->{direct} = 1; - + my $pid = $gnupg->list_public_keys( handles => $handles, - command_args => '0xF950DA9C', - ); - + command_args => '0xF950DA9C', + ); + waitpid $pid, 0; - + $outfile = $texts{temp}->fn(); - + return $CHILD_ERROR == 0; }; diff --git a/t/list_secret_keys.t b/t/list_secret_keys.t index bcb722d..1fe9b7e 100644 --- a/t/list_secret_keys.t +++ b/t/list_secret_keys.t @@ -15,10 +15,10 @@ my $outfile; TEST { reset_handles(); - + my $pid = $gnupg->list_secret_keys( handles => $handles ); close $stdin; - + $outfile = 'test/secret-keys/1.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; @@ -26,7 +26,7 @@ TEST close $stdout; $out->close(); waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -42,38 +42,38 @@ TEST TEST { reset_handles(); - + my $pid = $gnupg->list_secret_keys( handles => $handles, - command_args => '0xF950DA9C' ); + command_args => '0xF950DA9C' ); close $stdin; - + $outfile = 'test/secret-keys/2.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; $out->print( <$stdout> ); close $stdout; $out->close(); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; - + }; TEST { reset_handles(); - + $handles->stdout( $texts{temp}->fh() ); $handles->options( 'stdout' )->{direct} = 1; - + my $pid = $gnupg->list_secret_keys( handles => $handles, - command_args => '0xF950DA9C' ); - + command_args => '0xF950DA9C' ); + waitpid $pid, 0; - + $outfile = $texts{temp}->fn(); - + return $CHILD_ERROR == 0; }; diff --git a/t/list_sigs.t b/t/list_sigs.t index 9f4bb4e..16cfa6a 100644 --- a/t/list_sigs.t +++ b/t/list_sigs.t @@ -14,19 +14,19 @@ my $outfile; TEST { reset_handles(); - + my $pid = $gnupg->list_sigs( handles => $handles ); close $stdin; - + $outfile = 'test/public-keys-sigs/1.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; $out->print( <$stdout> ); close $stdout; $out->close(); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -34,12 +34,12 @@ TEST TEST { reset_handles(); - + my $pid = $gnupg->list_sigs( handles => $handles, - command_args => '0xF950DA9C', - ); + command_args => '0xF950DA9C', + ); close $stdin; - + $outfile = 'test/public-keys-sigs/2.out'; my $out = IO::File->new( "> $outfile" ) or die "cannot open $outfile for writing: $ERRNO"; @@ -47,7 +47,7 @@ TEST close $stdout; $out->close(); waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -55,17 +55,17 @@ TEST TEST { reset_handles(); - + $handles->stdout( $texts{temp}->fh() ); $handles->options( 'stdout' )->{direct} = 1; - + my $pid = $gnupg->list_sigs( handles => $handles, - command_args => '0xF950DA9C', - ); - + command_args => '0xF950DA9C', + ); + waitpid $pid, 0; - + $outfile = $texts{temp}->fn(); - + return $CHILD_ERROR == 0; }; diff --git a/t/passphrase_handling.t b/t/passphrase_handling.t index d96a709..bfd0695 100644 --- a/t/passphrase_handling.t +++ b/t/passphrase_handling.t @@ -20,22 +20,22 @@ TEST $gnupg->clear_passphrase(); - + TEST { reset_handles(); - + my $passphrase_handle = gensym; $handles->passphrase( $passphrase_handle ); - + my $pid = $gnupg->sign( handles => $handles ); - + print $passphrase_handle 'test'; print $stdin @{ $texts{plain}->data() }; - + close $passphrase_handle; close $stdin; - + waitpid $pid, 0; return $CHILD_ERROR == 0; }; @@ -47,16 +47,16 @@ TEST reset_handles(); $handles->clear_stderr(); $handles->stderr( '>&STDERR' ); - + my $pass_fn = 'test/passphrase'; my $passfile = IO::File->new( $pass_fn ) or die "cannot open $pass_fn: $ERRNO"; $handles->passphrase( $passfile ); $handles->options( 'passphrase' )->{direct} = 1; - + my $pid = $gnupg->sign( handles => $handles ); close $stdin; - + waitpid $pid, 0; return $CHILD_ERROR == 0; }; @@ -13,13 +13,13 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->sign( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -27,12 +27,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->sign( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/sign_and_encrypt.t b/t/sign_and_encrypt.t index f31a481..5dc1c08 100644 --- a/t/sign_and_encrypt.t +++ b/t/sign_and_encrypt.t @@ -13,14 +13,14 @@ use MyTestSpecific; TEST { reset_handles(); - + $gnupg->options->push_recipients( '0x2E854A6B' ); my $pid = $gnupg->sign_and_encrypt( handles => $handles ); - + print $stdin @{ $texts{plain}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -28,12 +28,12 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{plain}->fh() ); $handles->options( 'stdin' )->{direct} = 1; my $pid = $gnupg->sign_and_encrypt( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -13,13 +13,13 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->verify( handles => $handles ); - + print $stdin @{ $texts{signed}->data() }; close $stdin; waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; @@ -27,13 +27,13 @@ TEST TEST { reset_handles(); - + $handles->stdin( $texts{signed}->fh() ); $handles->options( 'stdin' )->{direct} = 1; - + my $pid = $gnupg->verify( handles => $handles ); - + waitpid $pid, 0; - + return $CHILD_ERROR == 0; }; diff --git a/t/wrap_call.t b/t/wrap_call.t index 22b074c..8677d54 100644 --- a/t/wrap_call.t +++ b/t/wrap_call.t @@ -12,21 +12,21 @@ use MyTestSpecific; TEST { reset_handles(); - + my $pid = $gnupg->wrap_call ( commands => [ qw( --list-packets ) ], - command_args => [ qw( test/key.1.asc ) ], - handles => $handles, + command_args => [ qw( test/key.1.asc ) ], + handles => $handles, ); - + close $stdin; - + my @out = <$stdout>; waitpid $pid, 0; - + return @out > 0; #just check if we have output. }; - + TEST { return $CHILD_ERROR == 0; @@ -37,20 +37,20 @@ TEST TEST { reset_handles(); - + my $pid = $gnupg->wrap_call ( gnupg_commands => [ qw( --list-packets ) ], - gnupg_command_args => [ qw( test/key.1.asc ) ], - handles => $handles, + gnupg_command_args => [ qw( test/key.1.asc ) ], + handles => $handles, ); - + close $stdin; - + my @out = <$stdout>; waitpid $pid, 0; - + return @out > 0; #just check if we have output. -}; +}; TEST |