]> git.pld-linux.org Git - packages/rpcbind.git/commitdiff
- Allow the warms start code to be enabled at compile time
authorJan Rękorajski <baggins@pld-linux.org>
Tue, 8 May 2007 13:50:52 +0000 (13:50 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  with the --enable-warmstarts configuration flag and
  set the state directory with the --with-statedir
  configuration flag.

Changed files:
    rpcbind-warmstart.patch -> 1.3

rpcbind-warmstart.patch

index 57a529dea2909a856c8d9c54904db0ca8d714bf5..3f8975abbd381d47881d517a3353c6136e6bfb78 100644 (file)
-diff -ur rpcbind-0.1.4/src/rpcbind.c rpcbind-0.1.4-warmstart/src/rpcbind.c
---- rpcbind-0.1.4/src/rpcbind.c        2007-04-24 17:46:06.000000000 +0200
-+++ rpcbind-0.1.4-warmstart/src/rpcbind.c      2007-04-24 17:44:38.000000000 +0200
-@@ -125,6 +125,7 @@
-       void *nc_handle;        /* Net config handle */
-       struct rlimit rl;
-       int maxrec = RPC_MAXDATASIZE;
-+      uid_t rpc_uid = 0;
+diff --git a/configure.in b/configure.in
+index 9a64b45..0e2f163 100644
+--- a/configure.in
++++ b/configure.in
+@@ -18,6 +21,23 @@ AC_ARG_ENABLE(debug,[  --enable-debug      Turns on rpcbind debugging],
+       esac],[debug=false])
+ AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
  
-       parseargs(argc, argv);
-@@ -187,9 +188,19 @@
-       (void) signal(SIGHUP, SIG_IGN);
-       (void) signal(SIGUSR1, SIG_IGN);
-       (void) signal(SIGUSR2, SIG_IGN);
++AC_ARG_ENABLE(warmstarts,[  --enable-warmstarts  Enables Warm Starts], 
++      [case "${enableval}" in
++              yes) warmstarts=true ;;
++              no)  warmstarts=no ;;
++              *) AC_MSG_ERROR(bad value ${enableval} for --enable-warmstarts) ;;
++      esac],[warmstarts=false])
++AM_CONDITIONAL(WARMSTART, test x$warmstarts = xtrue)
 +
-+      if (runasdaemon) {
-+              struct passwd *p;
-+              if((p = getpwnam(RUN_AS)) == NULL) {
-+                      syslog(LOG_ERR, "cannot get uid of daemon: %m");
-+                      exit(1);
-+              }
-+              rpc_uid = p->pw_uid;
-+      }
++if test "$warmstarts" = "true" ; then
++      AC_ARG_WITH(statedir,
++              [  --with-statedir=/foo use state dir /foo [/tmp]],
++      statedir=$withval,
++              statedir=/tmp)
++              AC_SUBST(statedir)
++      AC_DEFINE_UNQUOTED(RPCBIND_STATEDIR, "$statedir", [This defines the location where the state files will be kept for warm starts])
++fi
++
+ AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
+                   netinet/in.h stdlib.h string.h \
+                   sys/param.h sys/socket.h \
+diff --git a/man/rpcbind.8 b/man/rpcbind.8
+index 2d59ce8..7985f0f 100644
+--- a/man/rpcbind.8
++++ b/man/rpcbind.8
+@@ -131,6 +131,14 @@ to use non-privileged ports for outgoing connections, preventing non-privileged
+ clients from using
+ .Nm
+ to connect to services from a privileged port.
++.It Fl w
++Cause
++.Nm
++to do a "warm start" by read a state file when
++.Nm
++starts up. The state file is created when
++.Nm
++terminates.
+ .El
+ .Sh NOTES
+ All RPC servers must be restarted if
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 52d3857..fd80847 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -1,5 +1,14 @@
+ INCLUDES = -I$(srcdir)/tirpc -DPORTMAP -DINET6 -DVERSION="\"$(VERSION)\"" \
+                                                 -D_GNU_SOURCE -Wall -pipe
++if DEBUG
++INCLUDES +=   -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
++INCLUDES +=   -DND_DEBUG -DBIND_DEBUG
++endif
++
++if WARMSTART
++INCLUDES +=   -DWARMSTART
++endif
 +
- #ifdef WARMSTART
-       if (warmstart) {
--              read_warmstart();
-+              read_warmstart(rpc_uid);
-       }
- #endif
-       if (debugging) {
-@@ -207,13 +218,7 @@
-       }
  
