You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tony Sanders <sa...@bsdi.com> on 1995/12/13 21:05:23 UTC

Re: UnixWare 2.x patch

Chuck Murcko writes:
> Here's a patch to get Apache compiled on UnixWare 2.x. Like Ben and
> others have said in the past, rfc931.c needs to get rewritten, so I have
> opted not to touch conf.h, only Configuration and rfc931.c. I would
> recommend considering this a temporary measure, pending rewrite of
> rfc931.c.

Here is my rewrite of rfc931.c -- enjoy.

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1995-12-13 13:04 MST by <sa...@forge.BSDI.COM>.
# Source directory was `/usr/src/contrib/apache/src'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#   6337 -rw-rw-r-- rfc931.c
#    360 -rw-rw-r-- rfc931.h
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  echo 'WARNING: not restoring timestamps.  Consider getting and'
  echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
/usr/contrib/bin/shar: # ============= rfc931.c ==============
if test -f 'rfc931.c' && test X"$1" != X"-c"; then
  echo 'x - skipping rfc931.c (file already exists)'
else
  echo 'x - extracting rfc931.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'rfc931.c' &&
/*	BSDI	$Id: rfc931.c,v 1.2 1995/12/06 04:25:14 sanders Exp $ */
X
/* ====================================================================
X * Copyright (c) 1995 The Apache Group.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X *
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer. 
X *
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in
X *    the documentation and/or other materials provided with the
X *    distribution.
X *
X * 3. All advertising materials mentioning features or use of this
X *    software must display the following acknowledgment:
X *    "This product includes software developed by the Apache Group
X *    for use in the Apache HTTP server project (http://www.apache.org/)."
X *
X * 4. The names "Apache Server" and "Apache Group" must not be used to
X *    endorse or promote products derived from this software without
X *    prior written permission.
X *
X * 5. Redistributions of any form whatsoever must retain the following
X *    acknowledgment:
X *    "This product includes software developed by the Apache Group
X *    for use in the Apache HTTP server project (http://www.apache.org/)."
X *
X * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
X * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
X * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
X * IT'S CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
X * SPECIAL, EXEMPLARY,Saving rfc931.c (text)
/usr/contrib/bin/shar: Saving rfc931.h (text)
 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
X * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
X * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
X * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
X * OF THE POSSIBILITY OF SUCH DAMAGE.
X * ====================================================================
X *
X * This software consists of voluntary contributions made by many
X * individuals on behalf of the Apache Group and was originally based
X * on public domain software written at the National Center for
X * Supercomputing Applications, University of Illinois, Urbana-Champaign.
X * For more information on the Apache Group and the Apache HTTP server
X * project, please see <http://www.apache.org/>.
X *
X */
X
/*
X * rfc931() speaks a common subset of the RFC 931, AUTH, TAP and IDENT
X * protocols. The code queries an RFC 931 etc. compatible daemon on a remote
X * host to look up the owner of a connection. The information should not be
X * used for authentication purposes. This routine intercepts alarm signals.
X * 
X * Author: Wietse Venema, Eindhoven University of Technology,
X * The Netherlands.
X * Modified: Tony Sanders <sa...@earth.com>, September 15, 1995
X */
X
#include "conf.h"
X
#ifdef NOTDEF			/* Has changed a lot since this... */
static char sccsid[] = "@(#) rfc931.c 1.8 93/12/13 22:23:20";
#endif
X
/* System libraries. */
X
#include <stdio.h>
#ifndef NEXT
#include <unistd.h>
#endif
#include <setjmp.h>
#include <signal.h>
#include <string.h>
#include <sys/param.h>
#include <sys/types.h>
#ifndef ULTRIX_BRAIN_DEATH
#include <sys/socket.h>
#endif
#include <netinet/in.h>
X
#define RFC931_TIMEOUT	500		/* default timeout (seconds) */
#define	RFC931_PORT	113		/* Semi-well-known port */
#define	RFC931_BUFLEN	512		/* must hold `%u , %u\r\n\0' */
X
int rfc931_timeout = RFC931_TIMEOUT;		/* exported symbol */
static char *rfc931_unknown = "unknown";	/* unknown result */
static jmp_buf rfc931_jmpbuf;			/* timeout handler */
X
/* timeout -- handles SIGALRM */
static void
alarm_timeout(int sig)
{
X    longjmp(rfc931_jmpbuf, sig);
}
X
/* rfc921 -- returns the remote user name */
char *
rfc931(struct sockaddr_in *remote_sin, struct sockaddr_in *local_sin)
{
X    int s;
X    struct sockaddr_in remote_query_sin;
X    struct sockaddr_in local_query_sin;
X    unsigned remote_port;
X    unsigned local_port;
X    char buffer[RFC931_BUFLEN];
X    char scanbuf[80];				/* small sscanf fmt string */
X    static char user[RFC931_BUFLEN];		/* XXX: static buffer */
X    char *result;
X
X    result = rfc931_unknown;
X
X    if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
X	return result;
X
X    /* Set up timer so we won't get stuck while waiting for the server */
X    if (setjmp(rfc931_jmpbuf) == 0) {
X	signal(SIGALRM, alarm_timeout);
X	alarm(rfc931_timeout);
X
X	/*
X	 * Bind the local and remote ends of the query socket to the same
X	 * IP addresses as the connection under investigation. We go
X	 * through all this trouble because the local or remote system
X	 * might have more than one network address. The RFC931 etc.
X	 * client sends only port numbers; the server takes the IP
X	 * addresses from the query socket.
X	 */
X
X	local_query_sin = *local_sin;
X	local_query_sin.sin_port = htons(0);
X	remote_query_sin = *remote_sin;
X	remote_query_sin.sin_port = htons(RFC931_PORT);
X
X	if (bind(s, (struct sockaddr *)&local_query_sin,
X		    sizeof(local_query_sin)) < 0)
X	    return result;
X
X        if (connect(s, (struct sockaddr *)&remote_query_sin,
X		    sizeof(local_query_sin)) < 0)
X	    return result;
X
X	/* Send query to server */
X	sprintf(buffer, "%u , %u\r\n",
X		ntohs(remote_sin->sin_port),
X		ntohs(local_sin->sin_port));
X	if (write(s, buffer, strlen(buffer)) == -1)
X	    return result;
X
X	/* Read response from server */
X	if (read(s, buffer, RFC931_BUFLEN-1) == -1)
X	    return result;
X
X	/* all done with network -- disable timeout alarm */
X	alarm(0);
X
X	/*
X	 * Return data format is:
X	 *     lport , rport : reply_type : opsys_or_error : identifier
X	 *
X	 * "%d , %d : %[^ \t\r\n:] : %[^\t\r\n:] : %[^\r\n]"
X	 */
X
X	sprintf(scanbuf, "%%u , %%u : USERID : %%*[^\t\r\n:] : %%%d[^\r\n]",
X	    RFC931_BUFLEN-1);
X	if (sscanf(buffer, scanbuf, &remote_port, &local_port, user) != 3)
X	    return result;
X
X	/* sanity check port numbers */
X	if ((ntohs(remote_sin->sin_port) != remote_port)
X		    || (ntohs(local_sin->sin_port) != local_port))
X	    return result;
X
X	result = user;
X    }
X
X    return result;
}
SHAR_EOF
  $shar_touch -am 1205212595 'rfc931.c' &&
  chmod 0664 'rfc931.c' ||
  echo 'restore of rfc931.c failed'
  shar_count="`wc -c < 'rfc931.c'`"
  test 6337 -eq "$shar_count" ||
    echo "rfc931.c: original size 6337, current size $shar_count"
fi
# ============= rfc931.h ==============
if test -f 'rfc931.h' && test X"$1" != X"-c"; then
  echo 'x - skipping rfc931.h (file already exists)'
else
  echo 'x - extracting rfc931.h (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'rfc931.h' &&
/*	BSDI	$Id: rfc931.h,v 1.1 1995/12/06 04:25:17 sanders Exp $ */
X
#ifndef _RFC931_H_
#define _RFC931_H_
X
/* interface notes: calls alarm(), sets SIGALRM handler */
X
#ifdef NO_EXTERN_ANSI_PROTOTYPES
X    extern char *rfc931();
#else
X    extern char *rfc931(struct sockaddr_in *, struct sockaddr_in *);
#endif
X
extern int rfc931_timeout;
X
#endif /* _RFC931_H_ */
SHAR_EOF
  $shar_touch -am 1205212595 'rfc931.h' &&
  chmod 0664 'rfc931.h' ||
  echo 'restore of rfc931.h failed'
  shar_count="`wc -c < 'rfc931.h'`"
  test 360 -eq "$shar_count" ||
    echo "rfc931.h: original size 360, current size $shar_count"
fi
exit 0