summaryrefslogtreecommitdiff
path: root/src/database.c
AgeCommit message (Collapse)AuthorFilesLines
2022-03-29db: make --no-cache disable the cache completelytt-no-cacheTimo Teräs1-4/+11
Including using files found from the cache, or creating the cache directories with --initdb. Based on patch by Paul Spooren.
2022-03-06db: fix APK_OPENF_NO_STATE checkDaniel Kolesa1-1/+1
fixes #10821
2022-03-06db: honor APK_OPENF_NO_STATE againTimo Teräs1-8/+10
Do not call apk_db_read_layer() or try to process the layer if APK_OPENF_NO_STATE is specified. It might fail because of non-existing database directory. Based on patch by Daniel. fixes commit 9e4dd29f "db: prepare database reading for layers" Fixes #10821 Reported-and-analyzed-by: Daniel Kolesa <daniel@octaforge.org>
2022-02-22db, uvol: commit regular files before uvol volumesTimo Teräs1-4/+19
add priority to order fsdir commit sequence
2022-02-22db: fix apkindex path generationTimo Teräs1-1/+1
remove the left over apk_blob_push_fmt() call that corrupted uri and trim the path end from trailing slashes to get original functionality. fixes commit be4ce407 "support new index format without attaching arch"
2022-02-21db: sort world dependencies to layersTimo Teräs1-4/+9
2022-02-21db: prepare database writing for layersTimo Teräs1-135/+172
2022-02-21db: prepare database reading for layersTimo Teräs1-21/+49
2022-02-14support new index format without attaching archPaul Spooren1-8/+20
By default the package architecture is attached to the repository url. With this commit it is possible to define new indexes ending on `.adb`. If such index file is detected the packages must be in the same folder as the index. Signed-off-by: Paul Spooren <mail@aparcar.org>
2022-02-03database: fix apk_db_cache_active returning true when cache not configuredAriadne Conill1-1/+1
this regression was caused by refactoring of the options handling into the apk_ctx struct in 354713d2, presumably a little too much innovation with sed fixes #10799
2022-01-17package: fail on invalid control dataTimo Teräs1-2/+7
Handle meta data error to produce hard failure. fixes #10806
2021-12-29database: refactor mounting and unmounting /procAriadne Conill1-19/+44
2021-12-29database: relocate find_mountpoint()Ariadne Conill1-29/+29
2021-12-29database: refactor cache remountingAriadne Conill1-5/+15
2021-12-29database: refactor tmpfs root detection and cache setupAriadne Conill1-39/+73
2021-12-29database: isolate linux-specific mountpoint headersAriadne Conill1-5/+8
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]