[PATCH] allow to disable SLP with runtime option

Petr Uzel petr.uzel at suse.cz
Wed Apr 22 14:14:23 GMT 2009


Hi everyone,

I'd like to propose a patch for review. It enhances rsync when
patched and compiled with slp support.

It adds a new global boolean option, 'disable slp', which can be used to disable
SLP advertisements at runtime. The idea behind this patch is to allow
distributors to build rsync with SLP support compiled in, but to allow
the users to turn it off without recompiling rsync on their own.


The patch applies to rsync-3.0.6pre1 with slp.diff applied.


I'd highly appreciate any feedback.



Index: rsync-3.0.6pre1/loadparm.c
===================================================================
--- rsync-3.0.6pre1.orig/loadparm.c	2009-04-22 12:47:39.000000000 +0200
+++ rsync-3.0.6pre1/loadparm.c	2009-04-22 13:30:39.000000000 +0200
@@ -111,6 +111,7 @@ typedef struct
 	int rsync_port;
 #ifdef HAVE_LIBSLP
 	int slp_refresh;
+	BOOL disable_slp;
 #endif
 } global;
 
@@ -305,6 +306,7 @@ static struct parm_struct parm_table[] =
  {"port",              P_INTEGER,P_GLOBAL,&Globals.rsync_port,         NULL,0},
 #ifdef HAVE_LIBSLP
  {"slp refresh",       P_INTEGER,P_GLOBAL,&Globals.slp_refresh,        NULL,0},
+ {"disable slp",        P_BOOL,   P_GLOBAL,&Globals.disable_slp,        NULL,0},
 #endif
  {"socket options",    P_STRING, P_GLOBAL,&Globals.socket_options,     NULL,0},
 
@@ -402,6 +404,7 @@ FN_GLOBAL_STRING(lp_socket_options, &Glo
 FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port)
 #ifdef HAVE_LIBSLP
 FN_GLOBAL_INTEGER(lp_slp_refresh, &Globals.slp_refresh)
+FN_GLOBAL_BOOL(lp_disable_slp, &Globals.disable_slp)
 #endif
 
 FN_LOCAL_STRING(lp_auth_users, auth_users)
Index: rsync-3.0.6pre1/clientserver.c
===================================================================
--- rsync-3.0.6pre1.orig/clientserver.c	2009-04-22 12:47:39.000000000 +0200
+++ rsync-3.0.6pre1/clientserver.c	2009-04-22 13:36:35.000000000 +0200
@@ -1065,9 +1065,11 @@ int daemon_main(void)
 	 * local address??? */
 
 #ifdef HAVE_LIBSLP
-	if (register_services()) {
-		rprintf(FINFO,
-		    "Couldn't register with service discovery protocol, continuing anyway\n");
+	if (!lp_disable_slp()) {
+		if (register_services()) {
+			rprintf(FINFO,
+				"Couldn't register with service discovery protocol, continuing anyway\n");
+		}
 	}
 #endif
 
Index: rsync-3.0.6pre1/rsyncd.conf.yo
===================================================================
--- rsync-3.0.6pre1.orig/rsyncd.conf.yo	2009-04-22 12:47:39.000000000 +0200
+++ rsync-3.0.6pre1/rsyncd.conf.yo	2009-04-22 15:17:07.000000000 +0200
@@ -113,6 +113,10 @@ set to more than 65535, then 65535 is us
 Using 3600 (one hour) is a good number if you tend to change your
 configuration.
 
+dit(bf(disable slp)) This parameter is used to turn off service advertisements
+completely, and is only applicable if you have Service Location Protocol
+support compiled in. The default is no.
+
 enddit()
 
 manpagesection(MODULE PARAMETERS)


-- 
Best regards / s pozdravem

Petr Uzel, Packages maintainer
---------------------------------------------------------------------
SUSE LINUX, s.r.o.                          e-mail: puzel at suse.cz
Lihovarská 1060/12                          tel: +420 284 028 964
190 00 Prague 9                             fax: +420 284 028 951
Czech Republic                              http://www.suse.cz


More information about the rsync mailing list