--- 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 #include #include +#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 \