From: Daniel Kahn Gillmor Date: Sat, 18 Dec 2010 23:26:14 +0000 (-0500) Subject: do not use indirect object creation (see p.158 of "Modern Perl") X-Git-Tag: msva-perl_debian/0.8-1~1^2~12 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d17b5b5d3e552b30a61bed4c08f7670e34b3279c;p=monkeysphere-validation-agent.git do not use indirect object creation (see p.158 of "Modern Perl") --- diff --git a/Crypt/Monkeysphere/MSVA.pm b/Crypt/Monkeysphere/MSVA.pm index 02949f4..72c99b7 100755 --- a/Crypt/Monkeysphere/MSVA.pm +++ b/Crypt/Monkeysphere/MSVA.pm @@ -43,7 +43,7 @@ $VERSION = '0.7'; - my $gnupg = GnuPG::Interface->new(); + my $gnupg = GnuPG::Interface::->new(); $gnupg->options->quiet(1); $gnupg->options->batch(1); @@ -62,12 +62,12 @@ my $default_keyserver = 'hkp://pool.sks-keyservers.net'; my $default_keyserver_policy = 'unlessvalid'; - my $logger = Crypt::Monkeysphere::MSVA::Logger->new($ENV{MSVA_LOG_LEVEL}); + my $logger = Crypt::Monkeysphere::MSVA::Logger::->new($ENV{MSVA_LOG_LEVEL}); sub logger { return $logger; } - my $rsa_decoder = Convert::ASN1->new; + my $rsa_decoder = Convert::ASN1::->new(); $rsa_decoder->prepare(q< SEQUENCE { @@ -254,7 +254,7 @@ sub get_client_info { my $socket = shift; - my $sock = IO::Socket->new_from_fd($socket, 'r'); + my $sock = IO::Socket::->new_from_fd($socket, 'r'); # check SO_PEERCRED -- if this was a TCP socket, Linux # might not be able to support SO_PEERCRED (even on the loopback), # though apparently some kernels (Solaris?) are able to. @@ -313,7 +313,7 @@ msvalog('verbose', "Port: %04x\nAddr: %s\n", $port, $iaddrstring); my $remmatch = lc(sprintf("%s:%04x", $iaddrstring, $port)); my $infofile = '/proc/net/'.$proto; - my $f = new IO::File; + my $f = IO::File::->new(); if ( $f->open('< '.$infofile)) { my @header = split(/ +/, <$f>); my ($localaddrix, $uidix, $inodeix); @@ -464,7 +464,7 @@ sub der2key { my $rawdata = shift; - my $cert = Crypt::X509->new(cert => $rawdata); + my $cert = Crypt::X509::->new(cert => $rawdata); my $key = {error => 'I do not know what happened here'}; @@ -544,14 +544,14 @@ sub fetch_uid_from_keyserver { my $uid = shift; - my $cmd = IO::Handle->new(); - my $out = IO::Handle->new(); - my $nul = IO::File->new("< /dev/null"); + my $cmd = IO::Handle::->new(); + my $out = IO::Handle::->new(); + my $nul = IO::File::->new("< /dev/null"); my $ks = get_keyserver(); msvalog('debug', "start ks query to %s for UserID: %s\n", $ks, $uid); my $pid = $gnupg->wrap_call - ( handles => GnuPG::Handles->new( command => $cmd, stdout => $out, stderr => $nul ), + ( handles => GnuPG::Handles::->new( command => $cmd, stdout => $out, stderr => $nul ), command_args => [ '='.$uid ], commands => [ '--keyserver', $ks, @@ -659,8 +659,8 @@ } # make sure that the returned integers are Math::BigInts: - $key->{exponent} = Math::BigInt->new($key->{exponent}) unless (ref($key->{exponent})); - $key->{modulus} = Math::BigInt->new($key->{modulus}) unless (ref($key->{modulus})); + $key->{exponent} = Math::BigInt::->new($key->{exponent}) unless (ref($key->{exponent})); + $key->{modulus} = Math::BigInt::->new($key->{modulus}) unless (ref($key->{modulus})); msvalog('debug', "pubkey info:\nmodulus: %s\nexponent: %s\n", $key->{modulus}->as_hex(), $key->{exponent}->as_hex(), @@ -835,7 +835,7 @@ $server->server_close(); } $self->port($port); - $self->{updatemonitor} = Crypt::Monkeysphere::MSVA::Monitor->new($logger); + $self->{updatemonitor} = Crypt::Monkeysphere::MSVA::Monitor::->new($logger); } sub spawn_master_subproc { diff --git a/Crypt/Monkeysphere/MSVA/MarginalUI.pm b/Crypt/Monkeysphere/MSVA/MarginalUI.pm index 6136341..de41f27 100755 --- a/Crypt/Monkeysphere/MSVA/MarginalUI.pm +++ b/Crypt/Monkeysphere/MSVA/MarginalUI.pm @@ -135,7 +135,7 @@ GnuPG calculated validity for the peer: %s", my $cmd = ''; # FIXME: not very portable my $procfh; - $procfh = new IO::File(sprintf('/proc/%d/cmdline', $clientpid)); + $procfh = IO::File::->new(sprintf('/proc/%d/cmdline', $clientpid)); if (defined $procfh) { $cmd = <$procfh>; $procfh->close; @@ -173,10 +173,10 @@ GnuPG calculated validity for the peer: %s", Gtk2->init(); # create a new dialog with some buttons - one stock, one not. my $dialog = Gtk2::Dialog->new(sprintf('Monkeysphere validation agent [%s]', $peer), - undef, - [], - 'gtk-no' => 'cancel', - 'gtk-yes' => 'ok'); + undef, + [], + 'gtk-no' => 'cancel', + 'gtk-yes' => 'ok'); diff --git a/Crypt/Monkeysphere/MSVA/Monitor.pm b/Crypt/Monkeysphere/MSVA/Monitor.pm index 693e61a..67f24e9 100644 --- a/Crypt/Monkeysphere/MSVA/Monitor.pm +++ b/Crypt/Monkeysphere/MSVA/Monitor.pm @@ -108,7 +108,7 @@ Would you like to restart the validation agent?"); require Linux::Inotify2; - $self->{inotify} = new Linux::Inotify2 + $self->{inotify} = Linux::Inotify2::->new() or die "unable to create new inotify object: $!"; my $flags = 0xc06; diff --git a/gpgkeys_hkpms b/gpgkeys_hkpms index 2868099..ad7a728 100755 --- a/gpgkeys_hkpms +++ b/gpgkeys_hkpms @@ -140,7 +140,7 @@ use warnings; ca_file => undef, ); - my $ua = LWP::UserAgent->new(); + my $ua = LWP::UserAgent::->new(); printf("VERSION 1\nPROGRAM %s gpgkeys_hkpms msva-perl/%s\n", $self->{config}->{program}, # this is kind of cheating :/ @@ -150,7 +150,7 @@ use warnings; $self->{logger}->log('debug', "command: %s\n", $self->{config}->{command}); if (lc($self->{config}->{command}) eq 'search') { # for COMMAND = SEARCH, we want op=index, and we want to rejoin all args with spaces. - my $uri = new URI(sprintf('https://%s/pks/lookup', $self->{config}->{host})); + my $uri = URI::->new(sprintf('https://%s/pks/lookup', $self->{config}->{host})); my $arg = join(' ', @{$self->{args}}); $uri->query_form(op => 'index', options => 'mr', @@ -158,6 +158,7 @@ use warnings; ); $arg =~ s/\n/ /g ; # swap out newlines for spaces printf("\n%s %s BEGIN\n", $self->{config}->{command}, $arg); + $self->{logger}->log('debug', "URI: %s\n", $uri); my $resp = $ua->get($uri); if ($resp->is_success) { print($resp->decoded_content); @@ -168,7 +169,7 @@ use warnings; printf("\n%s %s END\n", $self->{config}->{command}, $arg); } elsif (lc($self->{config}->{command}) eq 'get') { # for COMMAND = GET, we want op=get, and we want to issue each query separately. - my $uri = new URI(sprintf('https://%s/pks/lookup', $self->{config}->{host})); + my $uri = URI::->new(sprintf('https://%s/pks/lookup', $self->{config}->{host})); foreach my $arg (@{$self->{args}}) { printf("\n%s %s BEGIN\n", $self->{config}->{command}, $arg); $uri->query_form(op => 'get', @@ -198,7 +199,7 @@ use warnings; if ($arg eq sprintf('KEY %s END', $keyid)) { $self->{logger}->log('debug', "Found KEY END line with %d lines of data elapsed\n", scalar(@keydata)); # for sending keys, we want to POST to /pks/add, with a keytext variable. - my $uri = new URI(sprintf('https://%s/pks/add', $self->{config}->{host})); + my $uri = URI::->new(sprintf('https://%s/pks/add', $self->{config}->{host})); my $resp = $ua->post($uri, {keytext => join("\n", @keydata)}); if ($resp->is_success) { printf("\n%s", $resp->decoded_content); @@ -232,14 +233,14 @@ use warnings; my $default_log_level = 'error'; my $client; if (exists($ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET})) { - $client = Crypt::Monkeysphere::MSVA::Client->new( - socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET}, - log_level => $default_log_level, - ); + $client = Crypt::Monkeysphere::MSVA::Client::->new( + socket => $ENV{MONKEYSPHERE_VALIDATION_AGENT_SOCKET}, + log_level => $default_log_level, + ); } my $self = { config => { }, args => [ ], - logger => (defined($client) ? $client->{logger} : Crypt::Monkeysphere::MSVA::Logger->new($default_log_level)), + logger => (defined($client) ? $client->{logger} : Crypt::Monkeysphere::MSVA::Logger::->new($default_log_level)), cache => { }, client => $client, actually_check => 1, @@ -252,7 +253,7 @@ use warnings; } -my $hkpms = Crypt::Monkeysphere::MSVA::HKPMS->new(); +my $hkpms = Crypt::Monkeysphere::MSVA::HKPMS::->new(); my $input = # load gpg instructions from stdin: do {