Navigation Menu

Skip to content

Commit

Permalink
Syslogging is optional, and protocol communication is more correct.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jan 29, 2002
1 parent 6bfe32b commit 8d612a2
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions IcculusFinger_daemon.pl
Expand Up @@ -26,6 +26,8 @@
# 2.0.1 : Fixed > and < conversion.
# MUCH better Lynx support (thanks, Chunky_Ks)
# Added an "embed" arg.
# changed \r and \n in protocol chatter to \015 and \012.
# Made syslogging optional.
#-----------------------------------------------------------------------------

# TODO: Let [img] tags nest inside [link] tags.
Expand Down Expand Up @@ -54,6 +56,10 @@
# URLs. "$url?user=$user&section=sectionname".
my $base_url = 'http://icculus.org/cgi-bin/finger/finger.pl';

# Set this to non-zero to log all finger requests via the standard Unix
# syslog facility (requires Sys::Syslog qw(:DEFAULT setlogsock) ...)
my $use_syslog = 1;

# Set $use_homedir to something nonzero if want to read planfiles from the
# standard Unix location ("/home/$user/.plan"). Note that this is a security
# hole, as it means that either IcculusFinger must run as root to insure
Expand Down Expand Up @@ -733,8 +739,8 @@ sub read_request {

for ($count = 0; $count < $max_request_size; $count++) {
$ch = getc(STDIN);
if ($ch ne "\r") {
last if (($ch eq '') or ($ch eq "\n"));
if ($ch ne "\015") {
last if (($ch eq '') or ($ch eq "\012"));
$retval .= $ch;
}
}
Expand All @@ -747,11 +753,13 @@ sub read_request {

my $query_string = read_request();

use Sys::Syslog qw(:DEFAULT setlogsock);
setlogsock("unix");
openlog("fingerd", "user") or die("Couldn't open syslog: $!\n");
syslog("info", "finger request: \"$query_string\"\n")
or die("Couldn't write to syslog: $!\n");
if ($use_syslog) {
use Sys::Syslog qw(:DEFAULT setlogsock);
setlogsock("unix");
openlog("fingerd", "user") or die("Couldn't open syslog: $!\n");
syslog("info", "finger request: \"$query_string\"\n")
or die("Couldn't write to syslog: $!\n");
}

my ($user, $args) = $query_string =~ /\A(.*?)(\?.*|\b)\Z/;
$user =~ tr/A-Z/a-z/ if defined $user;
Expand Down

0 comments on commit 8d612a2

Please sign in to comment.