rfc1413.c revision c49c786dc58938f915f20356d954ecec1de2d205
176N/A/* ==================================================================== 176N/A * The Apache Software License, Version 1.1 176N/A * Copyright (c) 2000-2001 The Apache Software Foundation. All rights 176N/A * Redistribution and use in source and binary forms, with or without 176N/A * modification, are permitted provided that the following conditions 176N/A * 1. Redistributions of source code must retain the above copyright 176N/A * notice, this list of conditions and the following disclaimer. 176N/A * 2. Redistributions in binary form must reproduce the above copyright 176N/A * notice, this list of conditions and the following disclaimer in 176N/A * the documentation and/or other materials provided with the 176N/A * 3. The end-user documentation included with the redistribution, 176N/A * if any, must include the following acknowledgment: 3813N/A * "This product includes software developed by the 176N/A * Alternately, this acknowledgment may appear in the software itself, 176N/A * if and wherever such third-party acknowledgments normally appear. 176N/A * 4. The names "Apache" and "Apache Software Foundation" must 176N/A * not be used to endorse or promote products derived from this 176N/A * software without prior written permission. For written 176N/A * permission, please contact apache@apache.org. 176N/A * 5. Products derived from this software may not be called "Apache", 176N/A * nor may "Apache" appear in their name, without prior written 176N/A * permission of the Apache Software Foundation. 176N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 176N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 176N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 176N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 3813N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3813N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3813N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 3813N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 3813N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 3813N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 3813N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2239N/A * ==================================================================== 2239N/A * This software consists of voluntary contributions made by many 2239N/A * individuals on behalf of the Apache Software Foundation. For more 1505N/A * information on the Apache Software Foundation, please see 1505N/A * Portions of this software are based upon public domain software 1505N/A * originally written at the National Center for Supercomputing Applications, 1505N/A * University of Illinois, Urbana-Champaign. 2239N/A/* TODO - put timeouts back in */ 2239N/A * rfc1413() speaks a common subset of the RFC 1413, AUTH, TAP and IDENT 2239N/A * protocols. The code queries an RFC 1413 etc. compatible daemon on a remote 2239N/A * host to look up the owner of a connection. The information should not be 2239N/A * used for authentication purposes. This routine intercepts alarm signals. 2239N/A * Diagnostics are reported through syslog(3). 2239N/A * Author: Wietse Venema, Eindhoven University of Technology, 2239N/A/* Some small additions for Apache --- ditch the "sccsid" var if 3856N/A * prototypes it defines on at least one system (SunlOSs) which has 3856N/A * them missing from the standard header files, and one minor change 2239N/A * below (extra parens around assign "if (foo = bar) ..." to shut up 2239N/A/* Rewritten by David Robinson */ 2239N/A/* maximum allowed length of userid */ 2239N/A/* rough limit on the amount of data we accept. */ 2239N/A /* This should not fail since we have a numeric address string 2239N/A "rfc1413: apr_sockaddr_info_get(%s) failed",
1505N/A /* This should not fail since we have a numeric address string 176N/A "rfc1413: apr_sockaddr_info_get(%s) failed",
176N/A "rfc1413: error creating query socket");
176N/A "rfc1413: error setting query socket timeout");
176N/A * Bind the local and remote ends of the query socket to the same 2239N/A * IP addresses as the connection under investigation. We go 2239N/A * through all this trouble because the local or remote system 2239N/A * might have more than one network address. The RFC1413 etc. 2239N/A * client sends only port numbers; the server takes the IP 2239N/A * addresses from the query socket. 2239N/A "rfc1413: Error binding query socket to local port");
176N/A * errors from connect usually imply the remote machine doesn't support 176N/A * the service; don't log such an error /* send query to server. Handle short write. */ "write: rfc1413: error sending request");
* Read response from server. - the response should be newline * terminated according to rfc - make sure it doesn't stomp its * Note that the strchr function below checks for \012 instead of '\n' * this allows it to work on both ASCII and EBCDIC machines. "read: rfc1413: error reading response");
/* Oops... we ran out of data before finding newline */ /* RFC1413_USERLEN = 512 */ * Strip trailing carriage return. It is part of the * protocol, not part of the data.