summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2010-01-17 12:27:01 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2010-01-17 12:27:01 +0100
commitc198a259432a5ee612ac8dd211f8017f0786fedb (patch)
tree41ae5933cfac61d345c449a56d33a7dbde04169b
parent97e4dbe7737852144e97e4edff36be95f39c5cc5 (diff)
downloadvdr-c198a259432a5ee612ac8dd211f8017f0786fedb.tar.gz
vdr-c198a259432a5ee612ac8dd211f8017f0786fedb.tar.bz2
If svdrphosts.conf contains only the address of the local host, the SVDRP port is opened only for the local host
-rw-r--r--CONTRIBUTORS2
-rw-r--r--HISTORY2
-rw-r--r--config.c18
-rw-r--r--config.h4
-rw-r--r--svdrp.c4
5 files changed, 26 insertions, 4 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 1c1da690..4ab11a85 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -2526,6 +2526,8 @@ Valdemaras Pipiras <valdemaras@ambernet.lt>
Manuel Reimer <Manuel.Reimer@gmx.de>
for fixing saving terminal settings when running in background
+ for making the SVDRP port open only for the local host if svdrphosts.conf
+ contains only the address of the local host
Rene van den Braken <rene@vandenbraken.name>
for reporting a bug in writing the PCR pid into the PMT in
diff --git a/HISTORY b/HISTORY
index 02ca3df3..9ab71fb3 100644
--- a/HISTORY
+++ b/HISTORY
@@ -6283,3 +6283,5 @@ Video Disk Recorder Revision History
- The "Edit timer" menu can now set the folder for the recording from a list of
folders stored in "folders.conf".
- Updated the Italian OSD texts (thanks to Diego Pierotto).
+- If svdrphosts.conf contains only the address of the local host, the SVDRP port
+ is opened only for the local host (thanks to Manuel Reimer).
diff --git a/config.c b/config.c
index 1605902d..9c73e872 100644
--- a/config.c
+++ b/config.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.c 2.7 2010/01/16 14:27:29 kls Exp $
+ * $Id: config.c 2.8 2010/01/17 12:22:56 kls Exp $
*/
#include "config.h"
@@ -118,6 +118,11 @@ bool cSVDRPhost::Parse(const char *s)
return result != 0 && (mask != 0 || addr.s_addr == 0);
}
+bool cSVDRPhost::IsLocalhost(void)
+{
+ return addr.s_addr == htonl(INADDR_LOOPBACK);
+}
+
bool cSVDRPhost::Accepts(in_addr_t Address)
{
return (Address & mask) == (addr.s_addr & mask);
@@ -276,6 +281,17 @@ cCommands RecordingCommands;
cSVDRPhosts SVDRPhosts;
+bool cSVDRPhosts::LocalhostOnly(void)
+{
+ cSVDRPhost *h = First();
+ while (h) {
+ if (!h->IsLocalhost())
+ return false;
+ h = (cSVDRPhost *)h->Next();
+ }
+ return true;
+}
+
bool cSVDRPhosts::Acceptable(in_addr_t Address)
{
cSVDRPhost *h = First();
diff --git a/config.h b/config.h
index 651e9ae7..68354b80 100644
--- a/config.h
+++ b/config.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: config.h 2.18 2010/01/16 13:33:10 kls Exp $
+ * $Id: config.h 2.19 2010/01/17 12:22:21 kls Exp $
*/
#ifndef __CONFIG_H
@@ -72,6 +72,7 @@ private:
public:
cSVDRPhost(void);
bool Parse(const char *s);
+ bool IsLocalhost(void);
bool Accepts(in_addr_t Address);
};
@@ -190,6 +191,7 @@ class cCommands : public cConfig<cCommand> {};
class cSVDRPhosts : public cConfig<cSVDRPhost> {
public:
+ bool LocalhostOnly(void);
bool Acceptable(in_addr_t Address);
};
diff --git a/svdrp.c b/svdrp.c
index b181fcd5..cb9a9351 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
- * $Id: svdrp.c 2.7 2010/01/03 15:41:26 kls Exp $
+ * $Id: svdrp.c 2.8 2010/01/17 12:23:31 kls Exp $
*/
#include "svdrp.h"
@@ -79,7 +79,7 @@ bool cSocket::Open(void)
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();