]> git.pld-linux.org Git - packages/rpcbind.git/blame - rpcbind-rpcuser.patch
- rel 2
[packages/rpcbind.git] / rpcbind-rpcuser.patch
CommitLineData
d533ffb9
JR
1diff --git a/configure.in b/configure.in
2index 0e2f163..dfe5907 100644
3--- a/configure.in
4+++ b/configure.in
5@@ -37,6 +37,12 @@ if test "$warmstarts" = "true" ; then
6 AC_SUBST(statedir)
7 AC_DEFINE_UNQUOTED(RPCBIND_STATEDIR, "$statedir", [This defines the location where the state files will be kept for warm starts])
8 fi
9+AC_ARG_WITH(rpcuser,
10+ [ --with-rpcuser=user uid to use [root]],
11+ rpcuser=$withval,
12+ rpcuser=root)
13+ AC_SUBST(rpcuser)
14+AC_DEFINE_UNQUOTED(RPCBIND_USER, "$rpcuser", [This defines the uid to run as])
1dabcde2 15
d533ffb9
JR
16 AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h \
17 netinet/in.h stdlib.h string.h \
18diff --git a/src/rpcbind.c b/src/rpcbind.c
19index 55bbd8d..2a900d9 100644
20--- a/src/rpcbind.c
21+++ b/src/rpcbind.c
22@@ -68,6 +68,7 @@
23 #include <pwd.h>
24 #include <string.h>
25 #include <errno.h>
26+#include "config.h"
27 #include "rpcbind.h"
28
29 /*#define RPCBIND_DEBUG*/
30@@ -79,6 +80,11 @@ int doabort = 0; /* When debugging, do an abort on errors */
31
32 rpcblist_ptr list_rbl; /* A list of version 3/4 rpcbind services */
33
34+#ifdef RPCBIND_USER
35+char *rpcbinduser = RPCBIND_USER;
36+#else
37+char *rpcbinduser = NULL;
38+#endif
1dabcde2
JR
39
40 /* who to suid to if -s is given */
d533ffb9
JR
41 #define RUN_AS "daemon"
42@@ -206,15 +212,16 @@ main(int argc, char *argv[])
43 err(1, "fork failed");
44 }
1dabcde2 45
d533ffb9
JR
46- if (runasdaemon) {
47+ if (runasdaemon || rpcbinduser) {
48 struct passwd *p;
49+ char *id = runasdaemon ? RUN_AS : rpcbinduser;
1dabcde2 50
d533ffb9
JR
51- if((p = getpwnam(RUN_AS)) == NULL) {
52- syslog(LOG_ERR, "cannot get uid of daemon: %m");
53+ if((p = getpwnam(id)) == NULL) {
54+ syslog(LOG_ERR, "cannot get uid of '%s': %m", id);
55 exit(1);
56 }
57 if (setuid(p->pw_uid) == -1) {
58- syslog(LOG_ERR, "setuid to daemon failed: %m");
59+ syslog(LOG_ERR, "setuid to '%s' failed: %m", id);
60 exit(1);
61 }
62 }
63--- rpcbind-0.1.4/src/warmstart.c~ 2007-05-08 14:48:17.000000000 +0200
64+++ rpcbind-0.1.4/src/warmstart.c 2007-05-08 14:52:30.000000000 +0200
65@@ -113,7 +113,7 @@
66 "rpcbind: cannot stat file = %s for reading\n", filename);
67 goto error;
68 }
69- if ((sbuf.st_uid != 0) || (sbuf.st_mode & S_IRWXG) ||
70+ if ((sbuf.st_mode & S_IRWXG) ||
71 (sbuf.st_mode & S_IRWXO)) {
72 fprintf(stderr,
73 "rpcbind: invalid permissions on file = %s for reading\n",
This page took 0.037009 seconds and 4 git commands to generate.