ARCv2

 view release on metacpan or  search on metacpan

lib/Arc.pm  view on Meta::CPAN

sub members
{
	return {
		# private:
		# protected:
			_error => undef, # contains the error message
			_syslog => 1,    # log to syslog or to STDERR
		# public:
			loglevel => 7,              # loglevel is combination of bits (1=AUTH,2=USER,4=ERR,8=CMDDEBUG,16=VERBSIDE,32=DEBUG) see _Log method
			logfileprefix => "",        # Prepended to every log entry
			logdestination => 'syslog', # Where should all the log output go to ('stderr','syslog')
	};
}

## Constructor. 
## Initializes the object and returns it blessed.
## For all sub classes, please override C<_Init> to check the 
## parameter which are passed to the C<new> function. This
## is necessary because you are not able to call the the new method of a
## parent class, when having a class name (new $class::SUPER::new, does not work.).
##in> %hash, key => val, ...

lib/Arc.pm  view on Meta::CPAN

	while (my ($key,$val) = each(%$members)) {
		$this->{$key} = exists($values{$key}) ? $values{$key} : $val;
		delete $values{$key};
	}

	croak("Ignored values at object-creation (this is probably not what you want): ",join(" ",keys (%values))) if keys %values;
	
	# loglevel
	$this->{loglevel} = 4 if not defined $this->{loglevel};

	$this->{_syslog} = ! (defined $this->{logdestination} && $this->{logdestination} eq "stderr");

	openlog("arcv2","cons,pid","user") if $this->{_syslog};
	
	1;
}

## Debug function.
## Logs messages with "DEBUG" 
##in> ... (message)
##out> always false

lib/Arc.pod  view on Meta::CPAN



=head1 Class VARIABLES

=head3 PUBLIC MEMBERS

=over 2

=item logdestination 

B<Description>: Where should all the log output go to ('stderr','syslog')

B<Default value>: 'syslog'

=item logfileprefix 

B<Description>: Prepended to every log entry

B<Default value>: ""

=item loglevel 

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

=item logfileprefix I<reimplemented from Arc>

B<Default value>: "command"

=back 

=over 2

=item logdestination I<inherited from Arc>

B<Description>: Where should all the log output go to ('stderr','syslog')

B<Default value>: 'syslog'

=item loglevel I<inherited from Arc>

B<Description>: loglevel is combination of bits (1=AUTH,2=USER,4=ERR,8=CMDDEBUG,16=VERBSIDE,32=DEBUG) see _Log method

B<Default value>: 7

=back 

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

B<Description>: timeout for all connections (ARCv2 and command) in seconds

B<Default value>: undef

=back 

=over 2

=item logdestination I<inherited from Arc>

B<Description>: Where should all the log output go to ('stderr','syslog')

B<Default value>: 'syslog'

=item logfileprefix I<inherited from Arc>

B<Description>: Prepended to every log entry

B<Default value>: ""

=item loglevel I<inherited from Arc>

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

use Arc::Connection;
use MIME::Base64; 

@Arc::Connection::Client::ISA = qw(Arc::Connection);

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.

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


=head1 SYNOPSIS

Arc::Connection::Client - Client class for ARCv2

 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;
 }

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



=head1 Class VARIABLES

=head3 PUBLIC MEMBERS

=over 2

=item logdestination I<reimplemented from Arc>

B<Default value>: "stderr"

=item logfileprefix I<reimplemented from Arc>

B<Default value>: "client"

=item port 

B<Description>: Port to connect to

B<Default value>: undef

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

B<Description>: timeout for all connections (ARCv2 and command) in seconds

B<Default value>: undef

=back 

=over 2

=item logdestination I<inherited from Arc>

B<Description>: Where should all the log output go to ('stderr','syslog')

B<Default value>: 'syslog'

=item loglevel I<inherited from Arc>

B<Description>: loglevel is combination of bits (1=AUTH,2=USER,4=ERR,8=CMDDEBUG,16=VERBSIDE,32=DEBUG) see _Log method

B<Default value>: 7

=back 

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

be used for working with the ARC server from the command line, resp. to start the
server.

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

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

B<Description>: attributes for Net::Server::PreFork

B<Default value>: undef

=back 

=over 2

=item logdestination I<inherited from Arc>

B<Description>: Where should all the log output go to ('stderr','syslog')

B<Default value>: 'syslog'

=item logfileprefix I<inherited from Arc>

B<Description>: Prepended to every log entry

B<Default value>: ""

=item loglevel I<inherited from Arc>

lib/arcx.pod  view on Meta::CPAN

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

The port, where the ARCv2 server is listening. If no -p option is given, arcx will use the one given at compile time ($Arc::DefaultPort).

=item -L <logdestination>

This option defines the log output destination. Possible values are "stderr" and "syslog". Default is "syslog". -L does not refer to the -v option and arcx.

=item -l <loglevel>

This option specifies the logging level of ARCv2. Default is 5, whereas 7 is the highest (DEBUG) and 1 is the lowest.

=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

lib/arcxd.pod  view on Meta::CPAN

Start the ARCv2 server. The server will listen on the DefaultPort and all local addresses.
It will read the configuration file, located in the ConfigPath. After successful listening, 
it will fork into the background.

=item arcxd -p 1234

Same as L<arcxd> but listens on port 1234.

=item arcxd -d 5

Stay in foreground and log messages to stderr.

=item arcxd -P arcxd.pid 

