Commit 88207f4f authored by 's avatar

Merged patch back-out from 2.2 branch

parent 9716152b
...@@ -1015,7 +1015,7 @@ EOF ...@@ -1015,7 +1015,7 @@ EOF
fi fi
for ac_hdr in unistd.h syslog.h for ac_hdr in unistd.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
...@@ -1288,6 +1288,7 @@ else ...@@ -1288,6 +1288,7 @@ else
fi fi
rm -f conftest* rm -f conftest*
trap '' 1 2 15 trap '' 1 2 15
cat > confcache <<\EOF cat > confcache <<\EOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
......
...@@ -48,7 +48,7 @@ fi ...@@ -48,7 +48,7 @@ fi
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(unistd.h syslog.h) AC_CHECK_HEADERS(unistd.h)
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST AC_C_CONST
......
...@@ -55,77 +55,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -55,77 +55,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
char spewbuf[1024]; /* yes, it's a global, but only for debugging */ char spewbuf[1024]; /* yes, it's a global, but only for debugging */
#endif #endif
typedef struct { static char _id_[]="$Id: pcgi-wrapper.c,v 1.9 2000/08/01 15:59:44 brian Exp $";
char *t_name;
int t_val;
} TRANS;
#ifdef HAVE_SYSLOG_H
static const TRANS facilities[] = {
{"auth", LOG_AUTH},
#ifdef LOG_AUTHPRIV
{"authpriv",LOG_AUTHPRIV},
#endif
#ifdef LOG_CRON
{"cron", LOG_CRON},
#endif
#ifdef LOG_DAEMON
{"daemon", LOG_DAEMON},
#endif
#ifdef LOG_FTP
{"ftp", LOG_FTP},
#endif
#ifdef LOG_KERN
{"kern", LOG_KERN},
#endif
#ifdef LOG_LPR
{"lpr", LOG_LPR},
#endif
#ifdef LOG_MAIL
{"mail", LOG_MAIL},
#endif
#ifdef LOG_NEWS
{"news", LOG_NEWS},
#endif
#ifdef LOG_SYSLOG
{"syslog", LOG_SYSLOG},
#endif
#ifdef LOG_USER
{"user", LOG_USER},
#endif
#ifdef LOG_UUCP
{"uucp", LOG_UUCP},
#endif
#ifdef LOG_LOCAL0
{"local0", LOG_LOCAL0},
#endif
#ifdef LOG_LOCAL1
{"local1", LOG_LOCAL1},
#endif
#ifdef LOG_LOCAL2
{"local2", LOG_LOCAL2},
#endif
#ifdef LOG_LOCAL3
{"local3", LOG_LOCAL3},
#endif
#ifdef LOG_LOCAL4
{"local4", LOG_LOCAL4},
#endif
#ifdef LOG_LOCAL5
{"local5", LOG_LOCAL5},
#endif
#ifdef LOG_LOCAL6
{"local6", LOG_LOCAL6},
#endif
#ifdef LOG_LOCAL7
{"local7", LOG_LOCAL7},
#endif
{NULL, -1},
};
#endif
static char _id_[]="$Id: pcgi-wrapper.c,v 1.8 2000/06/02 15:54:20 brian Exp $";
/* Globals, OR: "I'll know I'll hate myself in the morning" */ /* Globals, OR: "I'll know I'll hate myself in the morning" */
extern char **environ; extern char **environ;
...@@ -248,15 +178,6 @@ int main(int argc, char *argv[]) ...@@ -248,15 +178,6 @@ int main(int argc, char *argv[])
*/ */
if ((r->conn = pcgiConnect(r)) < 0) if ((r->conn = pcgiConnect(r)) < 0)
{ {
if (!r->errmsg[0])
{
strcpy(r->errmsg, ERR102_FAILURE_DURING_CONNECT);
sprintf(r->explain, WHY102_FAILURE_DURING_CONNECT,
r->sockpath);
}
onError(E_503, strerror(errno), r);
/*
if(pcgiVerifyProc(r) < 0) if(pcgiVerifyProc(r) < 0)
{ {
if(pcgiStartProc(r) < 0) if(pcgiStartProc(r) < 0)
...@@ -278,7 +199,6 @@ int main(int argc, char *argv[]) ...@@ -278,7 +199,6 @@ int main(int argc, char *argv[])
strcpy(r->errmsg, ERR103_UNABLE_VERIFY_RUNNING); strcpy(r->errmsg, ERR103_UNABLE_VERIFY_RUNNING);
onError(E_503, "pcgiVerifyProc failed", r); onError(E_503, "pcgiVerifyProc failed", r);
} }
*/
} }
/* /*
...@@ -456,48 +376,6 @@ shutdown(r->conn, 1); /* shutdown the socket so we can receive */ ...@@ -456,48 +376,6 @@ shutdown(r->conn, 1); /* shutdown the socket so we can receive */
} }
#endif /* end of main(): PCGI_WRAPPER_MAIN */ #endif /* end of main(): PCGI_WRAPPER_MAIN */
/*
// logMessage: output a message to the PCGI log
*/
void logMessage(char *msg, pcgiResource *r, int level)
{
FILE *f;
time_t now;
char *fname;
if (r->errlog[0])
{
#ifdef HAVE_SYSLOG_H
if (!strncasecmp(r->errlog, "syslog", 6))
{
if ((fname = strchr(r->errlog, ':')))
{
const TRANS *fac;
fname++;
for (fac = facilities; fac->t_name; fac++)
{
if (!strcasecmp(fname, fac->t_name))
{
openlog("pcgi-wrapper", LOG_NDELAY|LOG_CONS|LOG_PID, fac->t_val);
}
}
}
now = time(NULL);
syslog(level, "(%s): %s\n", r->sw_info, msg);
return;
}
#endif
if((f=fopen(r->errlog, "ab")) != NULL)
{
now = time(NULL);
fprintf(f, "%s pcgi-wrapper(%s): %s\n",
ctime(&now), r->sw_info, msg);
fclose(f);
}
}
}
/* /*
// onError: fatal pcgi error // onError: fatal pcgi error
*/ */
...@@ -512,9 +390,7 @@ void onError(char *estatus, char *emsg, pcgiResource *r) ...@@ -512,9 +390,7 @@ void onError(char *estatus, char *emsg, pcgiResource *r)
#else #else
char *pcgi_version = ""; char *pcgi_version = "";
#endif #endif
char displayError[MAXSZ] = ""; char *displayError = "";
char explainError[MAXSZ] = "";
char msgbuf[MAXSZ];
if (r != NULL) if (r != NULL)
{ {
...@@ -530,26 +406,23 @@ void onError(char *estatus, char *emsg, pcgiResource *r) ...@@ -530,26 +406,23 @@ void onError(char *estatus, char *emsg, pcgiResource *r)
WSACleanup(); WSACleanup();
} }
#endif #endif
sprintf(msgbuf, "%s %s\n", emsg, r->errmsg); if (r->errlog[0])
logMessage(msgbuf, r, LOG_ERR); {
if((f=fopen(r->errlog, "ab")) != NULL)
{
now = time(NULL);
fprintf(f, "%s pcgi-wrapper: %s %s\n",
ctime(&now), emsg, r->errmsg);
fclose(f);
}
}
if(r->p_env!=NULL) free(r->p_env); if(r->p_env!=NULL) free(r->p_env);
if(r->p_input!=NULL) free(r->p_input); if(r->p_input!=NULL) free(r->p_input);
} }
if (r->displayErrors) if (r->displayErrors)
{ displayError = r->errmsg;
sprintf(displayError, "%s<P WIDTH=\"50%%\">%s</P>\n%s<P WIDTH=\"50%%\">%s</P>\n", printf(errorHtml, estatus, displayError, emsg, pcgi_version);
"<H2>C-Runtime errno:</H2>\n", emsg,
"<H2>PCGI Error:</H2>\n", r->errmsg);
sprintf(explainError, "<H2>Explanation:</H2>\n%s", r->explain);
}
printf(errorHtml, estatus, displayError, explainError, emsg, pcgi_version,
"PCGI_INFO_FILE=", r->sw_info,
"PCGI_PID_FILE=", r->procpath,
"PCGI_SOCKET_FILE=", r->sockpath,
"PCGI_PORT=", r->sockport
);
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
...@@ -707,7 +580,7 @@ pcgi_socket pcgiConnect(pcgiResource *r) ...@@ -707,7 +580,7 @@ pcgi_socket pcgiConnect(pcgiResource *r)
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{ {
if (!r->errmsg[0]) if (!r->errmsg[0])
sprintf(r->errmsg, "%s, path=%s", ERR114_UNABLE_TO_OPEN_SOCKET, s.sun_path); strcpy(r->errmsg, ERR114_UNABLE_TO_OPEN_SOCKET);
return (-1); return (-1);
} }
while ((connected < 0) && (attempted <= retry)) while ((connected < 0) && (attempted <= retry))
...@@ -717,7 +590,7 @@ pcgi_socket pcgiConnect(pcgiResource *r) ...@@ -717,7 +590,7 @@ pcgi_socket pcgiConnect(pcgiResource *r)
if((errno!=ECONNREFUSED) && (errno!=ENOENT)) if((errno!=ECONNREFUSED) && (errno!=ENOENT))
{ {
if (!r->errmsg[0]) if (!r->errmsg[0])
sprintf(r->errmsg, "%s, path=%s", ERR115_CONNECTION_REFUSED, s.sun_path); strcpy(r->errmsg, ERR115_CONNECTION_REFUSED);
return(-1); return(-1);
} }
sleep(delay); sleep(delay);
...@@ -726,16 +599,8 @@ pcgi_socket pcgiConnect(pcgiResource *r) ...@@ -726,16 +599,8 @@ pcgi_socket pcgiConnect(pcgiResource *r)
} }
if (!(connected < 0)) if (!(connected < 0))
{ {
if (attempted > 0 && attempted <= retry)
{ /* Got thru to server but took several tries... */
char msgbuf[MAXSZ];
sprintf(msgbuf, "connect to zserver took %d attempts", attempted);
logMessage(msgbuf, r, LOG_WARNING);
}
if (!r->errmsg[0]) if (!r->errmsg[0])
sprintf(r->errmsg, "%s, path=%s, fd=%d", ERR116_UNABLE_TO_CONNECT, s.sun_path, fd); sprintf(r->errmsg, "%s, fd=%d", ERR116_UNABLE_TO_CONNECT, fd);
return (fd); return (fd);
} }
return (connected); return (connected);
......
...@@ -70,10 +70,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -70,10 +70,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#define MAXLINEBUFFER 12 #define MAXLINEBUFFER 12
#define PATHSEP_UNIX '/' #define PATHSEP_UNIX '/'
#define PATHSEP_WIN32 '\\' #define PATHSEP_WIN32 '\\'
...@@ -125,7 +121,7 @@ typedef SOCKET pcgi_socket; ...@@ -125,7 +121,7 @@ typedef SOCKET pcgi_socket;
#define E_503 "503 Service Unavailable" #define E_503 "503 Service Unavailable"
#define ERR101_FAILURE_DURING_START "(101) failure during start" #define ERR101_FAILURE_DURING_START "(101) failure during start"
#define ERR102_FAILURE_DURING_CONNECT "(102) failure during connect to ZServer" #define ERR102_FAILURE_DURING_CONNECT "(102) failure during connect"
#define ERR103_UNABLE_VERIFY_RUNNING "(103) unable to verify if process is running" #define ERR103_UNABLE_VERIFY_RUNNING "(103) unable to verify if process is running"
#define ERR104_ENVIRONMENT_SEND "(104) environment send" #define ERR104_ENVIRONMENT_SEND "(104) environment send"
#define ERR105_STDIN_SEND "(105) stdin send" #define ERR105_STDIN_SEND "(105) stdin send"
...@@ -166,7 +162,6 @@ typedef struct resource_tag ...@@ -166,7 +162,6 @@ typedef struct resource_tag
char modpath [MAXSZ]; /* module path */ char modpath [MAXSZ]; /* module path */
char errmsg [MAXSZ]; /* last error, brief message */ char errmsg [MAXSZ]; /* last error, brief message */
char errlog [MAXSZ]; /* fully qualified path to error log file */ char errlog [MAXSZ]; /* fully qualified path to error log file */
char explain [MAXSZ*2]; /* explanation of errors (optionally present) */
char insertPath [MAXPATH]; /* insert path by publisher */ char insertPath [MAXPATH]; /* insert path by publisher */
char pythonPath [MAXPATH]; /* PYTHONPATH, if provided */ char pythonPath [MAXPATH]; /* PYTHONPATH, if provided */
short displayErrors; /* displayErrors = 0,1 */ short displayErrors; /* displayErrors = 0,1 */
...@@ -183,11 +178,6 @@ typedef struct resource_tag ...@@ -183,11 +178,6 @@ typedef struct resource_tag
int lock; int lock;
} pcgiResource; } pcgiResource;
#define WHY102_FAILURE_DURING_CONNECT \
"The PCGI-wrapper program, spawned by Apache to handle the HTTP\n" \
"request via the standard CGI protocol, is unable to connect to\n" \
"the ZServer background process via Unix socket %s."
static char errorHtml[]= static char errorHtml[]=
"Status: %s\n" "Status: %s\n"
"Content-Type: text/html\n" "Content-Type: text/html\n"
...@@ -210,12 +200,11 @@ static char errorHtml[]= ...@@ -210,12 +200,11 @@ static char errorHtml[]=
" <P>\n" " <P>\n"
" The resource you requested is temporarily unavailable - " " The resource you requested is temporarily unavailable - "
"please try again later.\n" "please try again later.\n"
" </P></TD>\n" " </TD>\n"
"</TR>\n" "</TR>\n"
"</TABLE>\n" "</TABLE>\n"
"%s</P>\n" "%s\n"
"<P WIDTH=\"50%%\">%s</P>\n" "<!--\n%s\n%s\n-->\n"
"<!--\n%s\n%s\n\n%s%s\n%s%s\n%s%s\n%s%s\n-->\n"
"</BODY></HTML>"; "</BODY></HTML>";
/* To ensure backward compatibility with pcgi info files, */ /* To ensure backward compatibility with pcgi info files, */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment