| 1 | # | ||
| 2 | # $Id: rsh.pm,v 1.4 2003/03/02 11:12:10 dsw Exp $ | ||
| 3 | # | ||
| 4 | # COPYRIGHT AND LICENSE | ||
| 5 | # Copyright (c) 2001-2003, Juniper Networks, Inc. | ||
| 6 | # All rights reserved. | ||
| 7 | # Redistribution and use in source and binary forms, with or without | ||
| 8 | # modification, are permitted provided that the following conditions are | ||
| 9 | # met: | ||
| 10 | # 1. Redistributions of source code must retain the above | ||
| 11 | # copyright notice, this list of conditions and the following | ||
| 12 | # disclaimer. | ||
| 13 | # 2. Redistributions in binary form must reproduce the above | ||
| 14 | # copyright notice, this list of conditions and the following disclaimer | ||
| 15 | # in the documentation and/or other materials provided with the | ||
| 16 | # distribution. | ||
| 17 | # 3. The name of the copyright owner may not be used to | ||
| 18 | # endorse or promote products derived from this software without specific | ||
| 19 | # prior written permission. | ||
| 20 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
| 21 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
| 22 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 23 | # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
| 24 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 27 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 28 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 29 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 30 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 31 | # | ||
| 32 | # The JUNOS::Access::rsh package implements the rsh access method. This | ||
| 33 | # access method is currently unsupported. | ||
| 34 | # | ||
| 35 | |||
| 36 | package JUNOS::Access::rsh; | ||
| 37 | |||
| 38 | use vars qw(@ISA $unknown_host $command_not_found); | ||
| 39 | use JUNOS::Trace; | ||
| 40 | use JUNOS::Access; | ||
| 41 | |||
| 42 | @ISA = qw(JUNOS::Access); | ||
| 43 | |||
| 44 | sub start | ||
| 45 | { | ||
| 46 | my($self) = @_; | ||
| 47 | my $who = $self->{hostname}; | ||
| 48 | my @flags; | ||
| 49 | |||
| 50 | push(@flags, "-l " . $self->{login}) | ||
| 51 | if $self->{login} and $self->{login} ne $ENV{USER}; | ||
| 52 | |||
| 53 | $self->start_command("rsh", @flags, $who, "junoscript"); | ||
| 54 | } | ||
| 55 | |||
| 56 | $unknown_host = | ||
| 57 | "getaddrinfo: No address associated with hostname"; | ||
| 58 | |||
| 59 | $command_not_found = "junoscript: .*not found"; | ||
| 60 | |||
| 61 | sub incoming | ||
| 62 | { | ||
| 63 | tracept("IO"); | ||
| 64 | my($self, $incoming) = @_; | ||
| 65 | |||
| 66 | $incoming = $self->{Leader} . $incoming if $self->{Leader}; | ||
| 67 | |||
| 68 | if ($incoming =~ /${unknown_host}/s ) { | ||
| 69 | $self->{JUNOS_Device}->report_error("Host not found " . @_ ); | ||
| 70 | $self = undef; | ||
| 71 | } elsif ($incoming =~ /${command_not_found}/) { | ||
| 72 | $self->{JUNOS_Device}->report_error(ref $self . "::incoming: command not found: " . $self->{hostname} . "; old software?; aborting"); | ||
| 73 | $self = undef; | ||
| 74 | } else { | ||
| 75 | trace("IO", "ignoring leading input: [[[$incoming]]]"); | ||
| 76 | $self->{Leader} .= $incoming; | ||
| 77 | } | ||
| 78 | |||
| 79 | $self; | ||
| 80 | } | ||
| 81 | |||
| 82 | 1; | ||
| 83 | |||
| 84 | __END__ |