ARCv2

 view release on metacpan or  search on metacpan

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

B<Execute>. If your command runs into an error use the _SetError function 
and return immediately. This is what ARCv2 will evaluate and send to the
client.

B<Example>:
 sub Execute
 {
  my $this = shift;
  my $pw = <>;
  if ($pw ne "klaus") {
	  return $this->_SetError("Wrong password.");
  }
 }
 
In ARCv2 some standard commands are already implemented: C<Arc::Command::Get>,
C<Arc::Command::Put>, C<Arc::Command::Uptime>, C<Arc::Command::Whoami>,
C<Arc::Command::Test>.

By default, these classes are mapped to B<Command Names> as follows (in the 
default arcxd.conf for arcxd):
  uptime => Arc::Command::Uptime,

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


sub members 
{
	my $this = shift;
	return { %{$this->SUPER::members},
		logfileprefix => "client",
		logdestination => "stderr",
		
		sasl_cb_user => $ENV{'USER'}, # SASL Callback for username (PLAIN and some other mechs only)
		sasl_cb_auth => $ENV{'USER'}, # SASL Callback for authname (PLAIN and some other mechs only)
		sasl_cb_pass => "",           # SASL Callback for password (PLAIN and some other mechs only)

		server => undef,              # Server to connect to
		port => undef,                # Port to connect to
		sasl_mechanism => undef,      # use this mechanism for authentication
		server_sasl_mechanisms => [], # filled by the sasl mechanisms
		protocol => 1,	              # Which protocol type the shall use.
	};
}

sub _Init

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

 my $arc = new Arc::Connection::Client(
  server => "hyade11",
  port => 4242,
  timeout => 30,
  loglevel=> 7,
  logdestination => 'stderr',
  service => 'arc',
  sasl_mechanism => undef,
  sasl_cb_user => \&username,
  sasl_cb_auth => \&username,
  sasl_cb_pass => \&password,
 );

 if (my $m = $arc->IsError()) {
  die $m;
 }

 if ($arc->StartSession) {
  $arc->CommandStart("test");
  $arc->CommandWrite("hallo\n");
  if (my $t = $arc->CommandRead()) {
   print $t,"\n"; # should give 'all'
  }
  $arc->CommandEnd();
 }

 sub username
 {
  return $ENV{'USER'};
 }

 sub password
 {
  return <>;
 }


=head1 Class VARIABLES

=head3 PUBLIC MEMBERS

=over 2

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

B<Default value>: 1

=item sasl_cb_auth 

B<Description>: SASL Callback for authname (PLAIN and some other mechs only)

B<Default value>: $ENV{'USER'}

=item sasl_cb_pass 

B<Description>: SASL Callback for password (PLAIN and some other mechs only)

B<Default value>: ""

=item sasl_cb_user 

B<Description>: SASL Callback for username (PLAIN and some other mechs only)

B<Default value>: $ENV{'USER'}

=item sasl_mechanism 

lib/arcx.pod  view on Meta::CPAN

to /etc/passwd.

=back

=head1 USAGE

As usual a command line interface has some parameters to influence the behaviour.

The scheme looks like this:

arcx [-h <hostname>] [-p <port>] [-l <loglevel] [-L <logdestination] [-n] [-v] [-S <service>] [-F -f <history>] [-u|-U <username>] [-a|-A <authname>] [-w|-W <password>] [-s <mech>] [-t <timeout in sec>] [-r <string>] [command [command-arguments]]

=head2 Parameter

=over 4

=item -h <hostname>

The hostname, where the ARCv2 server is running. If no -h option is given, arcx will use the one chosen at compile time ($Arc::DefaultHost).

=item -p <port>

lib/arcx.pod  view on Meta::CPAN

=item -a

Ask for a authorization name.

=item -A <authname>

Use the <authname> for authorisation.

=item -w

Ask for a password (Only if SASL needs one).

=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>

scripts/arcx  view on Meta::CPAN

	my $arc = new Arc::Connection::Client(
		server => $args{h},
		port => $args{p},
		timeout => $args{t},
		loglevel=> $args{l},
		logdestination => $args{L},
		service => $args{S},
		sasl_mechanism => $args{s},
		sasl_cb_user => \&username,
		sasl_cb_auth => \&authname,
		sasl_cb_pass => \&password,
		protocol => $args{0} ? 0 : 1,
	);

	if (my $msg = $arc->IsError()) {
		err($msg);
		$retval = 1;
		next;
	}
	if ($arc->StartSession) {
		err("You are authenticated to $arc->{server}:$arc->{port} using $arc->{sasl_mechanism}.") if $args{n} || $intact || $args{v};

scripts/arcx  view on Meta::CPAN

}

sub usage
{
	my $msg = shift;
	print STDERR <<EOT;
$msg
$0 [-h <hostname>] [-p <port>] [-l <loglevel]
   [-L <logdestination] [-n] [-v] [-S <service>]
   [-F -f <history>] [-u|-U <username>] [-a|-A <authname>]
   [-w|-W <password>] [-s <mech>] [-t <timeout in sec>]
   [-r <string>] [-V] [-C <conffile>] [command [command-arguments]]

  (Remark: Some parameters behave different in comparison to the old arc)

  -h <hostname>    specify the ARCv2 server
  -p <port>        port to connect (default: $Arc::DefaultPort)
  -t <timeout>     specify the timeout in seconds (default: 30 secs)
  -0               use old protocol type (unencrypted protocol conn.)
  -C <conffile>    use <conffile> as source for server-command-mapping.
                   (default: $Arc::ConfigPath/arcx.conf)

scripts/arcx  view on Meta::CPAN


  -S <service>     name of the service used for arc auth (default: arc)
  -s <mech>        use <mech> as authentication mechanism for SASL
  -n               do nothing, just try to authenticate
  -v               be verbose

  -U <username>    username for authentication (dep. on SASL mechanism)
  -u               ask for username
  -A <authz name>  username for authorization (dep. SASL mechanism)
  -a               ask for authname
  -W <password>    password (dep. on SASL mechanism)
  -w               ask for password

  -f <history>     filename for command history (def: $ENV{HOME}/.archistory)
  -F               don't add commands to the history file

  -l <loglevel>    loglevel (see man Arc) (default: 0, error msgs will be on stderr)
  -L <logdest>     log destination (possible values: 'syslog' (def) or 'stderr')
  -V               display version information

$Arc::Copyright
$Arc::Contact

scripts/arcx  view on Meta::CPAN

{
	if (defined $args{A} && $args{A} ne "") {
		return $args{A};
	} elsif (defined $args{a}) {
		print STDERR "Enter your name for authorization: "; return <STDIN>;
	} else {
		return $ENV{'USER'};
	}
}

sub password
{
	if (defined $args{P} && $args{P} ne "") {
		return $args{P};
	} elsif (defined $args{p}) {
		print STDERR "Enter your password: ";
		ReadMode 2;
		my $pw = <STDIN>;
		ReadMode 0;
		return $pw;
	} else {
		return $ENV{'USER'};
	}
}

sub verbout



( run in 0.344 second using v1.01-cache-2.11-cpan-bb97c1e446a )