in place: simply check the "am_server" global variable, which is not set
true when the daemon is listening for connections (daemon_main is not
called in main.c if am_server is set).
#include "rsync.h"
static const char default_name[] = "UNKNOWN";
#include "rsync.h"
static const char default_name[] = "UNKNOWN";
+extern int am_daemon;
+extern int am_server;
struct sockaddr_storage ss;
socklen_t length = sizeof ss;
char *ssh_client, *p;
struct sockaddr_storage ss;
socklen_t length = sizeof ss;
char *ssh_client, *p;
static char addr_buf[100];
static int initialised;
static char addr_buf[100];
static int initialised;
- if ((ssh_client = getenv("SSH_CLIENT")) != NULL) {
- strlcpy(addr_buf, ssh_client, sizeof(addr_buf));
- /* truncate SSH_CLIENT to just IP address */
- p = strchr(addr_buf, ' ');
- if (p)
- *p = '\0';
- else
- strlcpy(addr_buf, "0.0.0.0", sizeof("0.0.0.0"));
+ if (am_server) {
+ /* daemon over --rsh mode */
+ strcpy(addr_buf, "0.0.0.0");
+ if ((ssh_client = getenv("SSH_CLIENT")) != NULL) {
+ /* truncate SSH_CLIENT to just IP address */
+ p = strchr(ssh_client, ' ');
+ if (p) {
+ len = MIN((unsigned int) (p - ssh_client),
+ sizeof(addr_buf) - 1);
+ strncpy(addr_buf, ssh_client, len);
+ *(addr_buf + len) = '\0';
+ }
+ }
} else
client_sockaddr(fd, &ss, &length);
} else
client_sockaddr(fd, &ss, &length);
strcpy(name_buf, default_name);
initialised = 1;
strcpy(name_buf, default_name);
initialised = 1;
- if (getenv("SSH_CLIENT") != NULL) {
- /* Look up name of IP address given in $SSH_CLIENT */
+ if (am_server) {
+ /* daemon over --rsh mode */
+
char *addr = client_addr(fd);
struct sockaddr_in sin;
#ifdef INET6
char *addr = client_addr(fd);
struct sockaddr_in sin;
#ifdef INET6