TODO: the configure changes should abort if the user requests --enable-slp
and we can't honor that request.
-based-on: 6884ccbd2f4f1cf9d350969e51bb6aca58a35da7
+based-on: 3e44bbd3132c22f7ce1ae48c0ce262f237473038
diff --git a/Makefile.in b/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
LIBOBJDIR=lib/
INSTALLCMD=@INSTALL@
-@@ -48,7 +50,7 @@ OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
+@@ -46,7 +48,7 @@ OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
- fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
- OBJS3=progress.o pipe.o @ASM@
+ usage.o fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
+ OBJS3=progress.o pipe.o @ASM@ @SIMD@
-DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
+DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o $(SLPOBJ)
popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
popt/popthelp.o popt/poptparse.o
- OBJS=$(OBJS1) $(OBJS2) $(OBJS3) @SIMD@ $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
-@@ -97,7 +99,7 @@ install-strip:
+ OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
+@@ -99,7 +101,7 @@ install-strip:
$(MAKE) INSTALL_STRIP='-s' install
rsync$(EXEEXT): $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(LIBSLP)
- $(OBJS): $(HEADERS)
- $(CHECK_OBJS): $(HEADERS)
+ rrsync: support/rrsync
+ cp -p $(srcdir)/support/rrsync rrsync
diff --git a/clientserver.c b/clientserver.c
--- a/clientserver.c
+++ b/clientserver.c
-@@ -1350,6 +1350,13 @@ int daemon_main(void)
+@@ -1490,6 +1490,13 @@ int daemon_main(void)
* address too. In fact, why not just do getnameinfo on the
* local address??? */
+#ifdef HAVE_LIBSLP
-+ if (register_services()) {
++ if (lp_use_slp() && register_services()) {
+ rprintf(FINFO,
+ "Couldn't register with service discovery protocol, continuing anyway\n");
+ }
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
-@@ -971,6 +971,29 @@ if test $rsync_cv_can_hardlink_special = yes; then
+@@ -1008,6 +1008,29 @@ if test $rsync_cv_can_hardlink_special = yes; then
AC_DEFINE(CAN_HARDLINK_SPECIAL, 1, [Define to 1 if link() can hard-link special files.])
fi
+
AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <sys/types.h>
-diff --git a/loadparm.c b/loadparm.c
---- a/loadparm.c
-+++ b/loadparm.c
-@@ -107,6 +107,9 @@ typedef struct {
+ #ifdef HAVE_SYS_TYPES_H
+diff --git a/daemon-parm.txt b/daemon-parm.txt
+--- a/daemon-parm.txt
++++ b/daemon-parm.txt
+@@ -10,8 +10,10 @@ STRING socket_options NULL
- int listen_backlog;
- int rsync_port;
-+#ifdef HAVE_LIBSLP
-+ int slp_refresh;
-+#endif
+ INTEGER listen_backlog 5
+ INTEGER rsync_port|port 0
++INTEGER slp_refresh 0
- BOOL proxy_protocol;
- } global_vars;
-@@ -403,6 +406,9 @@ static struct parm_struct parm_table[] =
- {"pid file", P_STRING, P_GLOBAL,&Vars.g.pid_file, NULL,0},
- {"port", P_INTEGER,P_GLOBAL,&Vars.g.rsync_port, NULL,0},
- {"proxy protocol", P_BOOL, P_LOCAL, &Vars.g.proxy_protocol, NULL,0},
-+#ifdef HAVE_LIBSLP
-+ {"slp refresh", P_INTEGER,P_GLOBAL,&Vars.g.slp_refresh, NULL,0},
-+#endif
- {"socket options", P_STRING, P_GLOBAL,&Vars.g.socket_options, NULL,0},
+ BOOL proxy_protocol False
++BOOL use_slp False
- {"auth users", P_STRING, P_LOCAL, &Vars.l.auth_users, NULL,0},
-@@ -544,6 +550,9 @@ FN_GLOBAL_STRING(lp_socket_options, socket_options)
-
- FN_GLOBAL_INTEGER(lp_listen_backlog, listen_backlog)
- FN_GLOBAL_INTEGER(lp_rsync_port, rsync_port)
-+#ifdef HAVE_LIBSLP
-+FN_GLOBAL_INTEGER(lp_slp_refresh, slp_refresh)
-+#endif
-
- FN_GLOBAL_BOOL(lp_proxy_protocol, proxy_protocol)
+ Locals: =================================================================
diff --git a/main.c b/main.c
--- a/main.c
+++ b/main.c
-@@ -1377,6 +1377,18 @@ static int start_client(int argc, char *argv[])
+@@ -1404,6 +1404,22 @@ static int start_client(int argc, char *argv[])
if (!read_batch) { /* for read_batch, NO source is specified */
char *path = check_for_hostspec(argv[0], &shell_machine, &rsync_port);
+ if (shell_machine && !shell_machine[0]) {
+#ifdef HAVE_LIBSLP
+ /* User entered just rsync:// URI */
-+ print_service_list();
-+ exit_cleanup(0);
++ if (lp_use_slp()) {
++ print_service_list();
++ exit_cleanup(0);
++ }
++ rprintf(FINFO, "SLP is disabled, cannot browse\n");
++ exit_cleanup(RERR_SYNTAX);
+#else /* No SLP, die here */
+ rprintf(FINFO, "No SLP support, cannot browse\n");
+ exit_cleanup(RERR_SYNTAX);
if (path) { /* source is remote */
char *dummy_host;
int dummy_port = 0;
-diff --git a/options.c b/options.c
---- a/options.c
-+++ b/options.c
-@@ -640,6 +640,11 @@ static void print_capabilities(enum logcode f)
- #endif
- "prealloc",
-
-+#ifndef HAVE_LIBSLP
-+ "no "
-+#endif
-+ "SLP",
-+
- "*"
- #ifndef HAVE_SIMD
- "no "
diff --git a/rsync.1.md b/rsync.1.md
--- a/rsync.1.md
+++ b/rsync.1.md
-@@ -151,6 +151,13 @@ rsync daemon by leaving off the module name:
+@@ -149,7 +149,19 @@ rsync daemon by leaving off the module name:
- See the following section for more details.
+ > rsync somehost.mydomain.com::
+-See the following section for more details.
++And, if Service Location Protocol is available, the following will list the
++available rsync servers:
++
++> rsync rsync://
++
++See the following section for even more usage details.
++
+One more thing, if Service Location Protocol is available, the following will
+list the available rsync servers:
+
+> rsync rsync://
+
+See the following section for even more usage details.
-+
+
# ADVANCED USAGE
- The syntax for requesting multiple files from a remote host is done by
diff --git a/rsync.h b/rsync.h
--- a/rsync.h
+++ b/rsync.h
-@@ -221,6 +221,10 @@
+@@ -236,6 +236,10 @@
#define SIGNIFICANT_ITEM_FLAGS (~(\
ITEM_BASIS_TYPE_FOLLOWS | ITEM_XNAME_FOLLOWS | ITEM_LOCAL_CHANGE))
diff --git a/rsyncd.conf.5.md b/rsyncd.conf.5.md
--- a/rsyncd.conf.5.md
+++ b/rsyncd.conf.5.md
-@@ -136,6 +136,16 @@ a literal % into a value is to use %%.
+@@ -136,6 +136,21 @@ a literal % into a value is to use %%.
You can override the default backlog value when the daemon listens for
connections. It defaults to 5.
++0. `use slp`
++
++ You can enable Service Location Protocol support by enabling this global
++ parameter. The default is "false".
++
+0. `slp refresh`
+
+ This parameter is used to determine how long service advertisements are
# MODULE PARAMETERS
After the global parameters you should define a number of modules, each module
+@@ -1173,6 +1188,7 @@ A more sophisticated example would be:
+ > max connections = 4
+ > syslog facility = local5
+ > pid file = /var/run/rsyncd.pid
++> slp refresh = 3600
+ >
+ > [ftp]
+ > path = /var/ftp/./pub
diff --git a/socket.c b/socket.c
--- a/socket.c
+++ b/socket.c
-@@ -538,6 +538,16 @@ void start_accept_loop(int port, int (*fn)(int, int))
+@@ -534,6 +534,16 @@ void start_accept_loop(int port, int (*fn)(int, int))
{
fd_set deffds;
int *sp, maxfd, i;
+#ifdef HAVE_LIBSLP
+ time_t next_slp_refresh;
-+ short slp_timeout = lp_slp_refresh();
++ short slp_timeout = lp_use_slp() ? lp_slp_refresh() : 0;
+ if (slp_timeout) {
+ if (slp_timeout < SLP_MIN_TIMEOUT)
+ slp_timeout = SLP_MIN_TIMEOUT;
#ifdef HAVE_SIGACTION
sigact.sa_flags = SA_NOCLDSTOP;
-@@ -565,14 +575,25 @@ void start_accept_loop(int port, int (*fn)(int, int))
+@@ -561,14 +571,25 @@ void start_accept_loop(int port, int (*fn)(int, int))
maxfd = sp[i];
}
/* close log file before the potentially very long select so
* file can be trimmed by another process instead of growing
-@@ -585,7 +606,18 @@ void start_accept_loop(int port, int (*fn)(int, int))
+@@ -581,7 +602,18 @@ void start_accept_loop(int port, int (*fn)(int, int))
fds = deffds;
#endif
+ /* refresh is done in main select loop */
+ return 0;
+}
+diff --git a/usage.c b/usage.c
+--- a/usage.c
++++ b/usage.c
+@@ -137,6 +137,11 @@ static void print_info_flags(enum logcode f)
+ #endif
+ "crtimes",
+
++#ifndef HAVE_LIBSLP
++ "no "
++#endif
++ "SLP",
++
+ "*Optimizations",
+
+ #ifndef HAVE_SIMD