]> git.pld-linux.org Git - packages/rpcbind.git/blob - rpcbind-warmstart.patch
- portmap replacement
[packages/rpcbind.git] / rpcbind-warmstart.patch
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
4 @@ -125,6 +125,7 @@
5         void *nc_handle;        /* Net config handle */
6         struct rlimit rl;
7         int maxrec = RPC_MAXDATASIZE;
8 +       uid_t rpc_uid = 0;
9  
10         parseargs(argc, argv);
11  
12 @@ -187,9 +188,19 @@
13         (void) signal(SIGHUP, SIG_IGN);
14         (void) signal(SIGUSR1, SIG_IGN);
15         (void) signal(SIGUSR2, SIG_IGN);
16 +
17 +       if (runasdaemon) {
18 +               struct passwd *p;
19 +               if((p = getpwnam(RUN_AS)) == NULL) {
20 +                       syslog(LOG_ERR, "cannot get uid of daemon: %m");
21 +                       exit(1);
22 +               }
23 +               rpc_uid = p->pw_uid;
24 +       }
25 +
26  #ifdef WARMSTART
27         if (warmstart) {
28 -               read_warmstart();
29 +               read_warmstart(rpc_uid);
30         }
31  #endif
32         if (debugging) {
33 @@ -207,13 +218,7 @@
34         }
35  
36         if (runasdaemon) {
37 -               struct passwd *p;
38 -
39 -               if((p = getpwnam(RUN_AS)) == NULL) {
40 -                       syslog(LOG_ERR, "cannot get uid of daemon: %m");
41 -                       exit(1);
42 -               }
43 -               if (setuid(p->pw_uid) == -1) {
44 +               if (setuid(rpc_uid) == -1) {
45                         syslog(LOG_ERR, "setuid to daemon failed: %m");
46                         exit(1);
47                 }
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
51 @@ -130,7 +130,7 @@
52  #endif
53  
54  void write_warmstart(void);
55 -void read_warmstart(void);
56 +void read_warmstart(uid_t rpc_uid);
57  
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
63 @@ -54,13 +54,13 @@
64  
65  
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"
69  #ifdef PORTMAP
70 -#define        PMAPFILE        "/tmp/portmap.file"
71 +#define        PMAPFILE        "/var/lib/rpcbind/portmap.file"
72  #endif
73  
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));
77  
78  static bool_t
79  write_struct(char *filename, xdrproc_t structproc, void *list)
80 @@ -98,7 +98,7 @@
81  }
82  
83  static bool_t
84 -read_struct(char *filename, xdrproc_t structproc, void *list)
85 +read_struct(char *filename, xdrproc_t structproc, void *list, uid_t rpc_uid)
86  {
87         FILE *fp;
88         XDR xdrs;
89 @@ -109,7 +109,7 @@
90                 "rpcbind: cannot stat file = %s for reading\n", filename);
91                 goto error;
92         }
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)) {
96                 fprintf(stderr,
97                 "rpcbind: invalid permissions on file = %s for reading\n",
98 @@ -148,7 +148,7 @@
99  }
100  
101  void
102 -read_warmstart()
103 +read_warmstart(uid_t rpc_uid)
104  {
105         rpcblist_ptr tmp_rpcbl = NULL;
106  #ifdef PORTMAP
107 @@ -156,11 +156,11 @@
108  #endif
109         int ok1, ok2 = TRUE;
110  
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);
113         if (ok1 == FALSE)
114                 return;
115         #ifdef PORTMAP
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);
118         #endif
119         if (ok2 == FALSE) {
120                 xdr_free((xdrproc_t) xdr_rpcblist_ptr, (char *)&tmp_rpcbl);
This page took 0.083746 seconds and 3 git commands to generate.