summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/configuration.cc
Commit message (Collapse)AuthorAgeFilesLines
* configuration: Add MoveSubTree with overwrite=falseJulian Andres Klode2025-10-251-3/+12
|
* refactor: Deduplicate and Move SectionInSubTree to ConfigurationJulian Andres Klode2025-02-181-0/+33
| | | | | Deduplicate the copies in a central one, mark it unavailable to external users.
* string{=> _view} flNotDir(string{=> _view}). Configuration::{Cnd,}Set(Value: ↵наб2025-02-141-2/+2
| | | | string{=> _view})
* Rewrite hidden config option checker for more patternsDavid Kalnischkies2024-11-221-40/+75
| | | | | | | | | | | | | The previous version allowed only foo::*::bar as a pattern, now you can have as many starred parts as you want allowing for a finer control instead of hardcoding specific common star-values or giving up with **. It also adds a new INVALID type for an option to mark options which should not be used, but are covered by a pattern which would normally allow it. Our tests are more or less the only users of this hidden feature making this change not very risky even through it has no dedicated test itself.
* apt-pkg/contrib/configuration.cc: prepare for APT::StringView -> ↵наб2024-11-121-40/+39
| | | | std::string_view
* Modernize standard library includesJulian Andres Klode2024-02-201-5/+5
| | | | | | This was automated with sed and git-clang-format, and then I had to fix up the top of policy.cc by hand as git-clang-format accidentally indented it by two spaces.
* Prevent infinite loop in `ReadConfigFile`Adam Saponara2023-12-291-1/+1
| | | | | Break the loop on failure. Without this, the function goes into an infinite loop if `FName` is a directory.
* Address statements of public domainJulian Andres Klode2023-03-061-1/+5
|
* Spelling fixesVille Skyttä2021-11-271-1/+1
|
* configuration: Add missing #include <array>Julian Andres Klode2021-02-241-0/+1
| | | | | | | | | | | | | | As user "DaOfficialRolex" on GitHub pointed out: This is needed to allow for APT on iOS to compile correctly. If not included the two following errors happen while compiling APT. ~/apt/apt-pkg/contrib/configuration.cc:900:44: error: constexpr variable cannot have non-literal type 'const std::array<APT::StringView, 3>' constexpr std::array<APT::StringView, 3> magicComments { "clear"_sv, "include"_sv, "x-apt-configure-index"_sv }; ^ ~/apt/apt-pkg/contrib/configuration.cc:900:44: error: implicit instantiation of undefined template 'std::__1::array<APT::StringView, 3>' /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tuple:219:64: note: template is declared here template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array; ^
* Avoid overstepping bounds in config file parsingDavid Kalnischkies2021-02-031-60/+54
| | | | | | | Our configuration files are not security relevant, but having a parser which avoids crashing on them even if they are seriously messed up is not a bad idea anyway. It is also a good opportunity to brush up the code a bit avoiding a few small string copies with our string_view.
* Retire and deprecate _strtabexpandDavid Kalnischkies2021-02-031-20/+2
| | | | | | | | If the Configuration code calling this was any indication, it is hard to use – and even that monster still caused heap-buffer-overflow errors, so instead of trying to fix it, lets just use methods which are far easier to use. The question why this is done at all remains, but is left for another day as an exercise for the reader.
* Fail ConfigDir reading if directory listing failedDavid Kalnischkies2021-02-031-1/+4
| | | | | | We were printing an error and hence have non-zero exit code either way, but API wise it makes sense to have this properly reported back to the caller to propagate it down the chain e.g. while parsing #include stanzas.
* Fix some style warnings from cppcheckDavid Kalnischkies2019-11-261-4/+5
| | | | | | | | Unused variable, std::algorithms instead of raw for-loops. There should be no observeable difference in behaviour. Reported-By: cppcheck Gbp-Dch: Ignore
* configuration: Compare size first during lookupJulian Andres Klode2018-12-261-1/+1
|
* Use quoted tagnames in config dumpsDavid Kalnischkies2018-11-291-1/+1
| | | | | | | | | | | | | | Tagnames in configuration can include spaces (and other nasties) e.g. in repository-specific configuration options due to Origin/Label potentially containing a space. The configuration file format supports parsing quoted as well as encoded spaces, but the output generated by apt-config and other places which might be feedback into apt via parsing (e.g. before calling apt-key in our gpgv method) do not quote and hence produce invalid configuration files. Changing the default to be an encoded tagname ensures that the output of dump can be used as a config file, but other users might not expect this so that is technically a backward-breaking change.
* Remove obsolete RCS keywordsGuillem Jover2018-05-071-1/+0
| | | | Prompted-by: Jakub Wilk <jwilk@debian.org>
* show warnings instead of errors if files are unreadableDavid Kalnischkies2017-07-261-7/+4
| | | | | | | | | | We used to fail on unreadable config/preferences/sources files, but at least for sources we didn't in the past and it seems harsh to refuse to work because of a single file, especially as the error messages are inconsistent and end up being silly (like suggesting to run apt update to fix the problem…). LP: #1701852
* use FileFd to parse all apt configuration filesDavid Kalnischkies2017-07-261-17/+6
| | | | | | Using different ways of opening files means we have different behaviour and error messages for them, so by the same for all we can have more uniformity for users and apt developers alike.
* Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-121-5/+5
| | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* avoid malloc if option whitelist is disabled (default)David Kalnischkies2017-01-271-3/+8
| | | | | | | Config options are checked in various paths, so making "useless" memory allocations wastes time and can also cause problems like #852757. The unneeded malloc was added in ae73a2944a89e0d2406a2aab4a4c082e1e9da3f9. (We have no explicit malloc here – its std:string doing this internally)
* fix various typos reported by spellintianDavid Kalnischkies2017-01-191-1/+1
| | | | | | | | Most of them in (old) code comments. The two instances of user visible string changes the po files of the manpages are fixed up as well. Gbp-Dch: Ignore Reported-By: spellintian
* allow warning generation for non-whitelisted optionsDavid Kalnischkies2016-12-311-1/+160
| | | | | | | | | | | | | | | The idea is simple: Each¹ Find*( call starts with a call check if the given option (with the requested type) exists in the whitelist. The whitelist is specified via our configure-index file so that we have a better chance at keeping it current. the whitelist is loaded via a special (undocumented for now) configuration stanza and if none is loaded the empty whitelist will make it so that no warnings are shown. Much needs to be done still, but that is as good a time as any to take a snapshot of the current state and release it into the wild given that it found some bugs already and has no practical effect on users. ¹ not all in this iteration, but many
* ensure Cnf::FindFile doesn't return files below /dev/nullDavid Kalnischkies2016-07-191-9/+1
| | | | | | | Very unlikely, but if the parent is /dev/null, the child empty and the grandchild a value we returned /dev/null/value which doesn't exist, so hardly a problem, but for best operability we should be consistent in our work and return /dev/null always.
* remove 100-levels config nesting limitDavid Kalnischkies2016-05-031-38/+36
| | | | | | | | | | | | The actual reason for this commit isn't the limit – there isn't much point in using that much nesting – its in shutting up gcc mostly: apt/apt-pkg/contrib/configuration.cc: In function ‘bool ReadConfigFile(Configuration&, const string&, const bool&, const unsigned int&)’: apt/apt-pkg/contrib/configuration.cc:686:20: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations] string Stack[100]; ^ by replacing this with C++s handy std::stack container (adapter). Also cleans some whitespace noise from the file in the process.
* add binary-specific options via Binary scopeDavid Kalnischkies2015-11-041-0/+53
| | | | | | Especially with apt now, it can be useful to set an option only for apt and not for apt-get. Using a binary-specific subtree which is merged into the root seems like a simple enough trick to achieve this.
* remove the compatibility markers for 4.13 abiDavid Kalnischkies2015-08-101-6/+0
| | | | | | | | We aren't and we will not be really compatible again with the previous stable abi, so lets drop these markers (which never made it into a released version) for good as they have outlived their intend already. Git-Dch: Ignore
* configureable acquire targets to download additional filesDavid Kalnischkies2015-06-091-2/+2
| | | | | | | | First pass at making the acquire system capable of downloading files based on configuration rather than hardcoded entries. It is now possible to instruct 'deb' and 'deb-src' sources.list lines to download more than just Packages/Translation-* and Sources files. Details on how to do that can be found in the included documentation file.
* fix some new compiler warnings reported by gcc-5David Kalnischkies2015-03-161-5/+5
| | | | Git-Dch: Ignore
* explicit overload methods instead of adding parametersDavid Kalnischkies2014-11-081-0/+6
| | | | | | | | Adding a new parameter (with a default) is an ABI break, but you can overload a method, which is "just" an API break for everyone doing references to this method (aka: nobody). Git-Dch: Ignore
* fix Configuration::FindVector APIDavid Kalnischkies2014-09-291-5/+0
| | | | Git-Dch: Ignore
* fix some compile errors in the now enabled #if (APT_PKG_MAJOR >= 4 && ↵Michael Vogt2014-05-071-1/+3
| | | | APT_PKG_MINOR < 13)
* cleanup headers and especially #includes everywhereDavid Kalnischkies2014-03-131-3/+10
| | | | | | | | Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use)
* warning: extra ‘;’ [-Wpedantic]David Kalnischkies2014-03-131-2/+1
| | | | | Git-Dch: Ignore Reported-By: gcc -Wpedantic
* add default and override handling for Cnf::FindVectorDavid Kalnischkies2014-03-131-2/+12
| | | | | | Automatically handle the override of list options via its parent value which can even be a comma-separated list of values. It also adds an easy way of providing a default for the list.
* * lp:~mvo/apt/config-clear:Michael Vogt2013-08-151-0/+12
| | | | | | | - support Configuration.Clear() for a clear of the entire configuration Conflicts: debian/changelog
* fix off-by-one error and do not use magic constant of 100 when checking ↵Michael Vogt2013-07-251-1/+1
| | | | StackPost
* various simple changes to fix cppcheck warningsDavid Kalnischkies2013-03-101-1/+1
|
* /dev/null is a special absolute path as it has no subdirectoriesDavid Kalnischkies2012-04-231-0/+9
|
* normalize a bit by replacing // and /./ with / in FindFileDavid Kalnischkies2012-04-231-30/+38
|
* * apt-pkg/contrib/configuration.cc:David Kalnischkies2012-04-221-8/+64
| | | - add a more versatile Dump() method
* * apt-pkg/contrib/configuration.cc:David Kalnischkies2012-01-301-2/+8
| | | | | - do not stop parent transversal in FindDir if the value is empty See http://lists.debian.org/deity/2012/01/msg00053.html , too.
* * apt-pkg/contrib/configuration.cc:Michael Vogt2011-10-051-4/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | - fix double delete (LP: #848907) - ignore only the invalid regexp instead of all options * apt-pkg/acquire-item.h, apt-pkg/deb/debmetaindex.cc: - fix fetching language information by adding OptionalSubIndexTarget * methods/https.cc: - cleanup broken downloads properly * ftparchive/cachedb.cc: - fix buffersize in bytes2hex * apt-pkg/deb/deblistparser.cc: - fix crash when the dynamic mmap needs to be grown in LoadReleaseInfo (LP: #854090)
| * * apt-pkg/contrib/configuration.cc:Michael Vogt2011-09-131-4/+5
| | | | | | | | - fix double delete (LP: #848907) - ignore only the invalid regexp instead of all options
* | merge with debian/experimentalDavid Kalnischkies2011-09-131-4/+4
|\ \
| * | cppcheck complains about some possible speed improvements which could beDavid Kalnischkies2011-08-111-3/+3
| |/ | | | | | | | | | | done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types.
| * apt-pkg/contrib/configuration.cc: revert Configuration::Set() ABI breakMichael Vogt2011-07-151-1/+1
| |
* | reorder includes: add <config.h> if needed and include it at firstDavid Kalnischkies2011-09-131-1/+4
|/
* * apt-pkg/init.cc:David Kalnischkies2011-07-061-1/+14
| | | - use CndSet in pkgInitConfig (Closes: #629617)
* * apt-pkg/contrib/configuration.cc:David Kalnischkies2010-08-281-3/+11
| | | | - fix autoremove by using correct config-option name and don't make faulty assumptions in error handling (Closes: #594689)