view release on metacpan or search on metacpan
- command error handling improved, passed to the client separatly now
1.03 Tue Dec 02 2004
- Documentation has to be created
- line feed when command sprays an error (thanks to Wolfgang Friebel)
- pid file
- removed errornous white space
1.02 Tue Nov 02 2004
- corrected a typo (forgot a $) (thanks to Tony Fraser)
- added a member-variable to allow changable server connection type
this makes extending Arc::Connection::Server more easier to use it then
with Arc::Server (suggested by Tony Fraser, thanks)
- timeout behaviour for command connection fixed (thanks to Wolfgang Friebel)
- workaround bug regarding asynchonous sasl-encryption within one connection
1.01 Wed Jul 28 2004
- commandconnection is now using IO::Select for accepting
- added init.d script for solaris
1.00 Wed Jul 28 2004
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: ARCv2
version: 1.05
version_from: lib/Arc.pm
installdirs: site
requires:
Authen::SASL: 2.06
Authen::SASL::Cyrus: 0.10
Config::IniFiles: 0.0
IO::Pipe: 0.0
IO::Select: 0.0
IO::Socket::INET: 0.0
MIME::Base64: 0.0
Net::Server::PreFork: 0.85
Term::ReadKey: 0.0
Term::ReadLine: 0.0
Test::More: 0.0
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.17
ARCv2 (see Arc.pm for current version)
=====
INSTALLATION
To install this module type the following:
IMPORTANT: Due the automatic generation of the pod-files, first of all
you have to run:
make -C docs
This is a workaround until I'll have a better idea.
Then to install
perl Makefile.PL
make
lib/Arc/Connection/Client.pm view on Meta::CPAN
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
{
my $this = shift;
return 0 unless $this->SUPER::_Init(@_);
# server
lib/Arc/Connection/Client.pm view on Meta::CPAN
##eg> $this->_InitARC2();
sub _InitARC2
{
my $this = shift;
@{$this->{_expectedcmds}} = qw(ERR AUTH);
$this->{_authenticated} = 0;
return $this->_SendCommand ("ARC/2.".$this->{protocol});
}
## initiate the authentication.
## Tells the server which authtype we want to use.
## Protocol command: AUTHENTICATE [<authtype>]\r\n
##out> true when succesful, otherwise false
##eg> $this->_Authenticate();
sub _Authenticate
{
my $this = shift;
@{$this->{_expectedcmds}} = qw(ERR AUTHTYPE);
return $this->_SendCommand ("AUTHENTICATE",$this->{sasl_mechanism});
}
## initiate the authentication (sasl)
lib/Arc/Connection/Client.pod view on Meta::CPAN
B<Default value>: "client"
=item port
B<Description>: Port to connect to
B<Default value>: undef
=item protocol I<reimplemented from Arc::Connection>
B<Description>: Which protocol type the shall use.
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
lib/Arc/Connection/Client.pod view on Meta::CPAN
=back
=head3 PROTECTED METHODS
=over 2
=item _Authenticate ( )
B<Description>: initiate the authentication.
Tells the server which authtype we want to use.
Protocol command: AUTHENTICATE [<authtype>]\r\n
B<Returns:> true when succesful, otherwise false
B<Example:>
$this->_Authenticate();
lib/Arc/Connection/Server.pm view on Meta::CPAN
# commands
return $this->_SetError("No ARCv2 commands given. There is no reason the run ARCv2.")
unless defined $this->{commands};
}
## Callback function to canonicalize the username (SASL)
## see Authen::SASL(::Cyrus) for parameter list and how to use.
sub _CBCanonUser
{
my ($this,$type,$realm,$maxlen,$user) = @_;
return $user;
}
## send the available SASL mechanisms.
## Protocol command: AUTH <comma-seperated list of SASL mechansims>\r\n
##out> true when succesful, otherwise false
##eg> $this->_Auth();
sub _Auth
{
my $this = shift;
lib/Arc/Connection/Server.pm view on Meta::CPAN
##eg> $this->_Done();
sub _Done
{
my $this = shift;
return $this->_SendCommand("DONE");
}
## tell the client, which SASL mechanism is used.
## Protocol command: AUTHTYPE <SASL mechansism>\r\n
##out> true when succesful, otherwise false
##eg> $this->_Authtype();
sub _Authtype
{
my $this = shift;
@{$this->{_expectedcmds}} = qw(QUIT SASL);
return $this->_SendCommand("AUTHTYPE",$this->{_saslmech});
}
## Creates the sasl object (server_new)
## and sends the first sasl challenge/response.
## Protocol command: SASL <base64 encoded SASL output>\r\n
##out> true when succesful, otherwise false
lib/Arc/Connection/Server.pm view on Meta::CPAN
$this->{_saslmech} = $this->{_cmdparameter};
} else {
return $this->_Error("SASL mechanism not allowed by server.");
}
} else {
$this->_Debug("Default Sasl: ",@{$this->{sasl_mechanisms}}[0]);
$this->{_saslmech} = @{$this->{sasl_mechanisms}}[0];
}
return $this->_Authtype();
}
## parses the SASL <base64 encoded SASL string>\r\n, sent by the client.
## Sasl challenge/response from the client
sub _RSASL
{
my $this = shift;
my $ret;
if (!defined $this->{_sasl}) {
lib/Arc/Connection/Server.pm view on Meta::CPAN
return $this->_SetError("Client socket needed.") unless (@_ == 1);
my $client = shift;
# Fill the connected Socket into the select object
$this->{_connection} = $client;
$this->{_connected} = 1;
$this->{_select} = new IO::Select( $client );
my $line = $this->_RecvLine();
unless ($this->{_error}) {
if ($line =~ m/^ARC\/2.(0|1)\r?\n$/) { # Protocoltype 2
$this->{protocol} = $1;
$this->Log(LOG_USER,"Arc v2.$1 Session recognized.");
$this->_Auth();
my $cmd;
while ((!$this->{_error}) && ($cmd = $this->_RecvCommand())) {
last unless $this->_ProcessLine($cmd);
last if $cmd eq "QUIT";
}
lib/Arc/Connection/Server.pod view on Meta::CPAN
B<Returns:> true when succesful, otherwise false
B<Example:>
$this->_Auth();
=item _Authtype ( )
B<Description>: tell the client, which SASL mechanism is used.
Protocol command: AUTHTYPE <SASL mechansism>\r\n
B<Returns:> true when succesful, otherwise false
B<Example:>
$this->_Authtype();
=item _CBCanonUser ( )
B<Description>: Callback function to canonicalize the username (SASL)
see Authen::SASL(::Cyrus) for parameter list and how to use.
=item _CheckCmd ( )
lib/Arc/Server.pm view on Meta::CPAN
sub members
{
my $this = shift;
return { %{$this->SUPER::members},
# private:
__arc => undef, # stores the Arc::Connection::Server object for optimal PreFork
# protected:
# public:
connection_type => 'Arc::Connection::Server', # Class to use for connections
connection_vars => undef, # variables passed directly to every connection handle See C<Arc::Connection::Server>
logfileprefix => "mainserver", # Logfileprefix
# net::server
server => undef, # attributes for Net::Server::PreFork
};
}
sub _Init
lib/Arc/Server.pm view on Meta::CPAN
}
## start the server
## This function is used by the user to start the server and enter the main accept-loop.
## Only by calling the C<Interrupt> function this call can be aborted.
##out> return true if everything worked fine, otherwise false is returned and C<IsError> should be checked.
##eg> $arc->Start();
sub Start
{
my $this = shift;
my $ct = $this->{connection_type};
eval "require $ct";
croak "Please \"use $ct\" before calling Start(): $@" if $@;
$this->run();
return 1;
}
# Net::Server::* hooks and overrides
sub process_request
{
lib/Arc/Server.pm view on Meta::CPAN
{
my ($this,$loglevel,$msg) = @_;
$msg =~ s/[\n\r]//g;
$this->Log(LOG_SIDE,$msg);
1;
}
sub child_init_hook
{
my $this = shift;
my $ct = $this->{connection_type};
$this->{__arc} = new $ct (
%{$this->{connection_vars}},
);
}
# deleting STDIN and STDOUT kills ARCv2, don't know if Net::Server does
# is right
sub post_accept
{
my $this = shift;
lib/Arc/Server.pod view on Meta::CPAN
=head1 SYNOPSIS
Arc::Server - Class for the standalone server for ARCv2
my $arc = new Arc::Server(
port => [4242],
loglevel => 7,
logdestination => "stderr",
daemonize => 0,
connection_type => "Arc::Connection::Server",
connection_vars => {
loglevel => 7,
logdestination => 'syslog',
timeout => 30,
sasl_mechanisms => ["GSSAPI","KERBEROS_V4","PLAIN"],
sasl_cb_getsecret => &getsecret,
sasl_cb_checkpass => &checkpass,
commands => {
'whoami' => 'Arc::Command::Whoami,
'uptime' => 'Arc::Command::Uptime,
lib/Arc/Server.pod view on Meta::CPAN
die $m;
}
=head1 Class VARIABLES
=head3 PUBLIC MEMBERS
=over 2
=item connection_type
B<Description>: Class to use for connections
B<Default value>: 'Arc::Connection::Server'
=item connection_vars
B<Description>: variables passed directly to every connection handle See C<Arc::Connection::Server>
B<Default value>: undef
lib/arcx.pod view on Meta::CPAN
=item -v
The verbose option. If this option is set, arcx is verbose in its context. This option does not influence the ARCv2 object. Use -l and -L for it.
=item -n
Do nothing, only try to authenticate.
=item -F
Do not save the commands typed in the interactive mode in the history file.
=item -f <history>
Use the specified file to save command history.
=item -S <service>
This option sets the service name for SASL authentication. Default is "arc". This option has to be change on the server as well.
=item -u
scripts/arcx view on Meta::CPAN
[-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)
-r <string> use this string as stdin value for the command
-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
scripts/object.pl view on Meta::CPAN
return "private";
} elsif (/^_/) {
return "protected";
} else {
return "public";
}
}
sub issuperior
{
my ($type,$cname,$item,$acl) = @_;
my $text = "";
while ($cname = $iter{$cname}) {
if (eval '$'.$type.'{$cname}->{$acl}->{$item}') {
$ready{$item} = 1;
$text = "reimplemented from $cname";
last;
}
}
return $text;
}
sub showmembers
{