[distcc] distcc over ssh - what am i doing wrong here?
Martin Pool
mbp at samba.org
Thu Feb 19 03:16:05 GMT 2004
Please try this one instead.
Index: head/src/netutil.c
===================================================================
--- head.orig/src/netutil.c 2003-11-28 10:55:12.000000000 +1100
+++ head/src/netutil.c 2004-02-19 14:10:49.000000000 +1100
@@ -2,7 +2,7 @@
*
* distcc -- A simple distributed compiler system
*
- * Copyright (C) 2002, 2003 by Martin Pool <mbp at samba.org>
+ * Copyright (C) 2002, 2003, 2004 by Martin Pool <mbp at samba.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -140,18 +140,29 @@
char host[1024];
char port[32];
- err = getnameinfo(sa, salen,
- host, sizeof host,
- port, sizeof port,
- NI_NUMERICHOST | NI_NUMERICSERV);
- if (err) {
- rs_log_error("getnameinfo failed: %s", gai_strerror(err));
- *p_buf = strdup("(UNKNOWN)");
- return EXIT_DISTCC_FAILED; /* more specific? */
+ if (!sa) {
+ *p_buf = strdup("NOTSOCKET");
+ return 0;
+ } else if (sa->sa_family == AF_INET || sa->sa_family == AF_INET6) {
+ err = getnameinfo(sa, salen,
+ host, sizeof host,
+ port, sizeof port,
+ NI_NUMERICHOST | NI_NUMERICSERV);
+ if (err) {
+ rs_log_warning("getnameinfo failed: %s", gai_strerror(err));
+ *p_buf = strdup("(UNKNOWN)");
+ return 0; /* it's still a valid string */
+ }
+
+ asprintf(p_buf, "%s:%s", host, port);
+ } else if (sa->sa_family == AF_UNIX) {
+ /* NB: The word 'sun' is predefined on Solaris */
+ struct sockaddr_un *sa_un = (struct sockaddr_un *) sa;
+ asprintf(p_buf, "UNIX-DOMAIN %s", sa_un->sun_path);
+ } else {
+ asprintf(p_buf, "UNKNOWN-FAMILY %d", sa->sa_family);
}
- asprintf(p_buf, "%s:%s", host, port);
-
return 0;
}
#else /* ndef ENABLE_RFC2553 */
@@ -159,7 +170,10 @@
int UNUSED(salen),
char **p_buf)
{
- if (sa->sa_family == AF_INET) {
+ if (!sa) {
+ *p_buf = strdup("NOTSOCKET");
+ return 0;
+ } else if (sa->sa_family == AF_INET) {
struct sockaddr_in *sain = (struct sockaddr_in *) sa;
asprintf(p_buf, "%s:%d", inet_ntoa(sain->sin_addr),
Index: head/src/daemon.c
===================================================================
--- head.orig/src/daemon.c 2004-02-19 14:07:06.000000000 +1100
+++ head/src/daemon.c 2004-02-19 14:07:26.000000000 +1100
@@ -278,6 +278,7 @@
/* This can fail with ENOTSOCK if e.g. sshd has started us on a pipe,
* not on a socket. I think it's harmless. */
rs_log_notice("failed to get peer name: %s", strerror(errno));
+ psa = NULL; /* make sure we don't refer to uninitialized mem */
len = 0;
}
Index: head/src/srvnet.c
===================================================================
--- head.orig/src/srvnet.c 2004-01-12 12:01:21.000000000 +1100
+++ head/src/srvnet.c 2004-02-19 14:09:38.000000000 +1100
@@ -208,6 +208,8 @@
/**
* Log client IP address and perform access control checks.
+ *
+ * Note that PSA may be NULL if the sockaddr is unknown.
**/
int dcc_check_client(struct sockaddr *psa,
int salen,
@@ -226,7 +228,7 @@
/* if there are any access entries, then we must match one */
if (allowed) {
for (l = allowed; l; l = l->next) {
- if (psa->sa_family == AF_INET) {
+ if (psa && psa->sa_family == AF_INET) {
/* At the moment, access control is only supported for
IPv4 */
in_addr_t cli_inaddr;
@@ -245,3 +247,4 @@
return 0;
}
+
Index: head/ChangeLog
===================================================================
--- head.orig/ChangeLog 2004-02-19 13:59:56.000000000 +1100
+++ head/ChangeLog 2004-02-19 14:10:50.000000000 +1100
@@ -1,5 +1,18 @@
2004-02-19 Martin Pool <mbp at sourcefrog.net>
+ * src/netutil.c (dcc_sockaddr_to_string): Handle null sockaddr.
+
+ * src/srvnet.c (dcc_check_client): Handle null sockaddr.
+
+ * src/daemon.c (dcc_inetd_server): If there is no sockaddr, pass
+ it as NULL.
+
+ * src/netutil.c (dcc_sockaddr_to_string): [ENABLE_RFC2553]:
+ Failure to convert the address to a string should be just a
+ warning, not an error. Add special cases for unix-domain sockets
+ and unknown address families. Possibly fixes SSH connections with
+ ENABLE_RFC2553.
+
* src/daemon.c (dcc_inetd_server): Downgrade warning on
getpeername failure to just a notice message.
--
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/distcc/attachments/20040219/05453ed7/attachment.bin
More information about the distcc
mailing list