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:
parent
046cd0a870
commit
3ec957d580
@ -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.
|
* Copyright (c) 1998, 1999, 2008 The NetBSD Foundation, Inc.
|
||||||
@ -385,6 +385,7 @@ int undelete(const char *);
|
|||||||
int rcmd_af(char **, int, const char *,
|
int rcmd_af(char **, int, const char *,
|
||||||
const char *, const char *, int *, int);
|
const char *, const char *, int *, int);
|
||||||
int rresvport_af(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 *);
|
int iruserok_sa(const void *, int, int, const char *, const char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -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
|
* Copyright (c) 1983, 1993, 1994
|
||||||
@ -34,7 +34,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
|
||||||
#else
|
#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
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
@ -505,6 +505,12 @@ rresvport(int *alport)
|
|||||||
|
|
||||||
int
|
int
|
||||||
rresvport_af(int *alport, int family)
|
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_storage ss;
|
||||||
struct sockaddr *sa;
|
struct sockaddr *sa;
|
||||||
@ -522,6 +528,9 @@ rresvport_af(int *alport, int family)
|
|||||||
sa->sa_len =
|
sa->sa_len =
|
||||||
#endif
|
#endif
|
||||||
salen = sizeof(struct sockaddr_in);
|
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;
|
portp = &((struct sockaddr_in *)(void *)sa)->sin_port;
|
||||||
break;
|
break;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
@ -530,6 +539,9 @@ rresvport_af(int *alport, int family)
|
|||||||
sa->sa_len =
|
sa->sa_len =
|
||||||
#endif
|
#endif
|
||||||
salen = sizeof(struct sockaddr_in6);
|
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;
|
portp = &((struct sockaddr_in6 *)(void *)sa)->sin6_port;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -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
|
# Remember to update distrib/sets/lists/base/shl.* when changing
|
||||||
#
|
#
|
||||||
# things we wish to do on next major version bump:
|
# things we wish to do on next major version bump:
|
||||||
@ -31,4 +31,4 @@
|
|||||||
# - remove gets(); it is finally dead in c11.
|
# - remove gets(); it is finally dead in c11.
|
||||||
# - make __cerror (spelled CERROR) hidden again
|
# - make __cerror (spelled CERROR) hidden again
|
||||||
major=12
|
major=12
|
||||||
minor=184
|
minor=185
|
||||||
|
@ -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.
|
* Copyright (C) 1998 WIDE Project.
|
||||||
@ -69,7 +69,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1992, 1993, 1994\
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
|
static char sccsid[] = "@(#)rshd.c 8.2 (Berkeley) 4/6/94";
|
||||||
#else
|
#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
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ static int check_all;
|
|||||||
static int log_success; /* If TRUE, log all successful accesses */
|
static int log_success; /* If TRUE, log all successful accesses */
|
||||||
static int sent_null;
|
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);
|
__dead static void rshd_errx(int, const char *, ...) __printflike(2, 3);
|
||||||
static void getstr(char *, int, const char *);
|
static void getstr(char *, int, const char *);
|
||||||
static int local_domain(char *);
|
static int local_domain(char *);
|
||||||
@ -155,7 +155,9 @@ main(int argc, char *argv[])
|
|||||||
struct linger linger;
|
struct linger linger;
|
||||||
int ch, on = 1;
|
int ch, on = 1;
|
||||||
socklen_t fromlen;
|
socklen_t fromlen;
|
||||||
|
socklen_t locallen;
|
||||||
struct sockaddr_storage from;
|
struct sockaddr_storage from;
|
||||||
|
struct sockaddr_storage local;
|
||||||
struct protoent *proto;
|
struct protoent *proto;
|
||||||
|
|
||||||
openlog("rshd", LOG_PID, LOG_DAEMON);
|
openlog("rshd", LOG_PID, LOG_DAEMON);
|
||||||
@ -185,10 +187,16 @@ main(int argc, char *argv[])
|
|||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
fromlen = sizeof(from); /* xxx */
|
fromlen = sizeof(from); /* xxx */
|
||||||
|
locallen = sizeof(local); /* xxx */
|
||||||
if (getpeername(STDIN_FILENO, (struct sockaddr *)&from, &fromlen) < 0) {
|
if (getpeername(STDIN_FILENO, (struct sockaddr *)&from, &fromlen) < 0) {
|
||||||
syslog(LOG_ERR, "getpeername: %m");
|
syslog(LOG_ERR, "getpeername: %m");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (getsockname(STDIN_FILENO, (struct sockaddr *)&local,
|
||||||
|
&locallen) < 0) {
|
||||||
|
syslog(LOG_ERR, "getsockname: %m");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
#if 0
|
#if 0
|
||||||
if (((struct sockaddr *)&from)->sa_family == AF_INET6 &&
|
if (((struct sockaddr *)&from)->sa_family == AF_INET6 &&
|
||||||
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&from)->sin6_addr) &&
|
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&from)->sin6_addr) &&
|
||||||
@ -232,13 +240,13 @@ main(int argc, char *argv[])
|
|||||||
proto = getprotobyname("tcp");
|
proto = getprotobyname("tcp");
|
||||||
(void)setsockopt(STDIN_FILENO, proto->p_proto, TCP_NODELAY, &on,
|
(void)setsockopt(STDIN_FILENO, proto->p_proto, TCP_NODELAY, &on,
|
||||||
sizeof(on));
|
sizeof(on));
|
||||||
doit((struct sockaddr *)&from);
|
doit((struct sockaddr *)&from, (struct sockaddr *)&local);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doit(struct sockaddr *fromp)
|
doit(struct sockaddr *fromp, struct sockaddr *localp)
|
||||||
{
|
{
|
||||||
struct passwd *pwd, pwres;
|
struct passwd *pwd, pwres;
|
||||||
in_port_t port;
|
in_port_t port;
|
||||||
@ -356,7 +364,7 @@ doit(struct sockaddr *fromp)
|
|||||||
(void) alarm(0);
|
(void) alarm(0);
|
||||||
if (port != 0) {
|
if (port != 0) {
|
||||||
int lport = IPPORT_RESERVED - 1;
|
int lport = IPPORT_RESERVED - 1;
|
||||||
s = rresvport_af(&lport, af);
|
s = rresvport_af_addr(&lport, af, localp);
|
||||||
if (s < 0) {
|
if (s < 0) {
|
||||||
syslog(LOG_ERR, "can't get stderr port: %m");
|
syslog(LOG_ERR, "can't get stderr port: %m");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
Loading…
Reference in New Issue
Block a user