This file is indexed.

/usr/share/perl5/MMM/Agent/Role.pm is in mysql-mmm-agent 2.2.1-1.1.

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
package MMM::Agent::Role;
use base 'MMM::Common::Role';

use strict;
use warnings FATAL => 'all';
use Log::Log4perl qw(:easy);
use MMM::Agent::Helpers;

our $VERSION = '0.01';

=head1 NAME

MMM::Agent::Role - role class (agent)

=cut


=head1 METHODS

=over 4

=item check()

Check (=assure) that the role is configured on the local host.

=cut
sub check($) {
	my $self = shift;

	my $res;

	if ($self->name eq $main::agent->writer_role) {
		$res = MMM::Agent::Helpers::allow_write();
		if (!defined($res) || $res !~ /^OK/) {
			FATAL sprintf("Couldn't allow writes: %s", defined($res) ? $res : 'undef');
			return;
		}
	}

	$res = MMM::Agent::Helpers::configure_ip($main::agent->interface, $self->ip);
	if (!defined($res) || $res !~ /^OK/) {
		FATAL sprintf("Couldn't configure IP '%s' on interface '%s': %s", $self->ip, $main::agent->interface, defined($res) ? $res : 'undef');
		return;
	}
}

=item add()

Add a role to the local host.

=cut
sub add($) {
	my $self = shift;
	
	my $res;

	if ($self->name eq $main::agent->writer_role) {
		$res = MMM::Agent::Helpers::sync_with_master();
		if (!defined($res) || $res !~ /^OK/) {
			FATAL sprintf("Couldn't sync with master: %s", defined($res) ? $res : 'undef');
			return;
		}
		$res = MMM::Agent::Helpers::allow_write();
		if (!defined($res) || $res !~ /^OK/) {
			FATAL sprintf("Couldn't allow writes: %s", defined($res) ? $res : 'undef');
			return;
		}
	}

	$res = MMM::Agent::Helpers::configure_ip($main::agent->interface, $self->ip);
	if (!defined($res) || $res !~ /^OK/) {
		FATAL sprintf("Couldn't configure IP '%s' on interface '%s': %s", $self->ip, $main::agent->interface, defined($res) ? $res : 'undef');
		return;
	}
}

=item del()

Delete a role from the local host.

=cut
sub del($) {
	my $self = shift;

	my $res;
	
	if ($self->name eq $main::agent->writer_role) {
		$res = MMM::Agent::Helpers::deny_write();
		if (!defined($res) || $res !~ /^OK/) {
			FATAL sprintf("Couldn't deny writes: %s", defined($res) ? $res : 'undef');
		}
	}

	$res = MMM::Agent::Helpers::clear_ip($main::agent->interface, $self->ip);
	if (!defined($res) || $res !~ /^OK/) {
		FATAL sprintf("Couldn't clear IP '%s' from interface '%s': %s", $self->ip, $main::agent->interface, defined($res) ? $res : 'undef');
	}
}

1;