/usr/lib/interchange/src/vlink.pl is in interchange 5.7.7-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | #!/usr/bin/perl -wT
# vlink.pl: runs as a cgi program and passes request to Interchange server
# via a UNIX socket
# $Id: vlink.pl,v 2.6 2008-11-12 04:15:22 jon Exp $
#
# Copyright (C) 2005-2008 Interchange Development Group, http://www.icdevgroup.org/
# Copyright (C) 1996-2002 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301 USA.
require 5.008_005;
use strict;
use Socket;
my $LINK_FILE = '~@~INSTALLARCHLIB~@~/etc/socket';
#my $LINK_FILE = '~_~LINK_FILE~_~';
my $LINK_TIMEOUT = 30;
#my $LINK_TIMEOUT = ~_~LINK_TIMEOUT~_~;
my $ERROR_ACTION = "-notify";
$ENV{PATH} = "/bin:/usr/bin";
$ENV{IFS} = " ";
# Return this message to the browser when the server is not running.
# Log an error log entry if set to notify
sub server_not_running {
my $msg;
if($ERROR_ACTION =~ /not/i) {
warn "ALERT: Interchange server not running for $ENV{SCRIPT_NAME}\n";
}
$| = 1;
print <<EOF;
Content-type: text/html
<HTML><HEAD><TITLE>Interchange server not running</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF">
<H3>We're sorry, the Interchange server is unavailable...</H3>
<P>
We are out of service or may be experiencing high system demand.
Please try again soon.
</BODY></HTML>
EOF
}
# Return this message to the browser when a system error occurs.
#
sub die_page {
printf("Content-type: text/plain\r\n\r\n");
printf("We are sorry, but the Interchange server is unavailable due to a\r\n");
printf("system error.\r\n\r\n");
printf("%s: %s (%d)\r\n", $_[0], $!, $?);
if($ERROR_ACTION =~ /not/i) {
warn "ALERT: Interchange $ENV{SCRIPT_NAME} $_[0]: $! ($?)\n";
}
exit(1);
}
my $Entity = '';
# Read the entity from stdin if present.
sub get_entity {
return '' unless defined $ENV{CONTENT_LENGTH};
my $len = $ENV{CONTENT_LENGTH} || 0;
return '' unless $len;
my $check;
# Can't hurt, helps Windows people
binmode(STDIN);
$check = read(STDIN, $Entity, $len);
die_page("Entity wrong length")
unless $check == $len;
$Entity;
}
sub send_arguments {
my $count = @ARGV;
my $val = "arg $count\n";
for(@ARGV) {
$val .= length($_);
$val .= " $_\n";
}
return $val;
}
sub send_environment () {
my (@tmp) = keys %ENV;
my $count = @tmp;
my ($str);
my $val = "env $count\n";
for(@tmp) {
$str = "$_=$ENV{$_}";
$val .= length($str);
$val .= " $str\n";
}
return $val;
}
sub send_entity {
return '' unless defined $ENV{CONTENT_LENGTH};
my $len = $ENV{CONTENT_LENGTH} || 0;
return '' unless $len > 0;
my $val = "entity\n";
$val .= "$len $Entity\n";
return $val;
}
$SIG{PIPE} = sub { die_page("signal"); };
$SIG{ALRM} = sub { server_not_running(); exit 1; };
eval { alarm $LINK_TIMEOUT; };
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) or die "socket: $!\n";
my $ok;
do {
$ok = connect(SOCK, sockaddr_un($LINK_FILE));
} while ( ! defined $ok and $! =~ /interrupt|such file or dir/i);
my $def = defined $ok;
die "ok=$ok def: $def connect: $!\n" if ! $ok;
get_entity();
select SOCK;
$| = 1;
select STDOUT;
print SOCK send_arguments();
print SOCK send_environment();
print SOCK send_entity();
print SOCK "end\n";
while(<SOCK>) {
print;
}
close (SOCK) or die "close: $!\n";
exit;
|