Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src bin/46703: BSD r-commands use wrong source address for stderr
details: https://anonhg.NetBSD.org/src/rev/244480743319
branches: trunk
changeset: 780182:244480743319
user: darrenr <darrenr%NetBSD.org@localhost>
date: Sat Jul 14 15:06:26 2012 +0000
description:
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()
diffstat:
include/unistd.h | 3 ++-
lib/libc/net/rcmd.c | 16 ++++++++++++++--
lib/libc/shlib_version | 4 ++--
libexec/rshd/rshd.c | 20 ++++++++++++++------
4 files changed, 32 insertions(+), 11 deletions(-)
diffs (162 lines):
diff -r bcf3a0174c1e -r 244480743319 include/unistd.h
--- a/include/unistd.h Sat Jul 14 14:13:03 2012 +0000
+++ b/include/unistd.h Sat Jul 14 15:06:26 2012 +0000
@@ -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 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
diff -r bcf3a0174c1e -r 244480743319 lib/libc/net/rcmd.c
--- a/lib/libc/net/rcmd.c Sat Jul 14 14:13:03 2012 +0000
+++ b/lib/libc/net/rcmd.c Sat Jul 14 15:06:26 2012 +0000
@@ -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 */
@@ -506,6 +506,12 @@
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;
socklen_t salen;
@@ -522,6 +528,9 @@
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 @@
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
diff -r bcf3a0174c1e -r 244480743319 lib/libc/shlib_version
--- a/lib/libc/shlib_version Sat Jul 14 14:13:03 2012 +0000
+++ b/lib/libc/shlib_version Sat Jul 14 15:06:26 2012 +0000
@@ -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
diff -r bcf3a0174c1e -r 244480743319 libexec/rshd/rshd.c
--- a/libexec/rshd/rshd.c Sat Jul 14 14:13:03 2012 +0000
+++ b/libexec/rshd/rshd.c Sat Jul 14 15:06:26 2012 +0000
@@ -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 @@
#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 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 @@
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 @@
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 @@
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 @@
(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);
Home |
Main Index |
Thread Index |
Old Index