From 1aeccbe51daa634e520f3c04cf4ebdd27352730e Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Fri, 19 Oct 2007 22:54:03 +0000 Subject: [PATCH] Forced EXT script location only to plugin's config directory. --- README | 9 +++++++-- config.c | 9 ++++++++- config.h | 7 +++++-- iptv.c | 3 ++- protocolext.c | 20 +++++++++++++------- setup.c | 6 +++--- 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/README b/README index a5f1695..349fbca 100644 --- a/README +++ b/README @@ -42,6 +42,8 @@ ln -s iptv-X.Y.Z iptv cd /put/your/path/here/VDR patch -p1 < PLUGINS/src/iptv/patches/vdr-X.Y.Z-pluginparam.patch cp sources.conf /path/to/vdrconf/ +mkdir -p /path/to/vdrconf/plugins/iptv +cp PLUGINS/src/iptv/examples/iptvstream.sh /path/to/vdrconf/plugins/iptv/ make make plugins ./vdr -P iptv @@ -95,8 +97,8 @@ Configuration: - channels.conf - TV4;IPTV:4:IPTV|EXT|/video/iptvstream.sh|4321:P:0:0:680:0:0:4:0:0:0 - TV3;IPTV:3:IPTV|FILE|/media/video.ts|5:P:0:514:670:2321:0:3:0:0:0 + TV4;IPTV:4:IPTV|EXT|iptvstream.sh|0:P:0:0:680:0:0:4:0:0:0 + TV3;IPTV:3:IPTV|FILE|/video/stream.ts|5:P:0:514:670:2321:0:3:0:0:0 TV2;IPTV:2:IPTV|HTTP|127.0.0.1/TS/2|3000:P:0:513:660:2321:0:2:0:0:0 TV1;IPTV:1:IPTV|UDP|127.0.0.1|1234:P:0:512:650:2321:0:1:0:0:0 ^ ^ ^ ^ ^ ^ @@ -128,6 +130,9 @@ Notes: port base number is 4321 and it can be configured via a commandline switch. The port range is defined by the number of IPTV devices (max. 8). +- The EXT protocol scripts must be located in the config directory of the + plugin. + Acknowledgements: - The IPTV section filtering code is derived from Linux kernel. diff --git a/config.c b/config.c index e47d029..352dc34 100644 --- a/config.c +++ b/config.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: config.c,v 1.16 2007/10/19 22:18:55 rahrenbe Exp $ + * $Id: config.c,v 1.17 2007/10/19 22:54:03 rahrenbe Exp $ */ #include "config.h" @@ -21,6 +21,7 @@ cIptvConfig::cIptvConfig(void) { for (unsigned int i = 0; i < sizeof(disabledFilters); ++i) disabledFilters[i] = -1; + memset(configDirectory, '\0', sizeof(configDirectory)); } unsigned int cIptvConfig::GetDisabledFiltersCount(void) @@ -41,3 +42,9 @@ void cIptvConfig::SetDisabledFilters(unsigned int Index, int Number) if (Index < sizeof(disabledFilters)) disabledFilters[Index] = Number; } + +void cIptvConfig::SetConfigDirectory(const char *directoryP) +{ + debug("cIptvConfig::SetConfigDirectory(%s)", directoryP); + strn0cpy(configDirectory, directoryP, sizeof(configDirectory)); +} diff --git a/config.h b/config.h index c05d394..1d2341a 100644 --- a/config.h +++ b/config.h @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: config.h,v 1.14 2007/10/19 22:18:55 rahrenbe Exp $ + * $Id: config.h,v 1.15 2007/10/19 22:54:03 rahrenbe Exp $ */ #ifndef __IPTV_CONFIG_H @@ -15,7 +15,7 @@ class cIptvConfig { -protected: +private: unsigned int readBufferTsCount; unsigned int tsBufferSize; unsigned int tsBufferPrefillRatio; @@ -24,6 +24,7 @@ protected: unsigned int sidScanning; unsigned int extListenPortBase; int disabledFilters[SECTION_FILTER_TABLE_SIZE]; + char configDirectory[255]; public: cIptvConfig(); @@ -34,6 +35,7 @@ public: unsigned int GetSectionFiltering(void) { return sectionFiltering; } unsigned int GetSidScanning(void) { return sidScanning; } unsigned int GetExtListenPortBase(void) { return extListenPortBase; } + const char *GetConfigDirectory(void) { return configDirectory; } unsigned int GetDisabledFiltersCount(void); int GetDisabledFilters(unsigned int Index); void SetTsBufferSize(unsigned int Size) { tsBufferSize = Size; } @@ -43,6 +45,7 @@ public: void SetSidScanning(unsigned int On) { sidScanning = On; } void SetExtListenPortBase(unsigned int PortNumber) { extListenPortBase = PortNumber; } void SetDisabledFilters(unsigned int Index, int Number); + void SetConfigDirectory(const char *directoryP); }; extern cIptvConfig IptvConfig; diff --git a/iptv.c b/iptv.c index 5c2f770..78571dc 100644 --- a/iptv.c +++ b/iptv.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: iptv.c,v 1.22 2007/10/19 22:18:55 rahrenbe Exp $ + * $Id: iptv.c,v 1.23 2007/10/19 22:54:03 rahrenbe Exp $ */ #include @@ -100,6 +100,7 @@ bool cPluginIptv::Initialize(void) { debug("cPluginIptv::Initialize()\n"); // Initialize any background activities the plugin shall perform. + IptvConfig.SetConfigDirectory(cPlugin::ConfigDirectory(PLUGIN_NAME_I18N)); return cIptvDevice::Initialize(deviceCount); } diff --git a/protocolext.c b/protocolext.c index ef7dba6..8ee39e8 100644 --- a/protocolext.c +++ b/protocolext.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: protocolext.c,v 1.8 2007/10/19 22:18:55 rahrenbe Exp $ + * $Id: protocolext.c,v 1.9 2007/10/19 22:54:03 rahrenbe Exp $ */ #include @@ -273,12 +273,18 @@ bool cIptvProtocolExt::Set(const char* Location, const int Parameter, const int { debug("cIptvProtocolExt::Set(): Location=%s Parameter=%d Index=%d\n", Location, Parameter, Index); if (!isempty(Location)) { - // Update script file and parameter - scriptFile = strcpyrealloc(scriptFile, Location); - scriptParameter = Parameter; - // Update listen port - listenPort = IptvConfig.GetExtListenPortBase() + Index; - } + struct stat stbuf; + // Update script file and parameter + free(scriptFile); + asprintf(&scriptFile, "%s/%s", IptvConfig.GetConfigDirectory(), Location); + if ((stat(scriptFile, &stbuf) != 0) || (strstr(scriptFile, "..") != 0)) { + error("ERROR: Non-existent script '%s'", scriptFile); + return false; + } + scriptParameter = Parameter; + // Update listen port + listenPort = IptvConfig.GetExtListenPortBase() + Index; + } return true; } diff --git a/setup.c b/setup.c index d495656..ff286a7 100644 --- a/setup.c +++ b/setup.c @@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: setup.c,v 1.38 2007/10/19 21:36:28 rahrenbe Exp $ + * $Id: setup.c,v 1.39 2007/10/19 22:54:03 rahrenbe Exp $ */ #include @@ -294,11 +294,11 @@ eOSState cIptvMenuEditChannel::ProcessKey(eKeys Key) if ((Key != kNone) && (data.protocol != oldProtocol)) { switch (data.protocol) { case eProtocolEXT: - strn0cpy(data.location, "/video/iptvstream.sh", sizeof(data.location)); + strn0cpy(data.location, "iptvstream.sh", sizeof(data.location)); data.parameter = 0; break; case eProtocolFILE: - strn0cpy(data.location, "/tmp/video.ts", sizeof(data.location)); + strn0cpy(data.location, "/video/stream.ts", sizeof(data.location)); data.parameter = 0; break; case eProtocolHTTP: