[Rt-commit] rt branch, 4.4/admin-gpg-keys, repushed

? sunnavy sunnavy at bestpractical.com
Wed Nov 28 09:23:10 EST 2018


The branch 4.4/admin-gpg-keys was deleted and repushed:
       was 42f4508fc420d774da792f2868e0d8372d034f59
       now 8bbaf1cc76e232fbab3a6f5e56d7468da4eeaba0

1: b432e61b3 ! 1: b490e19d2 Add admin page to manage GnuPG keys
    @@ -32,9 +32,59 @@
     +    );
     +}
     +
    ++sub SearchKey {
    ++    my $self = shift;
    ++    my $key  = shift;
    ++
    ++    my @output;
    ++    my %ret = $self->CallGnuPG(
    ++        Command     => "search_keys",
    ++        CommandArgs => [ '--', $key ],
    ++        Output      => \@output,
    ++        # gpg hangs if command handle is supplied :/
    ++        Handles     => { command => 0 },
    ++    );
    ++
    ++    my @results;
    ++    my $result;
    ++    for my $line ( @output ) {
    ++        if ( $line =~ /^\(\d+\)/ ) {
    ++            push @results, { Summary => $result } if $result;
    ++            $result = $line;
    ++        }
    ++        else {
    ++            $result .= $line;
    ++        }
    ++    }
    ++    push @results, { Summary => $result } if $result;
    ++
    ++    for my $item ( @results ) {
    ++        if ( $item->{Summary} =~ /^\s*\d+ bit \w+ key (\w{8,})/mi ) {
    ++            $item->{Key} = $1;
    ++        }
    ++        else {
    ++            RT->Logger->warning("Couldn't find key from gpg search result: $item->{Summary}");
    ++        }
    ++    }
    ++    @results = grep { $_->{Key} } @results;
    ++
    ++    return ( %ret, results => \@results );
    ++}
    ++
      sub GnuPGPath {
          state $cache = RT->Config->Get('GnuPG')->{'GnuPG'};
          $cache = $_[1] if @_ > 1;
    +@@
    +         foreach grep !defined $handle_map{$_}, 
    +         qw(stdin stdout stderr logger status command);
    + 
    ++    for my $type ( keys %handle_map ) {
    ++        delete $handle_map{$type} if !$handle_map{$type};
    ++    }
    ++
    +     my $handles = GnuPG::Handles->new(%handle_map);
    +     return ($handles, \%handle_map);
    + }
     
     diff --git a/share/html/Admin/Tools/GnuPG.html b/share/html/Admin/Tools/GnuPG.html
     new file mode 100644
    @@ -100,9 +150,31 @@
     +% my %options = RT->Config->Get('GnuPGOptions');
     +% if ( $options{'keyserver'} ) {
     +        <tr>
    ++            <td align="right"></td>
    ++            <td>
    ++                <input name="Query" value="<% $ARGS{Query} // '' %>" size="40" />
    ++                <input name="Search" type="submit" class="button" value="<&|/l&>Search</&>" />
    ++            </td>
    ++        </tr>
    ++% if ( @search_results ) {
    ++        <tr>
    ++            <td></td>
    ++            <td>
    ++                <input type="checkbox" name="KeyAll" value="1" onclick="setCheckbox(this, 'Key')"></th>
    ++                <span><&|/l&>Check All</&></span>
    ++            </td>
    ++        </tr>
    ++% for my $item ( @search_results ) {
    ++        <tr>
     +            <td align="right"><&|/l&>Key</&>:</td>
    -+            <td><input name="Key" value="<% $ARGS{Key} // '' %>" size="40" /></td>
    -+        </tr>
    ++            <td>
    ++                <input type="checkbox" name="Key" value="<% $item->{Key} %>" />
    ++                <span><% $item->{Summary} %></span>
    ++            </td>
    ++        </tr>
    ++% }
    ++% }
    ++
     +% }
     +        <tr>
     +            <td align="right"><&|/l&>Content</&>:</td>
    @@ -208,12 +280,22 @@
     +
     +require RT::Crypt::GnuPG;
     +
    -+if ( $ARGS{Import} ) {
    ++my @search_results;
    ++if ( $ARGS{Search} ) {
    ++    if ( $ARGS{Query} ) {
    ++        my %ret = RT::Crypt::GnuPG->SearchKey( $ARGS{Query} );
    ++        @search_results = @{$ret{results}};
    ++        push @results, split /\n+/, $ret{logger} unless @search_results;
    ++    }
    ++}
    ++elsif ( $ARGS{Import} ) {
     +
     +    # show admin detailed imported messages
     +    if ( $ARGS{Key} ) {
    -+        my %ret = RT::Crypt::GnuPG->ReceiveKey( $ARGS{Key} );
    -+        push @results, split /\n+/, $ret{logger};
    ++        for my $key ( ref $ARGS{Key} ? @{ $ARGS{Key} } : $ARGS{Key} ) {
    ++            my %ret = RT::Crypt::GnuPG->ReceiveKey( $key );
    ++            push @results, split /\n+/, $ret{logger};
    ++        }
     +    }
     +
     +    if ( $ARGS{Content} ) {
2: 42f4508fc = 2: 8bbaf1cc7 Test admin page of "Manage GnuPG Keys"



More information about the rt-commit mailing list