X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/9a7eef964a2e3389ffd3537302f80ca42cfe9239..55c1a3b729d8b3324ecd7a863280f3402dfe4f05:/slp.diff diff --git a/slp.diff b/slp.diff index 06c2ee2..1410e7c 100644 --- a/slp.diff +++ b/slp.diff @@ -6,6 +6,9 @@ After applying this patch, run these commands for a successful build: ./configure --enable-slp make +TODO: the configure changes should abort if the user requests --enable-slp +and we can't honor that request. + --- old/Makefile.in +++ new/Makefile.in @@ -12,6 +12,8 @@ CFLAGS=@CFLAGS@ @@ -37,7 +40,7 @@ After applying this patch, run these commands for a successful build: --- old/clientserver.c +++ new/clientserver.c -@@ -836,6 +836,13 @@ int daemon_main(void) +@@ -847,6 +847,13 @@ int daemon_main(void) * address too. In fact, why not just do inet_ntop on the * local address??? */ @@ -53,7 +56,7 @@ After applying this patch, run these commands for a successful build: int fd; --- old/configure.in +++ new/configure.in -@@ -518,6 +518,29 @@ if test $rsync_cv_chown_follows_symlink +@@ -522,6 +522,29 @@ if test $rsync_cv_chown_follows_symlink AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.]) fi @@ -85,35 +88,41 @@ After applying this patch, run these commands for a successful build: #include --- old/loadparm.c +++ new/loadparm.c -@@ -105,6 +105,7 @@ typedef struct +@@ -105,6 +105,9 @@ typedef struct char *socket_options; int rsync_port; ++#ifdef HAVE_LIBSLP + int slp_refresh; ++#endif int syslog_facility; } global; -@@ -286,6 +287,7 @@ static struct parm_struct parm_table[] = +@@ -286,6 +289,9 @@ static struct parm_struct parm_table[] = {"motd file", P_STRING, P_GLOBAL,&Globals.motd_file, NULL,0}, {"pid file", P_STRING, P_GLOBAL,&Globals.pid_file, NULL,0}, {"port", P_INTEGER,P_GLOBAL,&Globals.rsync_port, NULL,0}, ++#ifdef HAVE_LIBSLP + {"slp refresh", P_INTEGER,P_GLOBAL,&Globals.slp_refresh, NULL,0}, ++#endif {"socket options", P_STRING, P_GLOBAL,&Globals.socket_options, NULL,0}, {"syslog facility", P_ENUM, P_GLOBAL,&Globals.syslog_facility,enum_facilities,0}, -@@ -379,6 +381,7 @@ FN_GLOBAL_STRING(lp_pid_file, &Globals.p +@@ -379,6 +385,9 @@ FN_GLOBAL_STRING(lp_pid_file, &Globals.p FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options) FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port) ++#ifdef HAVE_LIBSLP +FN_GLOBAL_INTEGER(lp_slp_refresh, &Globals.slp_refresh) ++#endif FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility) FN_LOCAL_STRING(lp_auth_users, auth_users) --- old/main.c +++ new/main.c -@@ -962,6 +962,18 @@ static int start_client(int argc, char * +@@ -971,6 +971,18 @@ static int start_client(int argc, char * + if (!read_batch) { /* for read_batch, NO source is specified */ - argc--; shell_path = check_for_hostspec(argv[0], &shell_machine, &rsync_port); + + if (shell_machine && !shell_machine[0]) { @@ -132,7 +141,7 @@ After applying this patch, run these commands for a successful build: int dummy2; --- old/options.c +++ new/options.c -@@ -195,6 +195,7 @@ static void print_rsync_version(enum log +@@ -196,6 +196,7 @@ static void print_rsync_version(enum log char const *hardlinks = "no "; char const *links = "no "; char const *ipv6 = "no "; @@ -140,7 +149,7 @@ After applying this patch, run these commands for a successful build: STRUCT_STAT *dumstat; #ifdef HAVE_SOCKETPAIR -@@ -217,6 +218,10 @@ static void print_rsync_version(enum log +@@ -218,6 +219,10 @@ static void print_rsync_version(enum log ipv6 = ""; #endif @@ -151,7 +160,7 @@ After applying this patch, run these commands for a successful build: rprintf(f, "%s version %s protocol version %d\n", RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION); rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n"); -@@ -229,9 +234,9 @@ static void print_rsync_version(enum log +@@ -230,9 +235,9 @@ static void print_rsync_version(enum log /* Note that this field may not have type ino_t. It depends * on the complicated interaction between largefile feature * macros. */ @@ -177,7 +186,7 @@ After applying this patch, run these commands for a successful build: * FLOG and FCLIENT are only used on the daemon side for custom logging, --- old/rsync.yo +++ new/rsync.yo -@@ -137,7 +137,12 @@ particular rsync daemon by leaving off t +@@ -139,7 +139,12 @@ particular rsync daemon by leaving off t quote(tt(rsync somehost.mydomain.com::)) @@ -215,7 +224,7 @@ After applying this patch, run these commands for a successful build: enddit() -@@ -541,6 +550,7 @@ use chroot = no +@@ -543,6 +552,7 @@ use chroot = no max connections = 4 syslog facility = local5 pid file = /var/run/rsyncd.pid @@ -225,10 +234,11 @@ After applying this patch, run these commands for a successful build: path = /var/ftp/pub --- old/socket.c +++ new/socket.c -@@ -447,6 +447,14 @@ void start_accept_loop(int port, int (*f +@@ -447,6 +447,16 @@ void start_accept_loop(int port, int (*f { fd_set deffds; int *sp, maxfd, i; ++#ifdef HAVE_LIBSLP + time_t next_slp_refresh; + short slp_timeout = lp_slp_refresh(); + if (slp_timeout) { @@ -237,14 +247,17 @@ After applying this patch, run these commands for a successful build: + /* re-register before slp times out */ + slp_timeout -= 15; + } ++#endif #ifdef HAVE_SIGACTION sigact.sa_flags = SA_NOCLDSTOP; -@@ -475,14 +483,20 @@ void start_accept_loop(int port, int (*f +@@ -475,14 +485,25 @@ void start_accept_loop(int port, int (*f maxfd = sp[i]; } ++#ifdef HAVE_LIBSLP + next_slp_refresh = time(NULL) + slp_timeout; ++#endif + /* now accept incoming connections - forking a new process * for each incoming connection */ @@ -253,33 +266,41 @@ After applying this patch, run these commands for a successful build: pid_t pid; int fd; + int sel_ret; -+ struct timeval slp_tv; struct sockaddr_storage addr; socklen_t addrlen = sizeof addr; ++#ifdef HAVE_LIBSLP ++ struct timeval slp_tv; ++ + slp_tv.tv_sec = 10; + slp_tv.tv_usec = 0; ++#endif /* close log file before the potentially very long select so * file can be trimmed by another process instead of growing -@@ -494,8 +508,13 @@ void start_accept_loop(int port, int (*f +@@ -494,8 +515,18 @@ void start_accept_loop(int port, int (*f #else fds = deffds; #endif - - if (select(maxfd + 1, &fds, NULL, NULL, NULL) != 1) -+ sel_ret = select(maxfd + 1, &fds, NULL, NULL, slp_timeout ? &slp_tv: NULL); ++#ifdef HAVE_LIBSLP ++ sel_ret = select(maxfd + 1, &fds, NULL, NULL, ++ slp_timeout ? &slp_tv : NULL); + if (sel_ret == 0 && slp_timeout && time(NULL) > next_slp_refresh) { + rprintf(FINFO, "Service registration expired, refreshing it\n"); + register_services(); + next_slp_refresh = time(NULL) + slp_timeout; + } ++#else ++ sel_ret = select(maxfd + 1, &fds, NULL, NULL, NULL); ++#endif + if (sel_ret != 1) continue; for (i = 0, fd = -1; sp[i] >= 0; i++) { --- old/srvloc.c +++ new/srvloc.c -@@ -0,0 +1,105 @@ +@@ -0,0 +1,103 @@ +/* -*- c-file-style: "linux"; -*- + + Copyright (C) 2002 by Brad Hards @@ -319,9 +340,9 @@ After applying this patch, run these commands for a successful build: + char *cleanstr; + + if (errcode == SLP_OK) { -+ if (!strcmp(attrlist, "(comment=)")) { ++ if (!strcmp(attrlist, "(comment=)")) + rprintf(FINFO, "\t(No description)\n"); -+ } else { ++ else { + cleanstr = strrchr(attrlist, ')') ; + *cleanstr = ' '; /* remove last ')' */ + rprintf(FINFO, "\t%s\n", strchr(attrlist, '=') + 1); @@ -330,9 +351,9 @@ After applying this patch, run these commands for a successful build: + return SLP_FALSE; +} + -+SLPBoolean getSLPSrvURLCallback(UNUSED(SLPHandle hslp), const char *srvurl, -+ UNUSED(unsigned short lifetime), SLPError errcode, -+ void *cookie) ++static SLPBoolean getSLPSrvURLCallback(UNUSED(SLPHandle hslp), ++ const char *srvurl, UNUSED(unsigned short lifetime), ++ SLPError errcode, void *cookie) +{ + SLPError result; + SLPHandle attrhslp; @@ -352,10 +373,8 @@ After applying this patch, run these commands for a successful build: + SLPClose(attrhslp); + } + *(SLPError*)cookie = SLP_OK; -+ } else { ++ } else + *(SLPError*)cookie = errcode; -+ } -+ + + /* Return SLP_TRUE because we want to be called again + * if more services were found. */