SOURCES: rpcbind-rpcuser.patch - Allow the uid that rpcbind runs a...

baggins baggins at pld-linux.org
Tue May 8 15:50:35 CEST 2007


Author: baggins                      Date: Tue May  8 13:50:35 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- Allow the uid that rpcbind runs as to be set during
  compile time with the --with-rpcuser configuration
  flag. The given uid will only be used if the -s
  flag is not given on the command.

---- Files affected:
SOURCES:
   rpcbind-rpcuser.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/rpcbind-rpcuser.patch
diff -u SOURCES/rpcbind-rpcuser.patch:1.1 SOURCES/rpcbind-rpcuser.patch:1.2
--- SOURCES/rpcbind-rpcuser.patch:1.1	Tue Apr 24 17:10:36 2007
+++ SOURCES/rpcbind-rpcuser.patch	Tue May  8 15:50:29 2007
@@ -1,11 +1,73 @@
---- rpcbind-0.1.4/src/rpcbind.c~	2004-12-02 17:37:16.000000000 +0100
-+++ rpcbind-0.1.4/src/rpcbind.c	2007-04-24 17:02:42.000000000 +0200
-@@ -81,7 +81,7 @@
+diff --git a/configure.in b/configure.in
+index 0e2f163..dfe5907 100644
+--- a/configure.in
++++ b/configure.in
+@@ -37,6 +37,12 @@ if test "$warmstarts" = "true" ; then
+ 		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_ARG_WITH(rpcuser,
++	[  --with-rpcuser=user uid to use [root]],
++	rpcuser=$withval,
++	rpcuser=root)
++	AC_SUBST(rpcuser)
++AC_DEFINE_UNQUOTED(RPCBIND_USER, "$rpcuser", [This defines the uid to run as])
  
+ AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
+                   netinet/in.h stdlib.h string.h \
+diff --git a/src/rpcbind.c b/src/rpcbind.c
+index 55bbd8d..2a900d9 100644
+--- a/src/rpcbind.c
++++ b/src/rpcbind.c
+@@ -68,6 +68,7 @@
+ #include <pwd.h>
+ #include <string.h>
+ #include <errno.h>
++#include "config.h"
+ #include "rpcbind.h"
+ 
+ /*#define RPCBIND_DEBUG*/
+@@ -79,6 +80,11 @@ int doabort = 0;	/* When debugging, do an abort on errors */
+ 
+ rpcblist_ptr list_rbl;	/* A list of version 3/4 rpcbind services */
+ 
++#ifdef RPCBIND_USER
++char *rpcbinduser = RPCBIND_USER;
++#else
++char *rpcbinduser = NULL;
++#endif
  
  /* who to suid to if -s is given */
--#define RUN_AS  "daemon"
-+#define RUN_AS  "rpc"
+ #define RUN_AS  "daemon"
+@@ -206,15 +212,16 @@ main(int argc, char *argv[])
+         		err(1, "fork failed");
+ 	}
  
- #define RPCBINDDLOCK "/var/run/rpcbind.lock"
+-	if (runasdaemon) {
++	if (runasdaemon || rpcbinduser) {
+ 		struct passwd *p;
++		char *id = runasdaemon ? RUN_AS : rpcbinduser;
  
+-		if((p = getpwnam(RUN_AS)) == NULL) {
+-			syslog(LOG_ERR, "cannot get uid of daemon: %m");
++		if((p = getpwnam(id)) == NULL) {
++			syslog(LOG_ERR, "cannot get uid of '%s': %m", id);
+ 			exit(1);
+ 		}
+ 		if (setuid(p->pw_uid) == -1) {
+-			syslog(LOG_ERR, "setuid to daemon failed: %m");
++			syslog(LOG_ERR, "setuid to '%s' failed: %m", id);
+ 			exit(1);
+ 		}
+ 	}
+--- rpcbind-0.1.4/src/warmstart.c~	2007-05-08 14:48:17.000000000 +0200
++++ rpcbind-0.1.4/src/warmstart.c	2007-05-08 14:52:30.000000000 +0200
+@@ -113,7 +113,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_mode & S_IRWXG) ||
+ 	    (sbuf.st_mode & S_IRWXO)) {
+ 		fprintf(stderr,
+ 		"rpcbind: invalid permissions on file = %s for reading\n",
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/rpcbind-rpcuser.patch?r1=1.1&r2=1.2&f=u



More information about the pld-cvs-commit mailing list