diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-10-09 12:44:32 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-10-09 16:09:19 +0300 |
commit | a627ab8eb8387ebf5735cf525ae72bfa159aa39a (patch) | |
tree | 6c11a133c2743d03c4b4bc8be0f9cb42819aaee7 /src/io.c | |
parent | 354713d2f746c197eed6a1feb4c6af3420af6c15 (diff) | |
download | apk-tools-a627ab8eb8387ebf5735cf525ae72bfa159aa39a.tar.gz apk-tools-a627ab8eb8387ebf5735cf525ae72bfa159aa39a.tar.bz2 apk-tools-a627ab8eb8387ebf5735cf525ae72bfa159aa39a.tar.xz apk-tools-a627ab8eb8387ebf5735cf525ae72bfa159aa39a.zip |
make apk_database optional for applets that don't need it
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.
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1078,8 +1078,10 @@ void apk_id_cache_init(struct apk_id_cache *idc, int root_fd) void apk_id_cache_free(struct apk_id_cache *idc) { + if (!idc->root_fd) return; apk_hash_free(&idc->uid_cache); apk_hash_free(&idc->gid_cache); + idc->root_fd = 0; } void apk_id_cache_reset(struct apk_id_cache *idc) @@ -1100,8 +1102,7 @@ uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t defa FILE *in; ci = resolve_cache_item(&idc->uid_cache, APK_BLOB_STR(username)); - if (ci == NULL) - return default_uid; + if (ci == NULL) return default_uid; if (ci->genid != idc->genid) { ci->genid = idc->genid; @@ -1143,8 +1144,7 @@ uid_t apk_resolve_gid(struct apk_id_cache *idc, const char *groupname, uid_t def FILE *in; ci = resolve_cache_item(&idc->gid_cache, APK_BLOB_STR(groupname)); - if (ci == NULL) - return default_gid; + if (ci == NULL) return default_gid; if (ci->genid != idc->genid) { ci->genid = idc->genid; |