Re: [Patch] Allow to limit SVDRP port to given IP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I've attached a second patch. This patch changes VDR's svdrp port handling in the following way: If only the localhost item is found in svdrphosts.conf, then the port is attached to "INADDR_LOOPBACK", which makes it impossible to reach the port from outside. As soon as even one additional item is added, the port is opened to "INADDR_ANY", again, so the port is accessible from network. This way, the default configuration of VDR is "rock solid" and there should be no need to disable svdrp at all. We also have no additional configuration mechanisms. The user only has to work with svdrphosts.conf, as he did with previous VDR versions.

CU

Manuel
-- 
()  ascii ribbon campaign - against html mail
/\                        - gegen HTML-Mail
answers as html mail will be deleted automatically!
Antworten als HTML-Mail werden automatisch gelöscht!

GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
diff -ruN -x Make.config -x Makefile -x dvbdevice.h vdr-1.6.0-2.org/config.c vdr-1.6.0-2/config.c
--- vdr-1.6.0-2.org/config.c	2008-02-17 14:39:00.000000000 +0100
+++ vdr-1.6.0-2/config.c	2010-01-09 18:32:22.626879490 +0100
@@ -121,6 +121,11 @@
   return (Address & mask) == (addr.s_addr & mask);
 }
 
+bool cSVDRPhost::IsLocalhost(void)
+{
+  return (addr.s_addr == htonl(INADDR_LOOPBACK));
+}
+
 // --- cCommands -------------------------------------------------------------
 
 cCommands Commands;
@@ -141,6 +146,17 @@
   return false;
 }
 
+bool cSVDRPhosts::LocalhostOnly(void)
+{
+  cSVDRPhost *h = First();
+  while (h) {
+        if (!h->IsLocalhost())
+           return false;
+        h = (cSVDRPhost *)h->Next();
+        }
+  return true;
+}
+
 // --- cSetupLine ------------------------------------------------------------
 
 cSetupLine::cSetupLine(void)
diff -ruN -x Make.config -x Makefile -x dvbdevice.h vdr-1.6.0-2.org/config.h vdr-1.6.0-2/config.h
--- vdr-1.6.0-2.org/config.h	2010-01-09 18:45:11.477536875 +0100
+++ vdr-1.6.0-2/config.h	2010-01-09 18:29:36.565516740 +0100
@@ -73,6 +73,7 @@
   cSVDRPhost(void);
   bool Parse(const char *s);
   bool Accepts(in_addr_t Address);
+  bool IsLocalhost(void);
   };
 
 template<class T> class cConfig : public cList<T> {
@@ -164,6 +165,7 @@
 class cSVDRPhosts : public cConfig<cSVDRPhost> {
 public:
   bool Acceptable(in_addr_t Address);
+  bool LocalhostOnly(void);
   };
 
 extern cCommands Commands;
diff -ruN -x Make.config -x Makefile -x dvbdevice.h vdr-1.6.0-2.org/svdrp.c vdr-1.6.0-2/svdrp.c
--- vdr-1.6.0-2.org/svdrp.c	2010-01-09 18:45:11.535528281 +0100
+++ vdr-1.6.0-2/svdrp.c	2010-01-09 18:34:11.211458832 +0100
@@ -79,7 +79,7 @@
      struct sockaddr_in name;
      name.sin_family = AF_INET;
      name.sin_port = htons(port);
-     name.sin_addr.s_addr = htonl(INADDR_ANY);
+     name.sin_addr.s_addr = SVDRPhosts.LocalhostOnly() ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
      if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) {
         LOG_ERROR;
         Close();
_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux