summaryrefslogtreecommitdiff
path: root/src/database.c
AgeCommit message (Collapse)AuthorFilesLines
2021-12-29database: use SA_RESETHAND instead of SA_ONESHOT when registering a SIGALRM ↵Ariadne Conill1-1/+1
handler SA_ONESHOT is a GNU-specific alias for POSIX SA_RESETHAND.
2021-12-29use fstatat, not fstatat64Ariadne Conill1-3/+3
the stat64 family of functions were provided as transitional functions, but when building on glibc with _GNU_SOURCE, or any other supported system, the stat functions are equivalent to their stat64 counterparts
2021-12-29apk: add --preserve-env optionPaul Spooren1-2/+2
This options is useful for (post)install scripts to run with the same environment variables as apk is executed. [TT: minor stylistic changes] Signed-off-by: Paul Spooren <mail@aparcar.org>
2021-12-14everywhere: use stdlib.h for malloc(3) definition, not GNU-specific malloc.hAriadne Conill1-1/+0
musl implements support for malloc.h, but it is only a stub. we do not use any of the GNU-specific malloc interfaces, so just use POSIX stdlib.h instead. ref #10794
2021-12-03db: convert v3 scripts to ipkg on installTimo Teräs1-1/+18
fixes #10796
2021-11-22db: synthesize symlink hashes for v3 packagesTimo Teräs1-11/+17
The v3 format will not require the hash, but synthesize it to the DB so v3 packages can get installed properly. fixes #10785
2021-11-22db: fix regression in creating .apk-new filesTimo Teräs1-3/+3
The apk_fsdir_file_digest() servers dual purpose: to calculate the checksum, but also to determine if the file exists. Move it's error check where it originally was. fixes #10791
2021-11-15db: lazy create directories with --initdbTimo Teräs1-87/+51
fixes #10778
2021-11-15fix fetching of depdencies only packagesTimo Teräs1-14/+9
Remove the APK_REPOSITORY_CACHED bit from dependencies only packages (that is, installed_size == 0). For fetch, the problem is that apk_db_select_repo() would return the cache repository, but the package would not be there. Update also the locations needed to handle these packages correctly without the cached repository bit being set.
2021-11-09database: support loading v3 indexesTimo Teräs1-0/+25
2021-11-09database: implement uvol supportTimo Teräs1-134/+74
by adding an abstraction layer to the file system
2021-11-03db: purge temporary files without explicit modification checkTimo Teräs1-1/+2
When extraction failed, the user has had no opportunity to edit any files. Just clean up.
2021-11-03extract: move uvol extraction code to extractTimo Teräs1-2/+3
fix also the progress callback on uvol extraction
2021-11-03db, extract: handle waitpid returning EINTRTimo Teräs1-1/+1
2021-11-03db, audit: support sha256-160 hashes for v3 pkg compatTimo Teräs1-5/+12
2021-10-27db, add: support adding v3 package filesTimo Teräs1-1/+39
2021-08-23remove IS_ERR_OR_NULLTimo Teräs1-4/+4
In most places where pointer can be an 'error' it cannot be null pointer. Further, in those cases just calling PTR_ERR() is not enough to handle the null case. Simplify code by removing this case. If NULL case needs to be handled, it's better to add separate check and return fixed error code in that case.
2021-08-23db: honor SOURCE_DATE_EPOCH for scriptdbTimo Teräs1-2/+0
fixes #10762
2021-07-27Further refactor extract API to have separate ops vtableTimo Teräs1-52/+44
This splits the callbacks by type, and further prepares the API to be usable for v3 files too.
2021-07-27Refactor .apk extraction codeTimo Teräs1-80/+41
This moves and isolates the tar code to tar.c. And the actual file extraction to disk is moved to extract.c. A new API is introduced and used for v2 file extraction. This essentially moves and isolates the apk_sign_ctx_* beast into extract_v2.c and offers a saner interface to handling packages. A place holder is added for v3 extraction.
2021-07-26db: add some error checking to database state writeTimo Teräs1-39/+50
Make errors more observable. Unfortunately full rollback is non-trivial to implement. This is something to be fixed with the v3 database format.
2021-07-26db: fix installed db writing with long namesSamanta Navarro1-5/+10
Packages containing files with path names longer than 1024 characters cannot fit into the buffer which is used to write "installed" database. This leads to bbuf being APK_BLOB_NULL in apk_db_write_fdb because apk_blob_push_blob notices the condition and correctly handles it. The problem occurs when arguments to apk_ostream_write are manually calculated by pointer arithmetics. Since bbuf.ptr is NULL in such a case, bbuf.ptr - buf leads to a huge size value while buf still points into the stack. fixes #10751 [TT: minor edit to commit and abbreviating the commit message]
2021-07-23db: allow read-only operations without cacheTimo Teräs1-3/+6
fixes #10748
2021-07-22io: formalize apk_ostream_write() always writing full dataTimo Teräs1-9/+9
2021-07-22rework apk_istream_splice and apk_istream_teeTimo Teräs1-50/+28
- apk_istream_splice usage is converted to apk_stream_copy which is the newer variant. With caching enabled by default, this makes more sense mmapping or using separate buffers. - apk_istream_tee is reworked to write to apk_ostream, which simplifies quite a bit of various things
2021-07-22io: rework apk_istream_get_* to not return erros in blob valueTimo Teräs1-16/+16
The interface was slightly cumbersome, so replace these functions to return explicit error, and make the return blob a pointer arg.
2021-06-21db: check syscall errors in update_permissions()Timo Teräs1-5/+18
2021-06-19reduce misuse of error codes from errno.hTimo Teräs1-4/+4
2021-06-11extract: new applet to extract v2 packagesTimo Teräs1-2/+2
2021-06-11add basic abstraction for cryptographic operationsTimo Teräs1-27/+42
- basic digesting and signing apis (subject still to fine tuning) - update digest code, and adb signing for the thin wrapping layer - old v1 package and database handling not updated - default mkpkg file hash to sha256 ref #10744
2021-03-19database: do not chroot(".") unless actually necessaryAriadne Conill1-2/+12
If we use default root (/), then we do not have to chroot to run scripts. Use APK_NO_CHROOT flag for this scenario to avoid the chroot. This helps with using apk with bwrap and OSTree. Closes #10736.
2021-02-07db: fix control character check to use uint8_tTimo Teräs1-2/+2
fixes #10737
2021-02-04db: consider control characters in filename as maliciousTimo Teräs1-11/+19
Especially a newline can produce havoc in the database file as the filename is written there as-is. This hardenes the extraction to consider any control character as malicious. Additional hardening is added to database loading to better detect corrupt state and return proper error code about it. Reported-by: Luca Weiss <luca@z3ntu.xyz>
2021-01-14database.c: Fixed package DESCRIPTION parsingthibault.ferrante1-0/+1
Regression introduced by 0fb0d30 which makes parsing a description a critical failure. [TT: Minor stylistic change. Fix also missing final line change from the earlier commit]
2021-01-11database: Propagate errors when loading an APKINDEXthibault.ferrante1-6/+7
In case of failure when loading an APKINDEX, no errors are propagated to the user which may uncorrectly interpret the current problem.
2020-10-09rename adb_trust to apk_trust, and use it as package signature keystore tooTimo Teräs1-6/+3
2020-10-09make apk_database optional for applets that don't need itTimo Teräs1-35/+7
The new v3 applets don't use it, and eventually all applets will use the new formats only. This prepares the code for this, and moves trust, id_cache, and root_fd to apk_ctx which is enough for v3 applets at this time. The generic code is made to not initialize apk_database if it's not needed.
2020-10-09rename apk_db_options to apk_ctx, rework loggingTimo Teräs1-129/+129
makes apk_verbosity non-global fixes #10682
2020-10-09make apk_flags non-global, make progress printing state non-globalTimo Teräs1-17/+17
ref #10682
2020-10-09make apk_force non-global, remove left-over apk_archTimo Teräs1-10/+11
ref #10682
2020-10-09db: convert repository list to a string arrayTimo Teräs1-3/+4
2020-10-09io: make ostream_file always use tmpnameTimo Teräs1-30/+5
2020-10-09adb: introduce apk-tools database format, and few appletsTimo Teräs1-0/+8
This is a flat buffers inspired format that allows fast mmaped access to the data with low overhead, signature support and relatively good forward support.
2020-10-07various changes to make clang not give warningsTimo Teräs1-4/+4
2020-10-06db: make the --repositories-file change more announcedTimo Teräs1-3/+7
Document the version when changed. And print error with similar note if the given repositories-file cannot be read.
2020-10-06database: automatically create missing cache dirPaul Spooren1-0/+6
On some systems the `/var/` dir is mounted in a tmpfs which is reseted after each reboot. For that reason no post-install script can handle the creation of the cache dir at `/var/cache/apk`. Check on database opnening if the folder is available, if not create it. Fixes #10715 Signed-off-by: Paul Spooren <mail@aparcar.org>
2020-10-05db: make --repositories-file relative to host rootTimo Teräs1-1/+1
It used to be relative to the --root specified root, but that causes issues with relative command line filenames and is unintuitive. Update documentation accordingly. Fixes #10702.
2020-10-05db: mask password component of printed URLsTimo Teräs1-12/+19
fixes #10710
2020-10-01db: check cache only if some repositories are enabledTimo Teräs1-1/+1
2020-08-29database: clarify the deprecation notice for checksum-less packagesAriadne Conill1-3/+7
Closes #10708.