summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2018-08-30dpkg-query: Split enqperpackage() into each different actionGuillem Jover1-66/+115
2018-08-30dpkg-query: Flush output for --status, --print-avail and --listfiles at the endGuillem Jover1-2/+1
Do not flush the output on each entry output, instead wait until we have finished to flush it all out. This should speed up the output.
2018-08-30dpkg: Fix use after free in maintainer scripts handlingGuillem Jover1-3/+2
Fixes: commit 44b0bf1a576e3b0cfcb4c87f18d4195c3ffccb8f
2018-08-30dpkg-query: Run --list output through a pager if we are on a terminalGuillem Jover1-79/+31
The current code, checks whether we are running on a terminal, and then truncates the output fields so that it can fit within. This causes data loss and can confuse the user depending where the cut point has happened. Instead we remove that logic, and always redirect the outout through a pager in case we are running on a terminal, which gives full information and does not necessarily emit ugly output. Closes: #898603
2018-08-30libdpkg, dpkg: Use new pager spawning supportGuillem Jover1-7/+12
Use it instead of open-coding it, or piping it via a shell invocation, which required metacharacter escaping.
2018-08-30libdpkg: Split pager specific code into its own moduleGuillem Jover1-1/+2
We also namespace the pager function with the module name.
2018-08-30Switch from strchr() + strlen() to strchrnul()Guillem Jover2-6/+7
2018-08-30libdpkg: Split push_cleanup() into push_cleanup_fallback()Guillem Jover6-23/+23
We separate the function in one that takes one callback, and another that takes two. This simplifies most of the call sites which only need one callback.
2018-08-30libdpkg: Switch to a new tiny struct to track file ondisk identityGuillem Jover1-8/+12
We only need the device and inode numbers for a given file to be able to compare them for identity. Avoid storing the entire struct stat which is rather fat.
2018-08-30libdpkg: Move db-fsys code from src to lib/dpkgGuillem Jover25-1094/+19
This will prepare the ground for external programs to start using libdpkg to access the dpkg fsys database via a proper API, instead of messing with the on-disk layout in so many improper ways.
2018-08-30dpkg: Move struct perpackagestate handling into its own fileGuillem Jover5-16/+48
This is not really part of the fsys db handling, and we are not making use of it anymore in it, so let's move it somewhere else more appropriate.
2018-08-30libdpkg: Move files list information from dpkg clientdata to pkginfoGuillem Jover7-59/+32
This will make it possible to move the fsys database parsing and dumping code out from dpkg into libdpkg. This is general package information, even if some clients might not be interested in its contents, such as frontends that just manage metadata and drive dpkg itself.
2018-08-30dpkg: Check that clientdata is allocated before using itGuillem Jover3-2/+5
For functions that are supposed to just check the state of a package in a read-only way, make sure the clientdata is allocated, instead of just calling ensure_package_clientdata().
2018-08-30dpkg: Call ensure_package_clientdata() defensivelyGuillem Jover5-0/+9
We want to stop calling this function from the fsys loading code, so we should make very sure it is being called before we access the clientdata members, otherwise we'll just segfault.
2018-08-30libdpkg: Rename struct pkginfo files member to archivesGuillem Jover3-10/+12
Rename matching types and macros, so that the purpose of the symbols is clear, and to open the way for moving the fsys files list from the dpkg clientdata.
2018-08-01dpkg-statoverride: Remove redundant checkGuillem Jover1-1/+1
The condition is checking for the same multiple times. Warned-by: cppcheck
2018-07-24Use Synopsis instead of Summary for the short DescriptionGuillem Jover2-3/+3
This unifies the term with the rest of the codebase, and makes it more descriptive.
2018-06-22dpkg: Check for ldconfig command only on platforms that do have itGuillem Jover1-1/+2
We should implement a whitelist here, instead of a blacklist. Not all ELF based libc do have a ldconfig command.
2018-05-10dpkg-divert: Do not assume that diversions are always presentGuillem Jover1-3/+3
Several code paths assumed that the fsys nodes were only present when they contained diversions, and no other nodes would be present, thus did not make sure to check whether the divert struct members were valid. With the switch to a single fsys underlying implementation now triggers can vivify namenodes in the hash, so we need to check whether the members are valid all the time. Fixes: commit 2d7566140335d5338e5a98278d4df762936f67f4 Reported-by: Sven Joachim <svenjoac@gmx.de> Bisected-by: Sven Joachim <svenjoac@gmx.de>
2018-05-04dpkg: Print the environment variables setup for the conffile shellGuillem Jover1-0/+4
Make these variables more discoverable by printing them as a list before spawning the conffile shell.
2018-05-04dpkg: Fix a short-lived file descriptor leakGuillem Jover1-0/+2
Warned-by: coverity
2018-05-04libdpkg: Move control database code into db-ctrl modulesGuillem Jover18-597/+14
This continues the work to generalize and make these interfaces available to other users beside dpkg itself.
2018-05-03libdpkg: Use a single struct filenamenode definitionGuillem Jover2-7/+3
The struct filenamenode hash implementation is lightweight, and once split from the bulk of the on-disk database handling there's no point in reimplementing it, and then redefining the same struct in multiple places, which is rather confusing for the reader, and even for static analyzers. Closes: #746766
2018-05-03libdpkg: Move filesystem nodename hash implementation into a new moduleGuillem Jover2-330/+1
2018-05-03dpkg-divert: Warn when using --rename on a file from an Essential packageGuillem Jover1-0/+30
Renaming a file from dpkg-divert for an Essential package is very dangerous, because that file will not be available until dpkg has unpacked the diverting package, which might render the system non-functional.
2018-05-03dpkg-divert: Warn when using --add or --remove w/o --rename or --no-renameGuillem Jover2-5/+20
Using --no-rename as the default optimizes for the wrong case, as that's the exception, and while the safest option, it is needed only by packages that are part of the pseudo-Essential set. It's also cumbersome for the --local case. We will emit a warning asking those to be explicit, so that we can switch the default to --rename during the 1.20.x cycle. Prompted-by: Paul Wise <pabs@debian.org>
2018-05-03dpkg-divert: Add new --no-rename optionGuillem Jover1-1/+3
Document its intended usage and how it differs from --rename. This will make it possible to do a behavior switch during the 1.20.x release cycle.
2018-05-03dpkg: Add new fsys_hash_entries() function to abstract nfiles accessGuillem Jover2-2/+10
This will be needed when moving the fsys hash implementation into libdpkg.
2018-05-03src: Fix database modules to not depend unnecessarily on main.hGuillem Jover2-2/+2
2018-03-26Use internerr() or BUG() instead of assert()Guillem Jover9-35/+79
The problem with assert() is that it does not print the contents of the variables. It also can be disabled on NDEBUG. But we always want these consistency checks no matter what, and they are not performance sensitive anyway. Enable -Wno-nonnull-compare so that we can keep doing run-time non-NULL checks in functions, instead of just compile-time checks.
2018-03-26dpkg: Switch DEBIAN/conffile parsing assert() into an ohshit()Guillem Jover1-1/+2
This is a run-time error, not a programming error.
2018-02-19dpkg: Increment the line number on --set-selections on unknown packagesGuillem Jover1-0/+1
When the package is not known, we do an early skip to the next loop iteration, but forgot to increment the line number, which means that these will be off. Closes: #888983 Reported-by: Heinz Repp <heinz.repp@arcor.de>
2017-10-17dpkg: Print the package name on maintainter script errorsGuillem Jover1-7/+22
When processing an archive or a package, we can call maintainer script for other packages. Not printing the package name for the script that failed means we can get very confusing output. Closes: #877521
2017-05-17dpkg: Fix digest inference for shared conffilesGuillem Jover1-5/+1
The code in charge of inferring the digest for a conffile was checking the owning package status twice, and ignoring conffiles with a status lower than "unpacked" even if they had been configured previously and their md5sums were valid. This was causing bogus takeover unpack errors. Fixes: commit 05a8ddb482419d110571679a29bcd25e3c2b036d Closes: #861217 Stable-Candidate: 1.17.x
2017-05-17dpkg: Fix conffile takeover handling during unpack on --root or diversionsGuillem Jover1-8/+1
The current code was trying to stat(2) a conffile without taking into account a specified root directory, nor any possible diversions. But the check based on the device and inode was pretty much unnecessary because a simple string comparison is enough here, which as a bogus solves both problems by reducing the code size. Closes: #837051, #858004 Stable-Candidate: 1.17.x
2017-05-06doc: Spelling fixesGuillem Jover1-1/+1
Spotted-by: Josh Soref <jsoref@gmail.com>
2017-05-06doc: Spelling fixesJosh Soref5-5/+5
Signed-off-by: Guillem Jover <guillem@debian.org>
2017-02-26dpkg: Add a comment on any switch case that falls throughGuillem Jover2-2/+5
Warned-by: gcc-7
2017-01-22doc: Fix typos in documentation and code commentsGuillem Jover2-2/+2
Warned-by: codespell, spellintian
2016-12-17dpkg: Allow readlink(2) returning a size smaller than stat(2)Guillem Jover2-3/+12
Some bogus filesystems do not return the actual symlink size in st_size, which contradicts POSIX. But allowing the case where the returned size is smaller than the one used to allocate memory is harmless, although suspect. Let it through, but still print a warning so that users can install stuff but are reminded they need to get a fixed filesystem in place. This has affected at least ecryptfs in the past and now file-based encryption support in ext4 on Android N. Reported-by: Jay Freeman <saurik@saurik.com>
2016-12-17dpkg: Add new --validate-<thing> commandsGuillem Jover3-3/+86
These commands make it possible to test if several of those <thing>s have a valid syntax. The current list of supported things is «pkgname», «trigname», «archname» and «version».
2016-12-17dpkg: Fix typo in code commentGuillem Jover1-1/+1
2016-11-11dpkg: Fix use after free issue on error summaryGuillem Jover1-2/+3
We are releasing the dpkg database now after running the commands, which means that the postponed error reporting summary was trying to print messages that had already been freed from the database memory pool. Duplicate the passed strings so that we are impervious to the database life-cycle. Regression introduced in commit 3404fd24ef8020b4d6dc17adb82d7e6c035d90dc. Closes: #843874
2016-10-30dpkg: Give more information on --set-selections warningsGuillem Jover1-2/+3
Mention that the package cannot be found on the status nor available database, and that to the FAQ. Closes: #842230
2016-10-30dpkg: Do not log nor print duplicate removal actionGuillem Jover1-3/+8
We print “Removing <package> (<version>)” lines and log remove action twice when purging a package from frontends, because they usually first call --remove and then --purge sequentially. When purging a package which is already in config-files (i.e. it has been removed before), do not print nor log the remove action.
2016-10-30Cast off_t variables to intmax_t when printing them with %jdGuillem Jover2-3/+4
Warned-by: clang
2016-10-30dpkg: Initialize and reset the filesdb in --command-fdGuillem Jover1-0/+4
2016-10-30dpkg: Add new files_db_reset() functionGuillem Jover2-0/+10
2016-10-30dpkg: Track newargs in a different variable to avoid modifying itGuillem Jover1-3/+4
The dpkg_options_parse() call modifies the argv argument which means that if we try to free it later on or realloc it we will crash.
2016-10-30dpkg: Shutdown the modstatdb in --get-selectionsGuillem Jover1-0/+2
Otherwise we'll crash in commandfd.