Net-Server
view release on metacpan or search on metacpan
- Correct test for POSIX::setuid(0) success (Peter Chen)
- Allow DOS filenames for conf files (Mark M. Adkins)
- Allow for ndelay on Sys::Syslog::openlog (Doug Perham)
- Add documentation about run_dequeue.
- Add run_dequeue feature to Multiplex personality.
0.84 May 22 08:00 2002
- Safer peername check in get_client_info to
avoid crashing under certain conditions.
- Create noarch RPM since Net::Server is pure perl.
- Always chown log and pid files when started as root
but running as non-root.
- More graceful exit of children in PreFork
- Kill children with a kill 15 rather than kill 2 -
Fixes on Tru64 UNIX (Marco Sbodio)
- Allow for SOCK_STREAM and SOCK_DGRAM to be passed
as strings to proto (ie "/tmp/path/|SOCK_STREAM|unix") (Andrzej Filip)
- Backward compatibility fix for IO::Socket usage (Matt Sergeant)
- Avoid reopening STDIN and STDOUT in INET mode. (Bernard Quatermass)
- Beginning work on Safe signals
- Net::Server::Fork is on safe signals.
- Added Net::Server::SIG
- Added examples/sigtest.pl
0.71 Aug 17 15:51 2001
- Die on failed change to another user or group.
WARNING: No longer defaults to nobody.nobody.
Defaults to currently running user and group.
- Various cleanups with file removal.
- All files to be removed are now chowned.
0.70 Aug 17 10:34 2001
- Added support for different protocols to Net::Server.
This implemented via Net::Server::Proto and its classes.
Included Net::Server::Proto::TCP,
Net::Server::Proto::UDP,
Net::Server::Proto::UNIX,
and experimental Net::Server::Proto::SSL.
TCP, UDP, and UNIX are fully tested.
lib/Net/Server.pm view on Meta::CPAN
$self->fatal("Unable to load log module $pkg from file $file: $@");
}
}
# regular file based logging
croak "Unsecure filename \"$prop->{'log_file'}\"" if $prop->{'log_file'} !~ m|^([\:\w\.\-/\\]+)$|;
$prop->{'log_file'} = $1; # open a logging file
open(_SERVER_LOG, ">>", $prop->{'log_file'})
|| croak "Couldn't open log file \"$prop->{'log_file'}\" [$!]";
_SERVER_LOG->autoflush(1);
push @{ $prop->{'chown_files'} }, $prop->{'log_file'};
}
sub post_configure_hook {}
sub _server_type { ref($_[0]) }
sub pre_bind { # make sure we have good port parameters
my $self = shift;
my $prop = $self->{'server'};
lib/Net/Server.pm view on Meta::CPAN
if (! defined $prop->{'user'}) {
$self->log(1, "User Not Defined. Defaulting to EUID '$>'");
$prop->{'user'} = $>;
} elsif ($prop->{'user'} =~ /^([\w.-]+)$/) {
$prop->{'user'} = eval { get_uid($1) };
$self->fatal(my $e = $@) if $@;
} else {
$self->fatal("Invalid user \"$prop->{'user'}\"");
}
# chown any files or sockets that we need to
if ($prop->{'group'} ne $) || $prop->{'user'} ne $>) {
my @chown_files;
push @chown_files, map {$_->NS_port} grep {$_->NS_proto =~ /^UNIX/} @{ $prop->{'sock'} };
push @chown_files, $prop->{'pid_file'} if $prop->{'pid_file_unlink'};
push @chown_files, $prop->{'lock_file'} if $prop->{'lock_file_unlink'};
push @chown_files, @{ $prop->{'chown_files'} || [] };
my $uid = $prop->{'user'};
my $gid = (split /\ /, $prop->{'group'})[0];
foreach my $file (@chown_files){
chown($uid, $gid, $file) || $self->fatal("Couldn't chown \"$file\" [$!]");
}
}
if ($prop->{'chroot'}) {
$self->fatal("Specified chroot \"$prop->{'chroot'}\" doesn't exist.") if ! -d $prop->{'chroot'};
$self->log(2, "Chrooting to $prop->{'chroot'}");
chroot($prop->{'chroot'}) || $self->fatal("Couldn't chroot to \"$prop->{'chroot'}\": $!");
}
# drop privileges
lib/Net/Server/Daemonize.pm view on Meta::CPAN
my $uid = get_uid($user);
my $gid = get_gid($group); # returns list of groups
$gid = (split /[\s,]+/, $gid)[0];
my $pid = safe_fork();
exit(0) if $pid; # exit parent
# child
create_pid_file($pid_file) if defined $pid_file;
chown($uid, $gid, $pid_file) if defined $pid_file;
set_user($uid, $gid);
open STDIN, '<', '/dev/null' or die "Can't open STDIN from /dev/null: [$!]\n";
open STDOUT, '>', '/dev/null' or die "Can't open STDOUT to /dev/null: [$!]\n";
open STDERR, '>&STDOUT' or die "Can't open STDERR to STDOUT: [$!]\n";
### does this mean to be chroot ?
chdir '/' or croak "Can't chdir to \"/\": [$!]";
lib/Net/Server/HTTP.pm view on Meta::CPAN
}
} elsif ($log eq 'STDOUT' || $log eq '/dev/stdout') {
open my $fh, '>&', \*STDOUT or die "Could not dup STDOUT: $!";
$fh->autoflush(1);
$prop->{'access_log_function'} = sub { print $fh @_,"\n" };
} elsif ($log eq 'STDERR' || $log eq '/dev/stderr') {
$prop->{'access_log_function'} = sub { print STDERR @_,"\n" };
} else {
open my $fh, '>>', $log or die "Could not open access_log_file \"$log\": $!";
$fh->autoflush(1);
push @{ $prop->{'chown_files'} }, $log;
$prop->{'access_log_function'} = sub { print $fh @_,"\n" };
}
}
sub _tie_client_stdout {
my $self = shift;
my $prop = $self->{'server'};
# install a callback that will handle our outbound header negotiation for the clients similar to what apache does for us
my $copy = $self;
lib/Net/Server/Proto/UNIX.pm view on Meta::CPAN
=head1 SYNOPSIS
See L<Net::Server::Proto>.
=head1 DESCRIPTION
Protocol module for Net::Server. This module implements the UNIX
SOCK_STREAM socket type. See L<Net::Server::Proto>.
Any sockets created during startup will be chown'ed to the user and
group specified in the startup arguments.
=head1 PARAMETERS
The following parameters may be specified in addition to normal
command line parameters for a Net::Server. See L<Net::Server> for
more information on reading arguments.
=over 4
lib/Net/Server/Proto/UNIXDGRAM.pm view on Meta::CPAN
=head1 SYNOPSIS
See L<Net::Server::Proto>.
=head1 DESCRIPTION
Protocol module for Net::Server. This module implements the UNIX
SOCK_DGRAM socket type. See L<Net::Server::Proto>.
Any sockets created during startup will be chown'ed to the user and
group specified in the startup arguments.
=head1 PARAMETERS
The following parameters may be specified in addition to normal
command line parameters for a Net::Server. See L<Net::Server> for
more information on reading arguments.
=over 4
( run in 0.534 second using v1.01-cache-2.11-cpan-92ad3014f07 )