summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2018-11-25 16:44:03 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2018-11-25 17:22:53 +0100
commitb38060dba0273f1981caba4502eb1ffc9f8fac0e (patch)
tree701003e402ecf9199d96f189f619948d77b02c01
parent37de1902919ac27d4527edc4210f1f927ea376ef (diff)
Allow to override the directory of a request in aptwebserver
The filename can be overridden, but sometimes it is useful to do it only for the directory-part of the filename – e.g. if you want to let a flat archive directory (like /var/cache/apt/archives) serve a pool-based request like /pool/a/apt_version.deb. Gbp-Dch: Ignore
-rw-r--r--test/interactive-helper/aptwebserver.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 5da715253..109364d7a 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -747,9 +747,16 @@ static void * handleClient(int const client, size_t const id) /*{{{*/
}
if (regexec(pattern, filename.c_str(), 0, 0, 0) == 0)
{
- filename = _config->Find("aptwebserver::overwrite::" + I->Tag + "::filename", filename);
- if (filename[0] == '/')
+ filename = _config->Find("aptwebserver::overwrite::" + I->Tag + "::filename", flNotDir(filename));
+ if (filename.find("/") == std::string::npos)
+ {
+ auto directory = _config->Find("aptwebserver::overwrite::" + I->Tag + "::directory", flNotFile(filename));
+ filename = flCombine(directory, filename);
+ }
+ if (filename.empty() == false && filename[0] == '/')
filename.erase(0,1);
+ if (filename.empty())
+ filename = "./";
regfree(pattern);
break;
}