ARCv2

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

MANIFEST			This list of files
README
scripts/arcx
scripts/arcx.conf
scripts/arcxd
scripts/arcxd.conf
scripts/object.pl
scripts/PBConfig.pm
scripts/arcxd.init.d.solaris
t/arc1.t
META.yml                                 Module meta-data (added by MakeMaker)

lib/Arc/Command.pod  view on Meta::CPAN

    logfileprefix => "command",
  );
  $object->Execute(@a);
  $cmderr = $object->IsError();

  return -1;
 };
 
When everything went alright, the command will be executed. The command runs
in a separate process. Therefore STDIN, STDOUT and STDERR are duped to two
pipes, one for the in, one for the out direction. In the parent process data
from the encrypted network command connection is read from and written to these pipes.
Same situation on the client side, STDIN and STDOUT are used to put and get the 
data through the network.
 
                   encrypted
          /--->>---| net- |--->>-----\   
        / /---<<---| work |---<<-----\ \
      / /                              \ \
     | |     in                         | |    p2
  |--------|->>--\                  |--------|->>--\ 
  | Client | out   \                | Server | p1    \
  |--------|-<<-\    \              |--------|-<<-\    \ 
                /|\  \|/                          /|\  \|/

lib/Arc/Connection.pm  view on Meta::CPAN

				return 1;
			}
		}
	} else {
		return $this->_SetError("No CommandConnection received (Client died?).");
	}	
}

