head 1.8;
access;
symbols;
locks; strict;
comment @ * @;
1.8
date 95.06.10.04.05.31; author p-pomes; state Exp;
branches;
next 1.7;
1.7
date 94.03.12.04.27.19; author paul; state Exp;
branches;
next 1.6;
1.6
date 94.03.11.23.14.20; author paul; state Exp;
branches;
next 1.5;
1.5
date 93.12.16.21.46.45; author paul; state Exp;
branches;
next 1.4;
1.4
date 93.11.24.22.33.04; author paul; state Exp;
branches;
next 1.3;
1.3
date 93.11.24.18.05.56; author paul; state Exp;
branches;
next 1.2;
1.2
date 93.07.22.13.49.22; author paul; state Exp;
branches;
next 1.1;
1.1
date 93.06.14.20.37.07; author paul; state Exp;
branches;
next ;
desc
@@
1.8
log
@Changed default service from ns to csnet-ns (RFC-1700).
@
text
@/*
* Copyright (c) 1985 Corporation for Research and Educational Networking
* Copyright (c) 1988 University of Illinois Board of Trustees, Steven
* Dorner, and Paul Pomes
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Corporation for
* Research and Educational Networking (CREN), the University of
* Illinois at Urbana, and their contributors.
* 4. Neither the name of CREN, the University nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE TRUSTEES AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
** OpenQi -- Connect to the Qi server
**
** Open socket connections to the Qi server.
**
** Parameters:
** Host - Name of server to contact
** To - pointer to stream descriptor
** From - pointer to stream descriptor
**
** Returns:
** 0 if successful
** -1 if any error
**
** Side Effects:
** Initializes global QiFields by calling GetFields()
** Reports error via syslog
*/
int
OpenQi (Host, To, From)
char *Host;
FILE **To, **From;
{
int sock; /* our socket */
struct sockaddr_in Qi; /* the address of the nameserver */
struct servent *Ns; /* nameserver service entry */
struct hostent *hp; /* host entry for nameserver */
if (QiDebug)
fprintf(stderr, "contacting qi on %s\r\n", Host);
/* Locate the proper port */
if (Ns = getservbyname (NSSERVICE, "tcp"))
Qi.sin_port = Ns->s_port;
else {
if (QiDebug)
fprintf(stderr, "OpenQi: service \"%s\" unknown - using 105\r\n",
NSSERVICE);
syslog(LOG_ERR, "OpenQi: service \"%s\" unknown - using 105",
NSSERVICE);
Qi.sin_port = htons((unsigned short) 105);
}
Qi.sin_family = AF_INET;
/* Get a socket for the Qi connection */
if (geteuid() == 0) { /* if running as root, get a reserved port */
int localport = IPPORT_RESERVED - 1;
if ((sock = rresvport(&localport)) < 0) {
syslog(LOG_ERR, "OpenQI: rresvport(): %m");
return(-1);
}
} else if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
if (QiDebug)
fprintf(stderr, "OpenQi: socket(): %s\r\n", sys_errlist[errno]);
syslog(LOG_ERR, "OpenQi: socket(): %m");
return(-1);
}
/* Initialize QiFields global */
if (QiFields == QIF_NULL && (QiFields = GetFields(*To, *From)) == QIF_NULL)
return(-1);
/* Connection ok */
return (0);
}
@
1.7
log
@Changed NSSERVICE back to "ns" from "csnet-ns" as I can't get the
latter to decode authenticators properly when used with Kerberos.
@
text
@d38 1
a38 1
static char RcsId[] = "@@(#)$Id: OpenQi.c,v 1.6 1994/03/11 23:14:20 paul Exp paul $";
d68 1
a68 1
# define NSSERVICE "ns"
@