From db13d321d6566c8937a7dbf872d4b4410a9d79ae Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Nov 2004 14:25:10 +0000 Subject: portmap --- package/portmap/portmap-4.0-rpc_user.patch | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 package/portmap/portmap-4.0-rpc_user.patch (limited to 'package/portmap/portmap-4.0-rpc_user.patch') diff --git a/package/portmap/portmap-4.0-rpc_user.patch b/package/portmap/portmap-4.0-rpc_user.patch new file mode 100644 index 000000000..6ef0736d0 --- /dev/null +++ b/package/portmap/portmap-4.0-rpc_user.patch @@ -0,0 +1,59 @@ +diff -urN portmap_4/daemon.c portmap_4.new/daemon.c +--- portmap_4/daemon.c Thu Aug 3 18:07:22 2000 ++++ portmap_4.new/daemon.c Fri Aug 4 08:45:25 2000 +@@ -35,6 +35,7 @@ + static char sccsid[] = "@(#)daemon.c 5.3 (Berkeley) 12/28/90"; + #endif /* LIBC_SCCS and not lint */ + ++#include + #include + #include + #include +diff -urN portmap_4/pmap_check.c portmap_4.new/pmap_check.c +--- portmap_4/pmap_check.c Thu Aug 3 18:07:22 2000 ++++ portmap_4.new/pmap_check.c Thu Aug 3 18:29:51 2000 +@@ -40,6 +40,8 @@ + #include + #include + #include ++#include ++#include + #include + #ifdef SYSV40 + #include +@@ -149,11 +151,32 @@ + /* + * Give up root privileges so that we can never allocate a privileged + * port when forwarding an rpc request. ++ * ++ * Fix 8/3/00 Philipp Knirsch: First lookup our rpc user. If we find it, ++ * switch to that uid, otherwise simply resue the old bin user and print ++ * out a warning in syslog. + */ +- if (setuid(1) == -1) { +- syslog(LOG_ERR, "setuid(1) failed: %m"); +- exit(1); ++ ++ struct passwd *pwent; ++ ++ pwent = getpwnam("rpc"); ++ if (pwent == NULL) { ++ syslog(LOG_WARNING, "user rpc not found, reverting to user bin"); ++ if (setuid(1) == -1) { ++ syslog(LOG_ERR, "setuid(1) failed: %m"); ++ exit(1); ++ } + } ++ else { ++ if (setuid(pwent->pw_uid) == -1) { ++ syslog(LOG_WARNING, "setuid() to rpc user failed: %m"); ++ if (setuid(1) == -1) { ++ syslog(LOG_ERR, "setuid(1) failed: %m"); ++ exit(1); ++ } ++ } ++ } ++ + (void) signal(SIGINT, toggle_verboselog); + } + -- cgit v1.2.3