1
0
forked from rpms/rpcbind

Reworked how the rpcuser id is set

This commit is contained in:
Steve Dickson 2007-04-03 13:22:24 +00:00
parent 5af042e80a
commit d16c7a420b
3 changed files with 75 additions and 2 deletions

View File

@ -0,0 +1,68 @@
--- rpcbind-0.1.4/src/rpcbind.c.orig 2004-12-02 11:37:16.000000000 -0500
+++ rpcbind-0.1.4/src/rpcbind.c 2007-04-03 09:03:12.000000000 -0400
@@ -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 @@
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"
@@ -206,15 +212,16 @@
err(1, "fork failed");
}
- 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/config.h.in.orig 2007-04-03 09:02:35.000000000 -0400
+++ rpcbind-0.1.4/src/config.h.in 2007-04-03 09:02:49.000000000 -0400
@@ -1,2 +1,6 @@
-/* this define where the state files live for warm starts */
+
+/* This defines where the state files live for warm starts */
#undef RPCBIND_STATEDIR
+
+/* This defines the uid to run as */
+#undef RPCBIND_USER
--- rpcbind-0.1.4/configure.in.orig 2007-04-03 09:02:35.000000000 -0400
+++ rpcbind-0.1.4/configure.in 2007-04-03 09:02:49.000000000 -0400
@@ -37,6 +37,12 @@
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 \

View File

@ -61,7 +61,10 @@ stop() {
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
[ $RETVAL -eq 0 ] && {
rm -f /var/lock/subsys/$prog
rm -f /var/run/rpcbind*
}
return $RETVAL
}

View File

@ -38,7 +38,7 @@ RPC calls on a server on that machine.
%patch1 -p1
%patch2 -p1
%patch3 -p1
#%patch4 -p1
%patch4 -p1
%build
%ifarch s390 s390x
@ -48,6 +48,7 @@ PIE="-fpie"
%endif
export PIE
RPCBUSR=rpc
RPCBDIR=/var/lib/rpcbind
CFLAGS="`echo $RPM_OPT_FLAGS $ARCH_OPT_FLAGS $PIE`"
@ -55,6 +56,7 @@ autoreconf -fisv
%configure CFLAGS="$CFLAGS" LDFLAGS="-pie" \
--enable-warmstarts \
--with-statedir="$RPCBDIR" \
--with-rpcuser="$RPCBUSR" \
--enable-debug
make all