## function for reading and writing on the command connection.
## This function is always used by the C<Arc::Connection::Server> to handle 
## command data. When calling the C<ProcessCommand> from C<Arc::Connection::Client> 
## this function is also used.
## Data is read from the local socket resp. pipe and is written encrypted 
## to the network socket. The other side reads the data from network socket, 
## decrypts it and writes it to its local socket. This function behaves differently on 
## client and server sides, when the local or network socket is closed.
##in> *locfdin, *locfdout
##out> always true
##eg> $this->ReadWriteBinary(*STDIN,*STDOUT);
sub _ReadWriteBinary
{
	my $this = shift;
	my $locin = shift;
	my $locout = shift;

lib/Arc/Connection.pm  view on Meta::CPAN

	my $sel = new IO::Select($netsock,$locin);
	my $lwsel = new IO::Select($locout);
	my $nwsel = new IO::Select($netsock);

	my $buf;
	my $stop = 0;
	while (my @rs = $sel->can_read) {
		foreach my $r (@rs) {
			# Something is readable.
			my $ret = $r->sysread($buf,4096);
			# If no data received, this read socket is closed
			# We don't want to listen to it anymore
			unless ($ret) {
				$sel->remove($r);
				# If there is nothing to read anymore
				# we will never write to the other socket again.
				if ($r->fileno == $locin->fileno) {
					$stop = 1 unless $client;
					shutdown($netsock,1); # Close write connection
				} elsif ($r->fileno == $netsock->fileno) {
					# on client-side the netsock is closed only

lib/Arc/Connection.pm  view on Meta::CPAN

{
	my $this = shift;
	my ($cmd,$msg) = @_;
	my $ret = 1;

	$ret = $this->_SetError("Sending command $cmd failed.") unless $this->_SendLine($cmd,defined $msg ? " ".$msg : "");
	return $ret;
}

## receive a line (command). (protocol)
## This function receives data from the ARCv2 connection and
## fills the internal C<__linequeue> and C<__partial>. It returns 
## a line from the internal buffer if there is any. It also handles
## timeouts and "connection closed by foreign host"'s.
##out> true (and the line) if everything worked fine, otherwise false (undef)
##eg> if (my $line = $this->_RecvLine()) { ... }
sub _RecvLine
{
	my $this = shift;

	return shift @{$this->{__linequeue}} if scalar @{$this->{__linequeue}};

	# no connection is set not connected
	return $this->_SetError("RecvCommand only Available when connection and select is set.") unless $this->{_connected};

	my $partial = defined($this->{__partial}) ? $this->{__partial} : "";

	my $buf = "";
	until (scalar @{$this->{__linequeue}}) {
		if ($this->{_select}->can_read($this->{timeout})) { # true if select thinks there is data 
			my $inbuf;
			unless ($this->{_connection}->sysread($inbuf,4096)) {
				$this->{_connected} = 0;
				$this->{_connection}->close();
				return $this->_SetError("Connection closed by foreign host.");
			}
# decrypt if possible and necessary
			$buf = $this->{_sasl}->decode($inbuf) 
				if $this->{_authenticated} == 1 and $this->{protocol} == 1;
				

lib/Arc/Connection.pod  view on Meta::CPAN


B<Example:>

while (my $cmd = $this->_RecvCommand() && $this->_ProcessLine($cmd)) {}


=item _ReadWriteBinary ( *locfdin, *locfdout ) 

B<Description>: function for reading and writing on the command connection.
This function is always used by the C<Arc::Connection::Server> to handle 
command data. When calling the C<ProcessCommand> from C<Arc::Connection::Client> 
this function is also used.
Data is read from the local socket resp. pipe and is written encrypted 
to the network socket. The other side reads the data from network socket, 
decrypts it and writes it to its local socket. This function behaves differently on 
client and server sides, when the local or network socket is closed.


B<Returns:> always true


B<Example:>

$this->ReadWriteBinary(*STDIN,*STDOUT);

lib/Arc/Connection.pod  view on Meta::CPAN



B<Example:>

while (my $cmd = $this->_RecvCommand()) { ... }


=item _RecvLine (  ) 

B<Description>: receive a line (command). (protocol)
This function receives data from the ARCv2 connection and
fills the internal C<__linequeue> and C<__partial>. It returns 
a line from the internal buffer if there is any. It also handles
timeouts and "connection closed by foreign host"'s.


B<Returns:> true (and the line) if everything worked fine, otherwise false (undef)


B<Example:>

lib/Arc/Connection/Client.pm  view on Meta::CPAN

	while (!$this->{_error} && (not defined $this->{_cmdclientsock}) && (my $cmd = $this->_RecvCommand()) ) {
		$this->_ProcessLine($cmd);
		last if $cmd eq "DONE";
	}
	return 1 if defined $this->{_cmdclientsock};
	return;
}

## write something to the command.
## Write something to the standard input of the command started by C<CommandStart>.
##in> ... (data)
##out> true if successful, false if not. (IsError is set appropriatly)
##eg> last unless $this->CommandWrite();
sub CommandWrite
{
	my $this = shift;
	return $this->_SetError("There is no command running.") unless defined $this->{_cmdclientsock};
	return unless @_;

	my $str = join("",@_);
	$str = $this->{_sasl}->encode($str);

lib/Arc/Connection/Client.pm  view on Meta::CPAN

##out> true if successful, false if not. (IsError is set appropriatly)
##eg> last unless $arc->CommandEOF();
sub CommandEOF
{
	my $this = shift;
	return $this->_SetError("There is no command running.") unless defined $this->{_cmdclientsock};

	return shutdown($this->{_cmdclientsock},1);
}

## read data from the Command connection.
##out> if successful the received data is returned, otherwise false.
##eg> while (my $data = $arc->CommandRead()) { ... }
sub CommandRead
{
	my $this = shift;
	return $this->_SetError("There is no command running.") unless defined $this->{_cmdclientsock};

	my $sel = new IO::Select ( $this->{_cmdclientsock} );
	my $buf;
	while ($sel->can_read($this->{timeout})) {
		return unless $this->{_cmdclientsock}->sysread($buf,1024);
		$buf = $this->{_sasl}->decode($buf);

lib/Arc/Connection/Client.pod  view on Meta::CPAN

B<Returns:> true if successful, false if not. (IsError is set appropriatly)


B<Example:>

last unless $arc->CommandEOF();


=item CommandRead (  ) 

B<Description>: read data from the Command connection.


B<Returns:> if successful the received data is returned, otherwise false.


B<Example:>

while (my $data = $arc->CommandRead()) { ... }


=item CommandStart ( ... (command and its parameters) ) 

B<Description>: start an ARCv2 command
This function starts the given ARCv2 Command and enables the Command* functions.


B<Returns:> true if successful, false if not. (IsError is set appropriatly)


B<Example:>

if ($arc->CommandStart()) { ... }


=item CommandWrite ( ... (data) ) 

B<Description>: write something to the command.
Write something to the standard input of the command started by C<CommandStart>.


B<Returns:> true if successful, false if not. (IsError is set appropriatly)


B<Example:>

lib/Arc/Connection/Client.pod  view on Meta::CPAN


B<Example:>

while (my $cmd = $this->_RecvCommand() && $this->_ProcessLine($cmd)) {}


=item _ReadWriteBinary ( *locfdin, *locfdout ) I<inherited from Arc::Connection>

B<Description>: function for reading and writing on the command connection.
This function is always used by the C<Arc::Connection::Server> to handle 
command data. When calling the C<ProcessCommand> from C<Arc::Connection::Client> 
this function is also used.
Data is read from the local socket resp. pipe and is written encrypted 
to the network socket. The other side reads the data from network socket, 
decrypts it and writes it to its local socket. This function behaves differently on 
client and server sides, when the local or network socket is closed.


B<Returns:> always true


B<Example:>

$this->ReadWriteBinary(*STDIN,*STDOUT);

lib/Arc/Connection/Client.pod  view on Meta::CPAN



B<Example:>

while (my $cmd = $this->_RecvCommand()) { ... }


=item _RecvLine (  ) I<inherited from Arc::Connection>

B<Description>: receive a line (command). (protocol)
This function receives data from the ARCv2 connection and
fills the internal C<__linequeue> and C<__partial>. It returns 
a line from the internal buffer if there is any. It also handles
timeouts and "connection closed by foreign host"'s.


B<Returns:> true (and the line) if everything worked fine, otherwise false (undef)


B<Example:>

lib/Arc/Connection/Server.pod  view on Meta::CPAN


B<Example:>

while (my $cmd = $this->_RecvCommand() && $this->_ProcessLine($cmd)) {}


=item _ReadWriteBinary ( *locfdin, *locfdout ) I<inherited from Arc::Connection>

B<Description>: function for reading and writing on the command connection.
This function is always used by the C<Arc::Connection::Server> to handle 
command data. When calling the C<ProcessCommand> from C<Arc::Connection::Client> 
this function is also used.
Data is read from the local socket resp. pipe and is written encrypted 
to the network socket. The other side reads the data from network socket, 
decrypts it and writes it to its local socket. This function behaves differently on 
client and server sides, when the local or network socket is closed.


B<Returns:> always true


B<Example:>

$this->ReadWriteBinary(*STDIN,*STDOUT);

lib/Arc/Connection/Server.pod  view on Meta::CPAN



B<Example:>

while (my $cmd = $this->_RecvCommand()) { ... }


=item _RecvLine (  ) I<inherited from Arc::Connection>

B<Description>: receive a line (command). (protocol)
This function receives data from the ARCv2 connection and
fills the internal C<__linequeue> and C<__partial>. It returns 
a line from the internal buffer if there is any. It also handles
timeouts and "connection closed by foreign host"'s.


B<Returns:> true (and the line) if everything worked fine, otherwise false (undef)


B<Example:>

lib/arcx.pod  view on Meta::CPAN

=item -W <password>

Use the <password> for authentication. (Only if an appropriate mechanism is used. (eg. PLAIN)).

=item -s <mechanism>

For authentication use the given <mechanism>. (Default: let the server decide.)

=item -t <timeout>

Timeout in seconds to wait for data in control and command connection.

=item -r <string>

<string> is going to be written to the established command connection, when command is used. (Do not wait for user input on STDIN).

eg.: arcx -r "data" test 
results in "at".

=item command

Run this ARCv2 command. Run "help" to see, which commands are available.

=item command-arguments

Some ARCv2 command can handle arguments. They should go here.

lib/arcxd.pod  view on Meta::CPAN

=head2 main

=over 4

=item service

The name of the service the SASL authentication mechanism shall use.

=item timeout

Timeout in seconds to wait for data in control and command connection.

=back

=head2 arcd

=over 4

=item host

Here you can specify the address the server shall wait for connections. 0 lets the server listen on all interface on the host. 



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