mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 14:30:06 +00:00
e4cf507069
Mon Dec 2 03:59:38 1996 Ulrich Drepper <drepper@cygnus.com> * grp/initgroups.c: Update and reformat copyright. Use __getgrent_r instead of getgrent. * inet/rcmd.c: Update and reformat copyright. Use __gethostbyname_r instead of gethostbyname. * inet/rexec.c: Likewise. * intl/finddomain.c: Correct comment about CEN sponsor and revision. * locale/findlocale.c: Likewise. * intl/l10nflist.c: Correct handling of CEN sponsor and revision. * locale/Makefile (CPPFLAGS): Add definition of LOCALEDIR. * locale/setlocale.c (setlocale): Correctly split value of LOCALE_PATH. * locale/programs/localedef.c: Use LOCALEDIR not LOCALE_PATH to find output directory. * nss/getXXbyYY.c [NEED_H_ERRNO]: Before enlarging buffer test h_errno_tmp variable. Save error value from being changed during `free' call. * nss/getXXent.c: Likewise. * nss/nss_files/files-XXX.c: Set h_errno variable to NETDB_INTERNAL before returning ERANGE error. * posix/glob.c: Use getlogin_r and getpwnam_r function when available or in GNU libc. * pwd/getpw.c: Use getpwuid_r instead of getpwuid. * sunrpc/clnt_gen.c: Use gethostbyname_r and getprotobyname_r. * sunrpc/clnt_simp.c: Likewise. * sunrpc/getrpcport.c: Likewise. * sysdeps/unix/sysv/linux/gethostid.c: Likewise. * posix/getconf.c: Treat _SC_UNIT_MAX and _SC_ULONG_MAX separately since the value might be outsode the range of the `long int'. Print string `undefined' when a value is undefined. * stdlib/l64a.c: Return correct pointer. Patch by NIIBE Yutaka <gniibe@mri.co.jp>. * string/Makefile (routines): Add argz-addsep. * string/argz-addsep.c: New file. * string/argz.h: Add prototypes for argz_add_sep. * string/argz-ctsep.c: Prevent memory leak. * string/strcoll.c: Correct typo in comment. Sat Nov 30 02:53:59 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/sys/serial.h: Removed again. The file is not general enough to be part of the libc. * sysdeps/unix/sysv/linux/Dist: Remove sys/serial.h. * sysdeps/unix/sysv/linux/Makefile: Don't install sys/serial.h. Thu Nov 28 20:04:41 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * login/Makefile: Fix typo. * nss/Makefile (generated): Filter out db-alias.c. Thu Nov 28 14:44:01 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * time/Makefile (echo-zonenames): Don't depend on non-existing target `zonenames'. Thu Nov 28 12:34:05 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * link.h: New file. * nss/nsswitch.c: Use it. * printf.h: Fix file name. * stdlib/strfmon.c: Use it.
162 lines
4.4 KiB
C
162 lines
4.4 KiB
C
/*
|
|
* Copyright (c) 1980, 1993
|
|
* The Regents of the University of California. 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 University of
|
|
* California, Berkeley and its contributors.
|
|
* 4. Neither the name of 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 REGENTS 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 REGENTS 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.
|
|
*/
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint)
|
|
static char sccsid[] = "@(#)rexec.c 8.1 (Berkeley) 6/4/93";
|
|
#endif /* LIBC_SCCS and not lint */
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <alloca.h>
|
|
#include <stdio.h>
|
|
#include <netdb.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
int rexecoptions;
|
|
|
|
int
|
|
rexec(ahost, rport, name, pass, cmd, fd2p)
|
|
char **ahost;
|
|
int rport;
|
|
char *name, *pass, *cmd;
|
|
int *fd2p;
|
|
{
|
|
struct sockaddr_in sin, sin2, from;
|
|
struct hostent hostbuf, *hp;
|
|
size_t hstbuflen;
|
|
char *hsttmpbuf;
|
|
u_short port;
|
|
int s, timo = 1, s3;
|
|
char c;
|
|
int herr;
|
|
|
|
hstbuflen = 1024;
|
|
hsttmpbuf = __alloca (hstbuflen);
|
|
while (__gethostbyname_r (*ahost, &hostbuf, hsttmpbuf, hstbuflen,
|
|
&hp, &herr) < 0)
|
|
if (herr != NETDB_INTERNAL || errno != ERANGE)
|
|
{
|
|
herror(*ahost);
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
/* Enlarge the buffer. */
|
|
hstbuflen *= 2;
|
|
hsttmpbuf = __alloca (hstbuflen);
|
|
}
|
|
|
|
*ahost = hp->h_name;
|
|
ruserpass(hp->h_name, &name, &pass);
|
|
retry:
|
|
s = socket(AF_INET, SOCK_STREAM, 0);
|
|
if (s < 0) {
|
|
perror("rexec: socket");
|
|
return (-1);
|
|
}
|
|
sin.sin_family = hp->h_addrtype;
|
|
sin.sin_port = rport;
|
|
bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
|
|
if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
|
|
if (errno == ECONNREFUSED && timo <= 16) {
|
|
(void) close(s);
|
|
sleep(timo);
|
|
timo *= 2;
|
|
goto retry;
|
|
}
|
|
perror(hp->h_name);
|
|
return (-1);
|
|
}
|
|
if (fd2p == 0) {
|
|
(void) write(s, "", 1);
|
|
port = 0;
|
|
} else {
|
|
char num[32];
|
|
int s2, sin2len;
|
|
|
|
s2 = socket(AF_INET, SOCK_STREAM, 0);
|
|
if (s2 < 0) {
|
|
(void) close(s);
|
|
return (-1);
|
|
}
|
|
listen(s2, 1);
|
|
sin2len = sizeof (sin2);
|
|
if (getsockname(s2, (struct sockaddr *)&sin2, &sin2len) < 0 ||
|
|
sin2len != sizeof (sin2)) {
|
|
perror("getsockname");
|
|
(void) close(s2);
|
|
goto bad;
|
|
}
|
|
port = ntohs((u_short)sin2.sin_port);
|
|
(void) sprintf(num, "%u", port);
|
|
(void) write(s, num, strlen(num)+1);
|
|
{ int len = sizeof (from);
|
|
s3 = accept(s2, (struct sockaddr *)&from, &len);
|
|
close(s2);
|
|
if (s3 < 0) {
|
|
perror("accept");
|
|
port = 0;
|
|
goto bad;
|
|
}
|
|
}
|
|
*fd2p = s3;
|
|
}
|
|
(void) write(s, name, strlen(name) + 1);
|
|
/* should public key encypt the password here */
|
|
(void) write(s, pass, strlen(pass) + 1);
|
|
(void) write(s, cmd, strlen(cmd) + 1);
|
|
if (read(s, &c, 1) != 1) {
|
|
perror(*ahost);
|
|
goto bad;
|
|
}
|
|
if (c != 0) {
|
|
while (read(s, &c, 1) == 1) {
|
|
(void) write(2, &c, 1);
|
|
if (c == '\n')
|
|
break;
|
|
}
|
|
goto bad;
|
|
}
|
|
return (s);
|
|
bad:
|
|
if (port)
|
|
(void) close(*fd2p);
|
|
(void) close(s);
|
|
return (-1);
|
|
}
|