1 diff -urN portmap_4/daemon.c portmap_4.new/daemon.c
2 --- portmap_4/daemon.c Thu Aug 3 18:07:22 2000
3 +++ portmap_4.new/daemon.c Fri Aug 4 08:45:25 2000
5 static char sccsid[] = "@(#)daemon.c 5.3 (Berkeley) 12/28/90";
6 #endif /* LIBC_SCCS and not lint */
12 diff -urN portmap_4/pmap_check.c portmap_4.new/pmap_check.c
13 --- portmap_4/pmap_check.c Thu Aug 3 18:07:22 2000
14 +++ portmap_4.new/pmap_check.c Thu Aug 3 18:29:51 2000
16 #include <rpc/pmap_prot.h>
20 +#include <sys/types.h>
21 #include <sys/signal.h>
23 #include <netinet/in.h>
26 * Give up root privileges so that we can never allocate a privileged
27 * port when forwarding an rpc request.
29 + * Fix 8/3/00 Philipp Knirsch: First lookup our rpc user. If we find it,
30 + * switch to that uid, otherwise simply resue the old bin user and print
31 + * out a warning in syslog.
33 - if (setuid(1) == -1) {
34 - syslog(LOG_ERR, "setuid(1) failed: %m");
37 + struct passwd *pwent;
39 + pwent = getpwnam("rpc");
40 + if (pwent == NULL) {
41 + syslog(LOG_WARNING, "user rpc not found, reverting to user bin");
42 + if (setuid(1) == -1) {
43 + syslog(LOG_ERR, "setuid(1) failed: %m");
48 + if (setuid(pwent->pw_uid) == -1) {
49 + syslog(LOG_WARNING, "setuid() to rpc user failed: %m");
50 + if (setuid(1) == -1) {
51 + syslog(LOG_ERR, "setuid(1) failed: %m");
57 (void) signal(SIGINT, toggle_verboselog);