-       if (runasdaemon) {
--              struct passwd *p;
--
--              if((p = getpwnam(RUN_AS)) == NULL) {
--                      syslog(LOG_ERR, "cannot get uid of daemon: %m");
--                      exit(1);
--              }
--              if (setuid(p->pw_uid) == -1) {
-+              if (setuid(rpc_uid) == -1) {
-                       syslog(LOG_ERR, "setuid to daemon failed: %m");
-                       exit(1);
-               }
-diff -ur rpcbind-0.1.4/src/rpcbind.h rpcbind-0.1.4-warmstart/src/rpcbind.h
---- rpcbind-0.1.4/src/rpcbind.h        2004-10-25 14:07:44.000000000 +0200
-+++ rpcbind-0.1.4-warmstart/src/rpcbind.h      2007-04-24 17:44:52.000000000 +0200
-@@ -130,7 +130,7 @@
- #endif
+ bin_PROGRAMS = rpcbind rpcinfo
+@@ -18,10 +27,6 @@ rpcbind_LDFLAGS = -lpthread -ltirpc
+ rpcbind_LDADD = $(LIB_TIRPC)
+ AM_CPPFLAGS = -I/usr/include/tirpc -DCHECK_LOCAL -DPORTMAP \
+                        -DFACILITY=LOG_MAIL -DSEVERITY=LOG_INFO
+-if DEBUG
+-INCLUDES +=   -DRPCBIND_DEBUG -DSVC_RUN_DEBUG -DDEBUG_RMTCALL
+-INCLUDES +=   -DND_DEBUG -DBIND_DEBUG
+-endif
+ $(rpcbind_OBJECTS) :    security.o util.o check_bound.o pmap_svc.o \
+                         rpcb_svc.o rpcb_svc_com.o rpcb_svc_4.o \
+diff --git a/src/warmstart.c b/src/warmstart.c
+index 4a40639..6a50c41 100644
+--- a/src/warmstart.c
++++ b/src/warmstart.c
+@@ -46,17 +46,21 @@
+ #include <syslog.h>
+ #include <unistd.h>
  
- void write_warmstart(void);
--void read_warmstart(void);
-+void read_warmstart(uid_t rpc_uid);
++#include "config.h"
+ #include "rpcbind.h"
  
- char *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, char *netid);
- void network_init(void);
-diff -ur rpcbind-0.1.4/src/warmstart.c rpcbind-0.1.4-warmstart/src/warmstart.c
---- rpcbind-0.1.4/src/warmstart.c      2004-10-25 14:07:42.000000000 +0200
-+++ rpcbind-0.1.4-warmstart/src/warmstart.c    2007-04-24 17:45:36.000000000 +0200
-@@ -54,13 +54,13 @@
+ /*
+  * XXX this code is unsafe and is not used. It should be made safe.
+  */
  
++#ifndef RPCBIND_STATEDIR
++#define RPCBIND_STATEDIR "/tmp"
++#endif
  
  /* These files keep the pmap_list and rpcb_list in XDR format */
 -#define       RPCBFILE        "/tmp/rpcbind.file"
-+#define       RPCBFILE        "/var/lib/rpcbind/rpcbind.file"
++#define       RPCBFILE        RPCBIND_STATEDIR "/rpcbind.file"
  #ifdef PORTMAP
 -#define       PMAPFILE        "/tmp/portmap.file"
-+#define       PMAPFILE        "/var/lib/rpcbind/portmap.file"
++#define       PMAPFILE        RPCBIND_STATEDIR "/portmap.file"
  #endif
  
  static bool_t write_struct __P((char *, xdrproc_t, void *));
--static bool_t read_struct __P((char *, xdrproc_t, void *));
-+static bool_t read_struct __P((char *, xdrproc_t, void *, uid_t));
- static bool_t
- write_struct(char *filename, xdrproc_t structproc, void *list)
-@@ -98,7 +98,7 @@
- }
- static bool_t
--read_struct(char *filename, xdrproc_t structproc, void *list)
-+read_struct(char *filename, xdrproc_t structproc, void *list, uid_t rpc_uid)
- {
-       FILE *fp;
-       XDR xdrs;
-@@ -109,7 +109,7 @@
-               "rpcbind: cannot stat file = %s for reading\n", filename);
-               goto error;
-       }
--      if ((sbuf.st_uid != 0) || (sbuf.st_mode & S_IRWXG) ||
-+      if ((sbuf.st_uid != rpc_uid) || (sbuf.st_mode & S_IRWXG) ||
-           (sbuf.st_mode & S_IRWXO)) {
-               fprintf(stderr,
-               "rpcbind: invalid permissions on file = %s for reading\n",
-@@ -148,7 +148,7 @@
- }
- void
--read_warmstart()
-+read_warmstart(uid_t rpc_uid)
- {
-       rpcblist_ptr tmp_rpcbl = NULL;
- #ifdef PORTMAP
-@@ -156,11 +156,11 @@
- #endif
-       int ok1, ok2 = TRUE;
--      ok1 = read_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl);
-+      ok1 = read_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl, rpc_uid);
-       if (ok1 == FALSE)
-               return;
-       #ifdef PORTMAP
--      ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl);
-+      ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl, rpc_uid);
-       #endif
-       if (ok2 == FALSE) {
-               xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&tmp_rpcbl);
This page took 0.104717 seconds and 4 git commands to generate.