ARCv2
view release on metacpan or search on metacpan
lib/Arc/Command.pod view on Meta::CPAN
119120121122123124125126127128129130131132133134135136137138139and
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
141516171819202122232425262728293031323334sub
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
343536373839404142434445464748495051525354555657585960616263646566676869707172737475my
$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()) {
$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
9596979899100101102103104105106107108109110111112113114115B<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
333435363738394041424344454647484950515253to /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
93949596979899100101102103104105106107108109110111112113114115116117=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
777879808182838485868788899091929394959697my
$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
190191192193194195196197198199200201202203204205206207208209210}
sub
usage
{
my
$msg
=
shift
;
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)
-C <conffile>
use
<conffile> as source
for
server-command-mapping.
(
default
:
$Arc::ConfigPath
/arcx.conf)
scripts/arcx view on Meta::CPAN
213214215216217218219220221222223224225226227228229230231232233234
-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
253254255256257258259260261262263264265266267268269270271272273274275276277278{
if
(
defined
$args
{A} &&
$args
{A} ne
""
) {
return
$args
{A};
}
elsif
(
defined
$args
{a}) {
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}) {
STDERR
"Enter your password: "
;
ReadMode 2;
my
$pw
= <STDIN>;
ReadMode 0;
return
$pw
;
}
else
{
return
$ENV
{
'USER'
};
}
}
sub
verbout
( run in 0.444 second using v1.01-cache-2.11-cpan-bb97c1e446a )