diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-23 19:33:32 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2012-04-23 19:33:32 +0200 |
commit | af13d1437cbcb383de89f126b316c02587e4b691 (patch) | |
tree | ef59465fbafa3dab7aa81070b2411f885695762f | |
parent | ec76891fa17c77f8fd28b9b6e11ef2d7547afe7e (diff) |
/dev/null is a special absolute path as it has no subdirectories
-rw-r--r-- | apt-pkg/contrib/configuration.cc | 9 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | test/libapt/configuration_test.cc | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index ce02f1bd2..4de17e3e1 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -194,7 +194,11 @@ string Configuration::FindFile(const char *Name,const char *Default) const // Absolute if (val.length() >= 1 && val[0] == '/') + { + if (val.compare(0, 9, "/dev/null") == 0) + val.erase(9); break; + } // ~/foo or ./foo if (val.length() >= 2 && (val[0] == '~' || val[0] == '.') && val[1] == '/') @@ -230,7 +234,12 @@ string Configuration::FindDir(const char *Name,const char *Default) const { string Res = FindFile(Name,Default); if (Res.end()[-1] != '/') + { + size_t const found = Res.rfind("/dev/null"); + if (found != string::npos && found == Res.size() - 9) + return Res; // /dev/null returning return Res + '/'; + } return Res; } /*}}}*/ diff --git a/debian/changelog b/debian/changelog index dc331dc55..558677345 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ apt (0.9.3) unstable; urgency=low * apt-pkg/contrib/configuration.cc: - add a more versatile Dump() method - normalize a bit by replacing // and /./ with / in FindFile + - /dev/null is a special absolute path as it has no subdirectories * apt-pkg/acquire-worker.cc: - use Dump() to generate the configuration message for sending * cmdline/apt-config.cc: @@ -21,7 +22,7 @@ apt (0.9.3) unstable; urgency=low - check with RealFileExists for scenario file as otherwise a directory like one provided with RootDir triggers the usage of EDSP - -- David Kalnischkies <kalnischkies@gmail.com> Mon, 23 Apr 2012 19:10:13 +0200 + -- David Kalnischkies <kalnischkies@gmail.com> Mon, 23 Apr 2012 19:32:29 +0200 apt (0.9.2) unstable; urgency=low diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 6b657a70c..87d5699ef 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -93,6 +93,11 @@ int main(int argc,const char *argv[]) { equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt"); equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude"); + Cnf.Set("Dir::State", "/dev/null"); + Cnf.Set("Dir::State::lists", "lists/"); + equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null"); + equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null"); + //FIXME: Test for configuration file parsing; // currently only integration/ tests test them implicitly |