Let arcxd store the pid of the master process in arcxd.pid.

=back

=head1 USAGE

Some parameters can be supplied to this scripts. The most of them come from the configuration file.

lib/arcxd.pod  view on Meta::CPAN

The scheme looks like this:

arcxd [-d <loglevel>] [-p <port>] [-F <config file>] [-v]

=head2 Parameter

=over 4

=item -d <loglevel>

Let the server put its log output to "stderr" and set the log level to <loglevel>. Also tells the server to do not fork into the background.

=item -p <port>

On which port the server shall listen on. (override the one from the configuration file and the default port). Change this for testing purposes.

=item -P <pid_file>

Where should the Net::Server store the PID of the master process.

=item -F <config file>

lib/arcxd.pod  view on Meta::CPAN

=head2 logging

=over 4

=item loglevel

This option specifies the login level of ARCv2. Default is 5, whereas 7 is the highest (DEBUG) and 1 is the lowest.

=item destination

This option defines the log output destination. Possible values are "stderr" and "syslog". 

=back

=head1 SEE ALSO

L<Arc>, L<Arc::Command>, L<Arc::Connection>, 
L<Arc::Connection::Server>, L<Arc::Connection::Client>,
L<arcx>, L<arcxd>, L<Authen::SASL>, L<Authen::SASL::Cyrus>
L<Net::Server::PreFork>

scripts/arcx  view on Meta::CPAN

$SIG{TERM} = \&interrupt;
$SIG{HUP} = \&interrupt;

getopts("01S:l:nh:s:p:L:r:t:vaA:uU:wW:f:FC:V",\%args) || usage("Wrong parameter construction.");

usage() if $args{V};

usage("Timeout value must be numeric.") if (defined $args{t} && $args{t} !~ /^\d+$/);
usage("If using -r, a string must be appended.") if (defined $args{r} && length($args{r}) == 0);
usage("Port must be a number correct number.") if (defined $args{p} && $args{p} != 1 && $args{p} !~ /^\d+$/);
usage("Logging destination not chosen correctly.") if (defined $args{L} && ($args{L} ne "syslog" && $args{L} ne "stderr"));

$args{t} = defined $args{t} ? $args{t} : undef;
$args{l} = defined $args{l} ? $args{l} : 0;
$args{L} = defined $args{L} ? $args{L} : 'stderr';
$args{S} = defined $args{S} ? $args{S} : 'arc';
$args{f} = defined $args{f} && $args{f} ne "" ? $args{f} : $ENV{HOME}.'/.archistory';
$args{C} = defined $args{C} && $args{C} ne "" ? $args{C} : $Arc::ConfigPath.'/arcx.conf';

my $intact = !@ARGV;
my $stop = 0;

my @server_list;

if ($args{h}) {

scripts/arcx  view on Meta::CPAN

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

	exit 1;
}


scripts/arcxd  view on Meta::CPAN

getopts("d:F:p:vP:",\%args) || usage("Wrong parameter construction.");

$args{F} = $Arc::ConfigPath."/arcxd.conf" unless $args{F};
usage("Configuration file ($args{F}) not found.") unless -e $args{F};

my $cf;
(print @Config::IniFiles::errors or exit 1) unless $cf = new Config::IniFiles(-file => $args{F});

my %log;
$log{loglevel} = $args{d} ? $args{d} : $cf->val("logging","level",7);
$log{logdestination} = $args{d} ? 'stderr' :$cf->val("logging","destination",'syslog');

my %def;
$def{server} = {};

my $prop = $def{server};
$prop->{port} = [split(/,/,$args{p} ? $args{p} : $cf->val("arcd","port",$Arc::DefaultPort))];
$prop->{host} = $cf->val("arcd","host",0);

$prop->{max_requests} = $cf->val("arcd","max_requests");
$prop->{min_servers} = $cf->val("arcd","min_servers");

t/arc1.t  view on Meta::CPAN

my $user = "mannfred";
my $pass = "klaus";

if ($pid == 0) { # Child
	
	use Arc::Server;
	use Arc::Connection::Server;

	my $server = new Arc::Server (
				loglevel => 0,
				logdestination => 'stderr',
				server => {
					port => [30001], # Testport
					host => "localhost", 
				},
				connection_vars => {
					loglevel => 0,
					logdestination => 'stderr',
					sasl_mechanisms => ['PLAIN'],
					sasl_cb_checkpass => \&checkpass,
					sasl_cb_getsecret => \&getsecret,
					service => "arc",
					commands => { 
						test => 'Arc::Command::Test',
						whoami => 'Arc::Command::Whoami',
						uptime => 'Arc::Command::Uptime',
					}
				}

t/arc1.t  view on Meta::CPAN

} elsif ($pid) { # Parent
	use Arc::Connection::Client;
	ok(1); #1
	
	sleep(3); # Wait for the server to get ready

	my $client = new Arc::Connection::Client (
				server => "localhost",
				port => 30001, # Testport
				loglevel => 0,
				logdestination => 'stderr',
				service => 'arc',
				sasl_mechanism => "PLAIN",
				sasl_cb_user => $user,
				sasl_cb_auth => $user,
				sasl_cb_pass => $pass,
	) or ok(0);
	ok(1); #2

	my $s; 
	if ($client->StartSession()) { ok(1); } else { ok(0); } #3



( run in 1.509 second using v1.01-cache-2.11-cpan-49f99fa48dc )