ARCv2

 view release on metacpan or  search on metacpan

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

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
=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

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
}
 
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

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
  -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

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
{
        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.444 second using v1.01-cache-2.11-cpan-bb97c1e446a )