Age | Commit message (Collapse) | Author | Files | Lines |
|
This module handles setting and getting the filesystem root directory.
|
|
|
|
The former calls /bin/pwd, while the latter uses the getcwd() syscall
directly.
Signed-off-by: Guillem Jover <guillem@debian.org>
|
|
Allocate the digest into the non-freeing memory pool, as we have stopped
doing that for the entire loaded file with the switch to the file_slurp()
function. Otherwise when we release the varbuf the fsys nodes will be
pointing to garbage.
Fixes: commit 1166bbb5f099580a0c1c26d0e29b1ae3fe11ad0f
Reported-by: Sven Joachim <svenjoac@gmx.de>
Bisected-by: Sven Joachim <svenjoac@gmx.de>
|
|
|
|
Use it instead of open-coding it, or piping it via a shell invocation,
which required metacharacter escaping.
|
|
This will make using a pager way easier, and make it possible to remove
some redundant and unsafe system() usage.
|
|
A pager requires both input being connected to a tty, and we want to use
it when the output goes to the tty, so require both.
|
|
We also namespace the pager function with the module name.
|
|
Do not print filename which is going to be NULL.
Fixes: commit 9f7e58acdf28043bce2dfaf24ba27bb878418658
|
|
When dumping all stanzas from the package database, do it in
alphabetical order, so that we get reproducible output, both on disk
and for the upcoming output to stdout.
|
|
We will then be able to use it to print the package database into
stdout, for example.
|
|
|
|
This makes it possible to update the infodb directory when we have
changed the underlying directory with dpkg_db_set_dir().
|
|
|
|
This reduces code duplication.
|
|
|
|
|
|
This will make it possible for the caller to check what errno caused an
error to be emitted, if any.
|
|
|
|
|
|
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.
|
|
|
|
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.
|
|
We need these functions from the list and mtree implementations. Move
them out so that they can be shared. In addition this is pure in-core
handling so it makes sense to split out from the db-fsys modules.
|
|
We reduce the nesting level, and avoid a conditional inside the loop.
|
|
It contains the package hash table implementation. The on-disk database
is handled elsewhere, and using db here instead of hash makes it fairly
confusing.
|
|
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.
|
|
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.
|
|
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.
|
|
The only member that can be safely initialized in a new pkginfo's
pkgbin is the arch member, because that's used as part of the lookup.
Anything else might get overwritten with the data from the new object,
for example during deb822 parsing.
|
|
This partially reverts commit cd96cca4b2cf83f46d6e289418ed06e3c2ef7066.
It is not safe to assume that the pkgname_arcqual member has been
populated before. The caller might have used a local variable filled
manually. So we should always check whether it is NULL and fill it
ourselves, before returning it.
In addition now that we have the const function variants we can turn
these back into non-const so that we can do the archqualified package
name generation, and cache it for later use.
|
|
This will make it possible to switch the pkg_name() and pkgbin_name()
back to take non-const structs, and then fill the pkgname_archqual
cache on demand.
|
|
Because C does not have a C++ equivalent for the mutable keyword, we
cannot mark the pkgname_archqual member as such. Instead we will add a
new couple of const functions that will fallback to return a non-freeing
string to be used mostly in error handling code paths in case there is
no cached member, as otherwise we'd be "leaking" those strings (just
generating new instances that will be released as part of the pool)
every time we call these functions.
|
|
Move this into a proper function so that we can call it from multiple
places. In addition we always return a non-freeing allocated string,
in case the architecture is empty or none.
|
|
There's no point in arch-qualifying a package name if we got no
architecture to qualify it with.
|
|
|
|
|
|
|
|
Thanks-to: Niels Thykier <niels@thykier.net> (for typo in dpkg(1))
|
|
Warned-by: cppcheck
|
|
Add a couple of checks to make the test more robust, and to use an
assigned variable.
Warned-by: cppcheck
|
|
Warned-by: cppcheck
|
|
We were using strncpy() here as originally intended, to copy a string
into a struct member without copying the NUL-terminator. But now gcc
warns about the intended truncation, which might catch some people
unexpectedly.
Switch to use memccpy() which has similar semantics, but is more
explicit.
Warned-by: gcc-8
|
|
This unifies the term with the rest of the codebase, and makes it more
descriptive.
|
|
Now that the status changes are abstracted via a setter, which makes
sure only new changes are recorded, we can also record whether those
changes happened, so that we avoid unnecessarily logging unchanged
states.
Closes: #365921
|
|
The former is more portable as it's defined in more system md5.h
implementations, such as Solaris, while the latter is not.
Analysis-support-by: Bruno Ramos from IRC
|
|
This continues the work to generalize and make these interfaces
available to other users beside dpkg itself.
|
|
Currently, in order to run dpkg, frontends have to release the database
lock before invoking dpkg and re-acquire it afterwards, leaving a short
time where the database is unlocked and a different dpkg process or
frontend could lock it.
Frontend locking addresses the problem by creating a "lock-frontend"
file that is acquired by the frontend and not released for dpkg
invocations. Thus, multiple frontends cannot race for the database lock.
This change extends the frontend lock to dpkg itself, acquiring it
whenever the variable DPKG_FRONTEND_LOCKED is not set, so that a user
manually running dpkg or a frontend not supporting this protocol cannot
interfere with a currently running frontend.
[guillem@debian.org:
- Add documentation.
- Rename frontend lock file.
- Fix error strings. ]
Signed-off-by: Guillem Jover <guillem@debian.org>
|
|
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
|