1 diff -ur rpcbind-0.1.4/src/rpcbind.c rpcbind-0.1.4-warmstart/src/rpcbind.c
2 --- rpcbind-0.1.4/src/rpcbind.c 2007-04-24 17:46:06.000000000 +0200
3 +++ rpcbind-0.1.4-warmstart/src/rpcbind.c 2007-04-24 17:44:38.000000000 +0200
5 void *nc_handle; /* Net config handle */
7 int maxrec = RPC_MAXDATASIZE;
10 parseargs(argc, argv);
13 (void) signal(SIGHUP, SIG_IGN);
14 (void) signal(SIGUSR1, SIG_IGN);
15 (void) signal(SIGUSR2, SIG_IGN);
19 + if((p = getpwnam(RUN_AS)) == NULL) {
20 + syslog(LOG_ERR, "cannot get uid of daemon: %m");
23 + rpc_uid = p->pw_uid;
29 + read_warmstart(rpc_uid);
39 - if((p = getpwnam(RUN_AS)) == NULL) {
40 - syslog(LOG_ERR, "cannot get uid of daemon: %m");
43 - if (setuid(p->pw_uid) == -1) {
44 + if (setuid(rpc_uid) == -1) {
45 syslog(LOG_ERR, "setuid to daemon failed: %m");
48 diff -ur rpcbind-0.1.4/src/rpcbind.h rpcbind-0.1.4-warmstart/src/rpcbind.h
49 --- rpcbind-0.1.4/src/rpcbind.h 2004-10-25 14:07:44.000000000 +0200
50 +++ rpcbind-0.1.4-warmstart/src/rpcbind.h 2007-04-24 17:44:52.000000000 +0200
54 void write_warmstart(void);
55 -void read_warmstart(void);
56 +void read_warmstart(uid_t rpc_uid);
58 char *addrmerge(struct netbuf *caller, char *serv_uaddr, char *clnt_uaddr, char *netid);
59 void network_init(void);
60 diff -ur rpcbind-0.1.4/src/warmstart.c rpcbind-0.1.4-warmstart/src/warmstart.c
61 --- rpcbind-0.1.4/src/warmstart.c 2004-10-25 14:07:42.000000000 +0200
62 +++ rpcbind-0.1.4-warmstart/src/warmstart.c 2007-04-24 17:45:36.000000000 +0200
66 /* These files keep the pmap_list and rpcb_list in XDR format */
67 -#define RPCBFILE "/tmp/rpcbind.file"
68 +#define RPCBFILE "/var/lib/rpcbind/rpcbind.file"
70 -#define PMAPFILE "/tmp/portmap.file"
71 +#define PMAPFILE "/var/lib/rpcbind/portmap.file"
74 static bool_t write_struct __P((char *, xdrproc_t, void *));
75 -static bool_t read_struct __P((char *, xdrproc_t, void *));
76 +static bool_t read_struct __P((char *, xdrproc_t, void *, uid_t));
79 write_struct(char *filename, xdrproc_t structproc, void *list)
84 -read_struct(char *filename, xdrproc_t structproc, void *list)
85 +read_struct(char *filename, xdrproc_t structproc, void *list, uid_t rpc_uid)
90 "rpcbind: cannot stat file = %s for reading\n", filename);
93 - if ((sbuf.st_uid != 0) || (sbuf.st_mode & S_IRWXG) ||
94 + if ((sbuf.st_uid != rpc_uid) || (sbuf.st_mode & S_IRWXG) ||
95 (sbuf.st_mode & S_IRWXO)) {
97 "rpcbind: invalid permissions on file = %s for reading\n",
103 +read_warmstart(uid_t rpc_uid)
105 rpcblist_ptr tmp_rpcbl = NULL;
107 @@ -156,11 +156,11 @@
111 - ok1 = read_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl);
112 + ok1 = read_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &tmp_rpcbl, rpc_uid);
116 - ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl);
117 + ok2 = read_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &tmp_pmapl, rpc_uid);
120 xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&tmp_rpcbl);