bin/46703: BSD r-commands use wrong source address for stderr

http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=46703
Bump libc minor for the addition of rresvport_af_addr()
This commit is contained in:
darrenr 2012-07-14 15:06:26 +00:00
parent 046cd0a870
commit 3ec957d580
4 changed files with 32 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: unistd.h,v 1.134 2012/04/14 01:34:08 christos Exp $ */
/* $NetBSD: unistd.h,v 1.135 2012/07/14 15:06:26 darrenr Exp $ */
/*-
* Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
@ -385,6 +385,7 @@ int undelete(const char *);
int rcmd_af(char **, int, const char *,
const char *, const char *, int *, int);
int rresvport_af(int *, int);
int rresvport_af_addr(int *, int, void *);
int iruserok_sa(const void *, int, int, const char *, const char *);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: rcmd.c,v 1.67 2012/03/13 21:13:42 christos Exp $ */
/* $NetBSD: rcmd.c,v 1.68 2012/07/14 15:06:26 darrenr Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#else
__RCSID("$NetBSD: rcmd.c,v 1.67 2012/03/13 21:13:42 christos Exp $");
__RCSID("$NetBSD: rcmd.c,v 1.68 2012/07/14 15:06:26 darrenr Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -505,6 +505,12 @@ rresvport(int *alport)
int
rresvport_af(int *alport, int family)
{
return rresvport_af_addr(alport, family, NULL);
}
int
rresvport_af_addr(int *alport, int family, void *addr)
{
struct sockaddr_storage ss;
struct sockaddr *sa;
@ -522,6 +528,9 @@ rresvport_af(int *alport, int family)
sa->sa_len =
#endif
salen = sizeof(struct sockaddr_in);
if (addr)
((struct sockaddr_in *)(void *)sa)->sin_addr =
((struct sockaddr_in *)addr)->sin_addr;
portp = &((struct sockaddr_in *)(void *)sa)->sin_port;
break;
#ifdef INET6
@ -530,6 +539,9 @@ rresvport_af(int *alport, int family)
sa->sa_len =
#endif
salen = sizeof(struct sockaddr_in6);
if (addr)
((struct sockaddr_in6 *)(void *)sa)->sin6_addr =
((struct sockaddr_in6 *)addr)->sin6_addr;
portp = &((struct sockaddr_in6 *)(void *)sa)->sin6_port;
break;
#endif

View File

@ -1,4 +1,4 @@
# $NetBSD: shlib_version,v 1.232 2012/07/08 01:21:11 rmind Exp $
# $NetBSD: shlib_version,v 1.233 2012/07/14 15:06:26 darrenr Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@ -31,4 +31,4 @@
# - remove gets(); it is finally dead in c11.
# - make __cerror (spelled CERROR) hidden again
major=12
minor=184
minor=185

View File

@ -1,4 +1,4 @@
/* $NetBSD: rshd.c,v 1.49 2011/10/30 16:54:58 christos Exp $ */
/* $NetBSD: rshd.c,v 1.50 2012/07/14 15:06:26 darrenr Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
@ -69,7 +69,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
#else
__RCSID("$NetBSD: rshd.c,v 1.49 2011/10/30 16:54:58 christos Exp $");
__RCSID("$NetBSD: rshd.c,v 1.50 2012/07/14 15:06:26 darrenr Exp $");
#endif
#endif /* not lint */
@ -137,7 +137,7 @@ static int check_all;
static int log_success; /* If TRUE, log all successful accesses */
static int sent_null;
__dead static void doit(struct sockaddr *);
__dead static void doit(struct sockaddr *, struct sockaddr *);
__dead static void rshd_errx(int, const char *, ...) __printflike(2, 3);
static void getstr(char *, int, const char *);
static int local_domain(char *);
@ -155,7 +155,9 @@ main(int argc, char *argv[])
struct linger linger;
int ch, on = 1;
socklen_t fromlen;
socklen_t locallen;
struct sockaddr_storage from;
struct sockaddr_storage local;
struct protoent *proto;
openlog("rshd", LOG_PID, LOG_DAEMON);
@ -185,10 +187,16 @@ main(int argc, char *argv[])
argv += optind;
fromlen = sizeof(from); /* xxx */
locallen = sizeof(local); /* xxx */
if (getpeername(STDIN_FILENO, (struct sockaddr *)&from, &fromlen) < 0) {
syslog(LOG_ERR, "getpeername: %m");
return EXIT_FAILURE;
}
if (getsockname(STDIN_FILENO, (struct sockaddr *)&local,
&locallen) < 0) {
syslog(LOG_ERR, "getsockname: %m");
return EXIT_FAILURE;
}
#if 0
if (((struct sockaddr *)&from)->sa_family == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&from)->sin6_addr) &&
@ -232,13 +240,13 @@ main(int argc, char *argv[])
proto = getprotobyname("tcp");
(void)setsockopt(STDIN_FILENO, proto->p_proto, TCP_NODELAY, &on,
sizeof(on));
doit((struct sockaddr *)&from);
doit((struct sockaddr *)&from, (struct sockaddr *)&local);
}
extern char **environ;
static void
doit(struct sockaddr *fromp)
doit(struct sockaddr *fromp, struct sockaddr *localp)
{
struct passwd *pwd, pwres;
in_port_t port;
@ -356,7 +364,7 @@ doit(struct sockaddr *fromp)
(void) alarm(0);
if (port != 0) {
int lport = IPPORT_RESERVED - 1;
s = rresvport_af(&lport, af);
s = rresvport_af_addr(&lport, af, localp);
if (s < 0) {
syslog(LOG_ERR, "can't get stderr port: %m");
exit(EXIT_FAILURE);