summaryrefslogtreecommitdiff
path: root/net/rsync
diff options
context:
space:
mode:
authorOliver Braun <obraun@FreeBSD.org>2003-03-03 19:37:22 +0000
committerOliver Braun <obraun@FreeBSD.org>2003-03-03 19:37:22 +0000
commit5d90ba6cc76e11d47c29342531d6f35d0f28251d (patch)
tree45c317bc10d0ef9379a532af0dfcea20eb5af28b /net/rsync
parent- SECURITY FIX, urgent update recommended (diff)
* Add rsyncd.conf.sample and rsyncd.sh.sample.
PR: ports/48883 Submitted by: Morettoni Luca <luca@morettoni.net> * Add patch for -current submitted by ume@ Quote from ume@'s mail: It seems the daemon mode of rsync depends on an IPv4-mapped IPv6 address. Since an IPv4-mapped IPv6 address is off by default on 5-CURRENT, rsync doesn't listen on IPv4. Further, rsync has a bug that it always listen on 1st entry's address of the result of getaddrinfo() call. With this patch, rsync listen on both an IPv4 and an IPv6. * Make pkg-plist respect PORTDOCS.
Notes
Notes: svn path=/head/; revision=76813
Diffstat (limited to 'net/rsync')
-rw-r--r--net/rsync/Makefile6
-rw-r--r--net/rsync/files/extra-patch-socket.c178
-rw-r--r--net/rsync/files/rsyncd.conf.sample35
-rw-r--r--net/rsync/files/rsyncd.sh.sample16
-rw-r--r--net/rsync/pkg-plist10
5 files changed, 241 insertions, 4 deletions
diff --git a/net/rsync/Makefile b/net/rsync/Makefile
index 7721919dfa60..b7d1b90ee6d3 100644
--- a/net/rsync/Makefile
+++ b/net/rsync/Makefile
@@ -50,6 +50,10 @@ CONFIGURE_ARGS+= --enable-ipv6
CONFIGURE_ARGS+= --disable-ipv6
.endif
+.if ${OSVERSION} >= 500043
+EXTRA_PATCHES= ${FILESDIR}/extra-patch-socket.c
+.endif
+
MAN1= rsync.1
MAN5= rsyncd.conf.5
@@ -68,6 +72,8 @@ pre-configure:
post-install:
@${STRIP_CMD} ${PREFIX}/bin/rsync
+ ${INSTALL_DATA} ${FILESDIR}/rsyncd.conf.sample ${PREFIX}/etc/
+ ${INSTALL_SCRIPT} ${FILESDIR}/rsyncd.sh.sample ${PREFIX}/etc/rc.d/
.if !defined(NOPORTDOCS)
@${MKDIR} ${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README ${DOCSDIR}
diff --git a/net/rsync/files/extra-patch-socket.c b/net/rsync/files/extra-patch-socket.c
new file mode 100644
index 000000000000..dbfb08d36ba7
--- /dev/null
+++ b/net/rsync/files/extra-patch-socket.c
@@ -0,0 +1,178 @@
+Index: socket.c
+diff -u socket.c.orig socket.c
+--- socket.c.orig Mon Jan 27 12:35:09 2003
++++ socket.c Sat Feb 8 00:06:59 2003
+@@ -292,11 +292,11 @@
+ * @param bind_address Local address to bind, or NULL to allow it to
+ * default.
+ **/
+-static int open_socket_in(int type, int port, const char *bind_address,
+- int af_hint)
++static int *open_socket_in(int type, int port, const char *bind_address,
++ int af_hint)
+ {
+ int one=1;
+- int s;
++ int *s, *socks, maxs;
+ struct addrinfo hints, *all_ai, *resp;
+ char portbuf[10];
+ int error;
+@@ -310,41 +310,65 @@
+ if (error) {
+ rprintf(FERROR, RSYNC_NAME ": getaddrinfo: bind address %s: %s\n",
+ bind_address, gai_strerror(error));
+- return -1;
++ return NULL;
++ }
++
++ /* Count max number of sockets we may open */
++ for (maxs = 0, resp = all_ai; resp; resp = resp->ai_next, maxs++)
++ ;
++ socks = malloc((maxs + 1) * sizeof(int));
++ if (!socks) {
++ rprintf(FERROR,
++ RSYNC_NAME "couldn't allocate memory for sockets");
++ return NULL;
+ }
+
+ /* We may not be able to create the socket, if for example the
+ * machine knows about IPv6 in the C library, but not in the
+ * kernel. */
++ *socks = 0; /* num of sockets counter at start of array */
++ s = socks + 1;
+ for (resp = all_ai; resp; resp = resp->ai_next) {
+- s = socket(resp->ai_family, resp->ai_socktype,
++ *s = socket(resp->ai_family, resp->ai_socktype,
+ resp->ai_protocol);
+
+- if (s == -1)
++ if (*s == -1)
+ /* See if there's another address that will work... */
+ continue;
+
+- setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
++ setsockopt(*s, SOL_SOCKET, SO_REUSEADDR,
+ (char *)&one, sizeof one);
+
++#ifdef IPV6_V6ONLY
++ if (resp->ai_family == AF_INET6)
++ setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY,
++ (char *)&one, sizeof one);
++#endif
++
+ /* now we've got a socket - we need to bind it */
+- if (bind(s, all_ai->ai_addr, all_ai->ai_addrlen) < 0) {
++ if (bind(*s, resp->ai_addr, resp->ai_addrlen) < 0) {
+ /* Nope, try another */
+- close(s);
++ close(*s);
+ continue;
+ }
+
+- freeaddrinfo(all_ai);
+- return s;
++ (*socks)++;
++ s++;
+ }
+
+- rprintf(FERROR, RSYNC_NAME ": open inbound socket on port %d failed: "
+- "%s\n",
+- port,
+- strerror(errno));
++ if (all_ai)
++ freeaddrinfo(all_ai);
+
+- freeaddrinfo(all_ai);
+- return -1;
++ if (*socks == 0) {
++ rprintf(FERROR,
++ RSYNC_NAME ": open inbound socket on port %d failed: "
++ "%s\n",
++ port,
++ strerror(errno));
++ free(socks);
++ return NULL;
++ }
++ return socks;
+ }
+
+
+@@ -376,19 +400,29 @@
+
+ void start_accept_loop(int port, int (*fn)(int, int))
+ {
+- int s;
++ fd_set deffds;
++ int *s, maxfd, i, j;
+ extern char *bind_address;
+ extern int default_af_hint;
+
+ /* open an incoming socket */
+ s = open_socket_in(SOCK_STREAM, port, bind_address, default_af_hint);
+- if (s == -1)
++ if (s == NULL)
+ exit_cleanup(RERR_SOCKETIO);
+
+ /* ready to listen */
+- if (listen(s, 5) == -1) {
+- close(s);
+- exit_cleanup(RERR_SOCKETIO);
++ FD_ZERO(&deffds);
++ maxfd = -1;
++ for (i = 1; i <= *s; i++) {
++ if (listen(s[i], 5) == -1) {
++ for (j = 1; j <= i; j++)
++ close(s[j]);
++ free(s);
++ exit_cleanup(RERR_SOCKETIO);
++ }
++ FD_SET(s[i], &deffds);
++ if (maxfd < s[i])
++ maxfd = s[i];
+ }
+
+
+@@ -406,16 +440,20 @@
+ forever */
+ log_close();
+
+- FD_ZERO(&fds);
+- FD_SET(s, &fds);
++ FD_COPY(&deffds, &fds);
+
+- if (select(s+1, &fds, NULL, NULL, NULL) != 1) {
++ if (select(maxfd + 1, &fds, NULL, NULL, NULL) != 1) {
+ continue;
+ }
+
+- if(!FD_ISSET(s, &fds)) continue;
+-
+- fd = accept(s,(struct sockaddr *)&addr,&addrlen);
++ fd = -1;
++ for (i = 1; i <= *s; i++) {
++ if (FD_ISSET(s[i], &fds)) {
++ fd = accept(s[i], (struct sockaddr *)&addr,
++ &addrlen);
++ break;
++ }
++ }
+
+ if (fd == -1) continue;
+
+@@ -430,7 +468,7 @@
+
+ if ((pid = fork()) == 0) {
+ int ret;
+- close(s);
++ close(s[i]);
+ /* open log file in child before possibly giving
+ up privileges */
+ log_open();
+@@ -452,6 +490,7 @@
+ close(fd);
+ }
+ }
++ free(s);
+ }
+
+
diff --git a/net/rsync/files/rsyncd.conf.sample b/net/rsync/files/rsyncd.conf.sample
new file mode 100644
index 000000000000..dab5d1925af4
--- /dev/null
+++ b/net/rsync/files/rsyncd.conf.sample
@@ -0,0 +1,35 @@
+# rsyncd.conf - Example file, see rsyncd.conf(5)
+#
+
+# Set this if you want to stop rsync daemon with rc.d scripts
+pid file = /var/run/rsyncd.pid
+
+# Edit this file before running rsync daemon!!
+
+#uid = nobody
+#gid = nobody
+#use chroot = no
+#max connections = 4
+#syslog facility = local5
+
+#[ftp]
+# path = /var/ftp/pub
+# comment = whole ftp area (approx 6.1 GB)
+
+#[sambaftp]
+# path = /var/ftp/pub/samba
+# comment = Samba ftp area (approx 300 MB)
+
+#[rsyncftp]
+# path = /var/ftp/pub/rsync
+# comment = rsync ftp area (approx 6 MB)
+
+#[sambawww]
+# path = /public_html/samba
+# comment = Samba WWW pages (approx 240 MB)
+
+#[cvs]
+# path = /data/cvs
+# comment = CVS repository (requires authentication)
+# auth users = tridge, susan
+# secrets file = /usr/local/etc/rsyncd.secrets
diff --git a/net/rsync/files/rsyncd.sh.sample b/net/rsync/files/rsyncd.sh.sample
new file mode 100644
index 000000000000..7ec945a7dc5f
--- /dev/null
+++ b/net/rsync/files/rsyncd.sh.sample
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+case "$1" in
+start)
+ [ -x /usr/local/bin/rsync ] && [ -f /usr/local/etc/rsyncd.conf ] && \
+ /usr/local/bin/rsync --daemon > /dev/null && echo -n ' rsyncd'
+ ;;
+stop)
+ [ -r /var/run/rsyncd.pid ] && /bin/kill -9 `cat /var/run/rsyncd.pid` > /dev/null && echo -n ' rsyncd'
+ ;;
+*)
+ echo "Usage: `basename $0` {start|stop}" >&2
+ ;;
+esac
+
+exit 0
diff --git a/net/rsync/pkg-plist b/net/rsync/pkg-plist
index 70cdde938919..b95b6cfcddb4 100644
--- a/net/rsync/pkg-plist
+++ b/net/rsync/pkg-plist
@@ -1,6 +1,8 @@
@comment $FreeBSD$
bin/rsync
-share/doc/rsync/README
-share/doc/rsync/COPYING
-share/doc/rsync/tech_report.tex
-@dirrm share/doc/rsync
+etc/rsyncd.conf.sample
+etc/rc.d/rsyncd.sh.sample
+%%PORTDOCS%%share/doc/rsync/README
+%%PORTDOCS%%share/doc/rsync/COPYING
+%%PORTDOCS%%share/doc/rsync/tech_report.tex
+%%PORTDOCS%%@dirrm share/doc/rsync