summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.h
Commit message (Collapse)AuthorAgeFilesLines
* Prevent shutdown while running dpkgJulian Andres Klode2019-05-031-0/+2
| | | | | | | As long as we are running dpkg, keep an inhibitor that blocks us from shutting down. LP: #1820886
* fileutl: Merge Popen variantsJulian Andres Klode2019-02-261-3/+1
|
* fileutl: Remove deprecated functions such as gzFd()Julian Andres Klode2019-02-261-15/+0
|
* gpgv: Use buffered writes for splitting clearsigned filesJulian Andres Klode2019-02-041-0/+6
| | | | | | This is safe here, as the code ensures that the file is flushed before it is being used. The next series should probably make GetTempFile() buffer writes by default.
* Override FileFd copy constructor to prevent copyingJulian Andres Klode2018-12-041-0/+1
| | | | | FileFd could be copied using the default copy constructor, which does not work, and then causes code to crash.
* Fix typo reported by codespell in code commentsDavid Kalnischkies2018-11-251-1/+1
| | | | | | | | No user visible change expect for some years old changelog entries, so we don't really need to add a new one for this… Reported-By: codespell Gbp-Dch: Ignore
* Remove obsolete RCS keywordsGuillem Jover2018-05-071-1/+0
| | | | Prompted-by: Jakub Wilk <jwilk@debian.org>
* apt-pkg: Add support for zstdJulian Andres Klode2018-03-121-2/+14
| | | | | | | zstd is a compression algorithm developed by facebook. At level 19, it is about 6% worse in size than xz -6, but decompression is multiple times faster, saving about 40% install time, especially with eatmydata on cloud instances.
* Run the ProxyAutoDetect script in the sandbox againJulian Andres Klode2017-10-221-0/+2
| | | | | | | | The previous change moved running the proxy detection program from the method to the main process, so it runs as root and not as _apt. This brings it back into the sandbox. Gbp-Dch: ignore
* show warnings instead of errors if files are unreadableDavid Kalnischkies2017-07-261-0/+1
| | | | | | | | | | 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-0/+22
| | | | | | 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-2/+2
| | | | | | | | | | | | | 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 chdir in acquire clean with unlinkatDavid Kalnischkies2017-06-261-0/+1
| | | | | | | | | | | | POSIX.1-2008 gives us a range of *at calls to deal with files including the unlinkat so we can remove a file from a directory based on a path to the file relative to the directory. (In our case here the path we have is just the filename) We avoid changing directories in this way which e.g. fails if the directory we started in no longer exists or is otherwise inaccessible. Closes: 860738
* Do not read stderr from proxy autodetection scriptsJulian Andres Klode2016-10-041-0/+3
| | | | | | | | | | | | | This fixes a regression introduced in commit 8f858d560e3b7b475c623c4e242d1edce246025a don't leak FD in AutoProxyDetect command return parsing which accidentally made the proxy autodetection code also read the scripts output on stderr, not only on stdout when it switched the code from popen() to Popen(). Reported-By: Tim Small <tim@seoss.co.uk>
* drop incorrect const attribute from DirectoryExistsDavid Kalnischkies2016-08-121-1/+1
| | | | | | | | | | | | | | | | | Since its existence in 2010 DirectoryExists was always marked with this attribute, but for no real reason. Arguably a check for the existence of the file is not modifying global state, so theoretically this shouldn't be a problem. It is wrong from a logical point of view through as between two calls the directory could be created so the promise we made to the compiler that it could remove the second call would be wrong, so API wise it is wrong. It's a bit mysterious that this is only observeable on ppc64el and can be fixed by reordering code ever so slightly, but in the end its more our fault for adding this attribute than the compilers fault for doing something silly based on the attribute. LP: 1473674
* implement socks5h proxy support for http methodDavid Kalnischkies2016-08-101-0/+1
| | | | | | | | | | | | | | | | | Socks support is a requested feature in sofar that the internet is actually believing Acquire::socks::Proxy would exist. It doesn't and this commit isn't adding it as that isn't how our configuration works, but it allows Acquire::http::Proxy="socks5h://…". The HTTPS method was changed already to support socks proxies (all versions) via curl. This commit implements only SOCKS5 (RFC1928) with no auth or pass&user auth (RFC1929), but not GSSAPI which is required by the RFC. The 'h' in the protocol name further indicates that DNS resolution is delegated to the socks proxy rather than performed locally. The implementation works and was tested with Tor as socks proxy for which implementing socks5h only can actually be considered a feature. Closes: 744934
* ensure Cnf::FindFile doesn't return files below /dev/nullDavid Kalnischkies2016-07-191-0/+2
| | | | | | | 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.
* edsp: try harder to not generate unneeded error messagesDavid Kalnischkies2016-05-201-6/+0
| | | | | | | | | | | The &= introduced in the EDSP-FileFd conversion isn't working to full satisfaction for multiple && clauses as the && has a higher binding than &= has, so that the methods were called even through they shouldn't have because of previous errors. Using variadic functions we can solve this in a slightly cleaner way bringing down the amount of 'broken pipe' errors for the error case of the dump resolver substantially. Git-Dch: Ignore
* convert EDSP to be based on FileFd instead of FILE*David Kalnischkies2016-05-201-0/+6
| | | | I doubt there is any non-src:apt usage of these interfaces.
* FileFd: (native) LZ4 supportJulian Andres Klode2016-01-071-1/+2
| | | | | Implement native support for LZ4 compression, using the official lz4 library.
* FileFd: Add a buffered writing modeJulian Andres Klode2015-12-271-0/+1
| | | | | This is somewhat experimental right now, and might not work for everyone, so it is on an opt-in basis.
* FildFd: Introduce a Flush() function and call it from Close()Julian Andres Klode2015-12-271-0/+1
| | | | The flush function can be used for buffered writers.
* shuffle compressor-specific code into private subclassesDavid Kalnischkies2015-12-221-0/+6
| | | | | | | | | | | | | | This isn't implementing any new features, it is "just" moving code around from FileFd methods which decided on each call how to handle the request by including all logic for all possible compressor backends in the method body to a model in which backend-specifics are implemented in a FileFdPrivate subclass. This avoids a big chunk of #ifdef's and should make it a tiny bit more obvious which backend uses which code. The execution of the idea is slightly uglified by the need to preserve ABI and API which causes liberal befriending. Git-Dch: Ignore
* add messages to our deprecation warnings in libaptDavid Kalnischkies2015-11-271-2/+2
| | | | Git-Dch: Ignore
* review of new/changed translatable program stringsJustin B Rye2015-11-211-1/+1
| | | | | Reference mail: https://lists.debian.org/debian-l10n-english/2015/11/msg00006.html
* wrap every unlink call to check for != /dev/nullDavid Kalnischkies2015-11-041-0/+1
| | | | | | | | | | | | | | | | Unlinking /dev/null is bad, we shouldn't do that. Also, we should print at least a warning if we tried to unlink a file but didn't manage to pull it of (ignoring the case were the file is /dev/null or doesn't exist in the first place). This got triggered by a relatively unlikely to cause problem in pkgAcquire::Worker::PrepareFiles which would while temporary uncompressed files (which are set to keep compressed) figure out that to files are the same and prepare for sharing by deleting them. Bad move. That also shows why not printing a warning is a bad idea as this hide the error for in non-root test runs. Git-Dch: Ignore
* ignore for _apt inaccessible TMPDIR in pkgAcqChangelogDavid Kalnischkies2015-08-311-0/+1
| | | | | | | | | | | | Using libpam-tmpdir caused us to create our download tmp directory in root's private tmp before changing to _apt, which wouldn't have access to it. By extending our GetTempDir method with an optional wrapper changing the effective user, we can test if a given user can access the directory and ignore TMPDIR if not instead of ignoring TMPDIR completely. Closes: 797270
* elimate duplicated code in pkgIndexFile subclassesDavid Kalnischkies2015-08-101-2/+3
| | | | | | | | Trade deduplication of code for a bunch of new virtuals, so it is actually visible how the different indexes behave cleaning up the interface at large in the process. Git-Dch: Ignore
* make all d-pointer * const pointersDavid Kalnischkies2015-08-101-19/+8
| | | | | | | | | | | | | | Doing this disables the implicit copy assignment operator (among others) which would cause hovac if used on the classes as it would just copy the pointer, not the data the d-pointer points to. For most of the classes we don't need a copy assignment operator anyway and in many classes it was broken before as many contain a pointer of some sort. Only for our Cacheset Container interfaces we define an explicit copy assignment operator which could later be implemented to copy the data from one d-pointer to the other if we need it. Git-Dch: Ignore
* ensure lists/ files have correct permissions after apt-cdrom addDavid Kalnischkies2015-04-191-1/+12
| | | | | | | | Its a bit unpredictable which permissons and owners we will encounter on a CD-ROM (or a USB stick, as apt-cdrom is responsible for those too), so we have to ensure in this codepath as well that everything is nicely setup without waiting for a 'apt-get update' to fix up the (potential) mess.
* Rename DropPrivs() to DropPrivileges()Michael Vogt2014-10-071-1/+1
| | | | Git-Dch: ignore
* DropPrivs: Document what it doesJulian Andres Klode2014-09-241-1/+11
| | | | Git-Dch: ignore
* Merge branch 'debian/sid' into debian/experimentalMichael Vogt2014-09-231-0/+2
|\ | | | | | | | | | | | | | | | | Conflicts: apt-pkg/acquire-item.cc apt-pkg/acquire-item.h apt-pkg/cachefilter.h configure.ac debian/changelog
| * SECURITY UPDATE for CVE-2014-{0488,0487,0489}Michael Vogt2014-09-161-0/+2
| | | | | | | | | | | | incorrect invalidating of unauthenticated data (CVE-2014-0488) incorect verification of 304 reply (CVE-2014-0487) incorrect verification of Acquire::Gzip indexes (CVE-2014-0489)
* | Merge remote-tracking branch 'mvo/feature/drop-rights' into debian/experimentalMichael Vogt2014-06-181-0/+4
|\ \ | | | | | | | | | | | | | | | Conflicts: apt-pkg/contrib/fileutl.cc apt-pkg/contrib/fileutl.h
| * | DropPrivs in the solvers (just to be on the safe side)Michael Vogt2014-06-111-0/+3
| |/
* | Merge remote-tracking branch 'mvo/feature/apt-install-deb' into ↵Michael Vogt2014-05-071-0/+18
|\ \ | | | | | | | | | debian/experimental
| * \ Merge branch 'feature/abspath' into feature/apt-install-debMichael Vogt2014-04-281-0/+4
| |\ \ | | | | | | | | | | | | | | | | Conflicts: test/libapt/fileutl_test.cc
| | * | add flAbsPath() as a wrapper to realpath()Michael Vogt2014-04-281-0/+4
| | |/
| * | Merge branch 'feature/popen' into feature/apt-install-debMichael Vogt2014-04-281-0/+12
| |\ \
| | * | Implement Popen() execv helper to avoid popen()Michael Vogt2014-04-281-0/+12
| | |/
| * / WIP local deb installMichael Vogt2014-04-281-0/+2
| |/
* | Merge branch 'debian/sid' into debian/experimentalMichael Vogt2014-05-071-14/+16
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: apt-pkg/cachefilter.h apt-pkg/contrib/fileutl.cc apt-pkg/contrib/netrc.h apt-pkg/deb/debsrcrecords.cc apt-pkg/init.h apt-pkg/pkgcache.cc debian/apt.install.in debian/changelog
| * Rename FileFd::Open() Perms to AccessModeMichael Vogt2014-04-101-8/+8
| | | | | | | | | | | | | | Bug lp:#1304657 was caused by confusion around the name Perms. The new name AccessMode should make it clear that its not the literal file permissions but instead the AccessMode passed to open() (i.e. the umask needs to be applied)
| * mark optional (private) symbols as hiddenDavid Kalnischkies2014-03-211-3/+3
| | | | | | | | | | | | | | | | This methods should not be used by anyone expect the library itself as they are helpers for the specific class and therefore perfect candidates for hidding. Git-Dch: Ignore
| * fix test/integration/test-apt-helperMichael Vogt2014-03-141-5/+6
| |\
| | * follow method attribute suggestions by gccDavid Kalnischkies2014-03-131-1/+1
| | | | | | | | | | | | | | | Git-Dch: Ignore Reported-By: gcc -Wsuggest-attribute={pure,const,noreturn}
| | * cleanup headers and especially #includes everywhereDavid Kalnischkies2014-03-131-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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)
| * | add hashsum support in apt-file download and add more testsMichael Vogt2014-03-121-0/+1
| |/
* | Merge branch 'debian/sid' into debian/experimentalMichael Vogt2014-02-271-0/+5
|\| | | | | | | | | | | | | | | Conflicts: apt-private/private-list.cc configure.ac debian/apt.install.in debian/changelog