Cisco-Conf

 view release on metacpan or  search on metacpan

cisconf.PL  view on Meta::CPAN

    }
    if (exists($config->{'hosts'}->{$name})) {
	die "A router $name already exists.";
    }

    print "\nEnter a description of the router $name (one line):\n";
    my $description = <STDIN>;
    $description =~ s/^\s+//;
    $description =~ s/\s+$//;

    my $user = ((getpwuid($>))[0]);
    if ($< != $>) {
	$user .= " " . ((getpwuid($<))[0]);
    }
    if ($< != 0  &&  $> != 0) {
	$user .= " " . ((getpwuid(0))[0]);
    }
    print "\nEnter blank separated list of users that may configure the";
    print "\n router: [$user] ";
    my $reply = <STDIN>;
    $reply =~ s/^\s+//;
    $reply =~ s/\s+$//;
    $user = $reply ? $reply : $user;

    my $peer_address;
    if ($peer_address = Socket::inet_aton($name)) {

lib/Cisco/Conf.pm  view on Meta::CPAN

    }
    my $self = $config->{'hosts'}->{$name};
    bless($self, (ref($class) || $class));
    my $key;
    foreach $key (qw(editors ci local_addr tftp_prefix)) {
	if (!exists($self->{$key})) {
	    $self->{$key} = $config->{$key};
	}
    }
    $self->{'configFile'} = $configFile;
    my($euid, $epasswd, $euser) = getpwuid($>);
    my($ruid, $rpasswd, $ruser) = getpwuid($<);
    my($user);
    foreach $user (@{$self->{'users'}}) {
	if ($user eq $euid  ||  $user eq $euser  ||
	    $user eq $ruid  ||  $user eq $ruser) {
	    return $self;
	}
    }
    die "You have no permissions to access host $name.";
}



( run in 0.298 second using v1.01-cache-2.11-cpan-8d75d55dd25 )