This file is indexed.

/usr/share/perl5/EBox/CGI/CA/RevokeCertificate.pm is in zentyal-ca 2.3.6+quantal1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright (C) 2008-2012 eBox Technologies S.L.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

package EBox::CGI::CA::RevokeCertificate;

use strict;
use warnings;

use base 'EBox::CGI::ClientBase';

use EBox::Gettext;
use EBox::Global;
# For exceptions
use Error qw(:try);
use EBox::Exceptions::DataInUse;

# Method: new
#
#       Constructor for RevokeCertificate CGI
#
# Returns:
#
#       RevokeCertificate - The object recently created

sub new
  {

    my $class = shift;

    my $self = $class->SUPER::new('title' => __('Certification Authority'),
				  @_);

    $self->{chain} = "CA/Index";
    bless($self, $class);

    return $self;

  }

# Process the HTTP query
# Templates that come from: forceRevoke.mas and formRevoke.mas

sub _process
  {

    my $self = shift;

    # If it comes from forceRevoke with a cancel button
    if ( defined($self->param('cancel')) ) {
      $self->setRedirect( 'CA/Index' );
      $self->setMsg( __("The certificate has NOT been revoked.") );
      $self->cgi()->delete_all();
      return;
    }

    my $ca = EBox::Global->modInstance('ca');

    $self->_requireParam('isCACert', __('Boolean indicating Certification Authority Certificate') );
    $self->_requireParam('reason', __('Reason') );

    my $commonName = $self->unsafeParam('commonName');
    # We have to check it manually
    if ( not defined($commonName) or $commonName eq '' ) {
      throw EBox::Exceptions::DataMissing(data => __('Common Name'));
    }
    # Only valid chars minus '/' plus '*' --> security risk
    unless ( $commonName =~ m{^[\w .?&+:\-\@\*]*$} ) {
        throw EBox::Exceptions::External(__('The input contains invalid ' .
                                            'characters. All alphanumeric characters, ' .
					    'plus these non alphanumeric chars: .?&+:-@* ' .
					    'and spaces are allowed.'));
    }

    # Transform %40 in @
    $commonName =~ s/%40/@/g;
    # Transform %20 in space
    $commonName =~ s/%20/ /g;

    my $isCACert = $self->param('isCACert');
    my $reason = $self->param('reason');
    my $caPassphrase = $self->param('caPassphrase');
    $caPassphrase = undef if ( $caPassphrase eq '' );
    my @array = ();

    my $retValue;
    my $retFromCatch = undef;

    if ( defined($self->param("revokeForce")) ) {
    # If comes from a forceRevoke with forceRevoke button
      if ( $isCACert ) {
	$ca->revokeCACertificate(reason        => $reason,
                                 caKeyPassword => $caPassphrase,
				 force         => 1);
      } else {
	$ca->revokeCertificate(commonName    => $commonName,
			       reason        => $reason,
                               caKeyPassword => $caPassphrase,
			       force         => 1);
      }
    } else {
      # If it comes from a formRevoke.mas
      try {
	if ( $isCACert ) {
	  $retValue = $ca->revokeCACertificate( reason => $reason,
                                                caKeyPassword => $caPassphrase,
                                              );
	} else {
	  $retValue = $ca->revokeCertificate( commonName    => $commonName,
                                              caKeyPassword => $caPassphrase,
					      reason        => $reason);
	}
      } catch EBox::Exceptions::DataInUse with {
	$self->{template} = '/ca/forceRevoke.mas';
	$self->{chain} = undef;
	my $cert = $ca->getCertificateMetadata( cn => $commonName );
	push (@array, 'metaDataCert' => $cert);
	push (@array, 'isCACert'   => $isCACert);
	push (@array, 'reason'     => $reason);
        push (@array, 'caPassphrase' => $caPassphrase);
	$self->{params} = \@array;
	$retFromCatch = 1;
      };
    }

    if (not $retFromCatch) {
      my $msg = __("The certificate has been revoked");
      $msg = __("The CA certificate has been revoked") if ($isCACert);
      $self->setMsg($msg);
      # No parameters to send to CA/Index
      $self->cgi()->delete_all();
    }

  }

1;