Commit Graph

74 Commits (0b7d6dfbf2c7e54171719f4a427789962d365642)

Author SHA1 Message Date
Aydin Mercan 0b7d6dfbf2
crypto: start seperating public/private key usage
Digests now use bearssl + libsodium instead of openssl + libsodium.
It fits better with the API looking more similar and I don't think it
will be that much of a bottleneck.

Instead of a apk_pkey that mimicks the EVP_PKEY semantics, have seperate
public and private key structures. However, apk is broken because of it
and needs fixing. The rest of the code might compile but won't work
as I haven't handled the cases where pkey corressponds to public/private
keys in codebase properly. Also, DSA signatures are removed.

Public and private keys impls' now use a static array of vtables
internally. The indicies correspond to the signature scheme version and
checking `< APK_*_MAX` should be enough? I tried to make so that higher
values correspond to more desirable constructs, this might come in handy.

Signing/verifying start is free from keys as it isn't used though it
might be brought back for domain seperated hashes, ability to get
timestamps involved with epheremal keys in the future etc.

`apk_crypto.h` is free from openssl includes although some headers still
use them for now.
2022-08-24 10:15:14 +03:00
Aydin Mercan 2727846361
crypto: start tinkering
Start working on "cute" signatures because why not? Cute signatures are
inspired/ripped of from the signify and minisign design:

Key (URL-Safe, padded base64):
- 2 bytes of version tag (specifies the algorithm)
- 16 bytes of key ID
- Public/Private key (size depending on the version tag)

Signature (raw):
- 2 bytes of version tag (specifies the algorithm)
- Signature depending (size depending on the version tag)

The new scheme uses libsodium and thus the work of
abstracting cryptographic operations from libcrypto should also be
completed. Also, since the key of the signature is provided in the
filename, there shouldn't be a need for ID

There is also the possibility of using epheremal keys for signatures and
sign the package's public key, signature and signing timestamp in the header
such as:

- 2 bytes of version tag
- signing timestamp
- epheremal public key used
- epheremal signature
- signature of the previous sections
2022-08-24 10:13:22 +03:00
Ariadne Conill de15d4adbb legacy build system: include libportability headers 2021-12-29 20:14:41 +02:00
Timo Teräs a673653200 database: implement uvol support
by adding an abstraction layer to the file system
2021-11-09 21:50:11 +02:00
Timo Teräs 9c843e4ecd Refactor .apk extraction code
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-27 14:09:38 +03:00
Timo Teräs 3b00c0dc80 adb: unify various interfaces to adb_m_process
Removes code duplication, and puts important checks in one place.
Support seamless decompression in adbdump.
2021-07-22 15:30:08 +03:00
Timo Teräs 7af34db6cf adb: support seamless de/compression of adb files
Add compression header of adb files. Support uncompressed and
deflate compression at this time.
2021-07-22 15:30:08 +03:00
Timo Teräs d02b1030e9 update Makefile to include new v3 code and applets 2021-06-14 14:17:29 +03:00
Timo Teräs 2f58322c70 fix makefile build after crypto abstraction work 2021-06-11 13:49:33 +03:00
Timo Teräs 7ce4cc4b73 add basic abstraction for cryptographic operations
- 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-06-11 13:35:32 +03:00
Timo Teräs 705e002bb0 rename adb_trust to apk_trust, and use it as package signature keystore too 2020-10-09 16:09:19 +03:00
Timo Teräs 354713d2f7 rename apk_db_options to apk_ctx, rework logging
makes apk_verbosity non-global

fixes #10682
2020-10-09 16:09:19 +03:00
Timo Teräs efe0c4afec adb: introduce apk-tools database format, and few applets
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-09 16:09:19 +03:00
Timo Teräs 2408ad4f95 build: make soname explicit and simplify and fix soname link 2020-08-25 15:35:46 +03:00
Fredrik Gustafsson 4d69d123f5 fix logic to not compile lua module when it was not asked
fixes 12fdf6fc "allow building without help..."
2020-05-19 17:03:25 +03:00
Timo Teräs d0edeec8fb make the atom functions not use global state
This greatly helps with memory management on applications that
may want to daemonize and open/close database several times.

Also the lifetime and "owner" of memory for all data is now
explicitly bound to owning struct apk_database, which might
be helpful when writing language bindings. As side effect, the
interned "atoms" are unique only within what apk_database, so
comparing packages from different apk_database may not work
as expected.

Fixes #10697
2020-05-19 12:02:56 +03:00
Timo Teräs 12fdf6fc21 allow building without help when lua interpreter is not available
fixes #10696
2020-05-19 10:50:57 +03:00
Timo Teräs 5258b484bf add script to autogenerate help from man pages
This creates main help like:
--
usage: apk [<OPTIONS>...] COMMAND [<ARGUMENTS>...]

Package installation and removal:
  add        Add packages to WORLD and commit changes
  del        Remove packages from WORLD and commit changes

System maintenance:
  fix        Check WORLD against the system and ensure consistency
  update     Update repository indexes
  upgrade    Install upgrades available from repositories
  cache      Commands related to the management of an offline package cache

Querying package information:
  info       Give detailed information about packages or repositories
  list       List packages matching a pattern or other criteria
  dot        Generate graphviz graphs
  policy     Show repository policy for packages

Repository maintenance:
  index      Create repository index file from packages
  fetch      Download packages from global repositories to a local directory
  manifest   Show checksums of package contents
  verify     Verify package integrity and signature

Miscellaneous:
  audit      Audit directories for changes
  stats      Show statistics about repositories and installations
  version    Compare package versions or perform tests on version strings

This apk has coffee making abilities.
--

And applet specific help like:
--
usage: apk add [<OPTIONS>...] PACKAGES...

Description:
  apk add adds the requested packages to WORLD and installs (or upgrades)
  them if not already present, ensuring all dependencies are met.

Options:
  --initdb         Initialize a new package database
  -l, --latest     Disables normal heuristics for choosing which repository to install a
  -u, --upgrade    When adding packages which are already installed, upgrade them rather
  -t, --virtual NAME
                   Instead of adding the specified packages to WORLD, create a new
  --no-chown       Do not change file owner or group
--
2020-05-06 13:05:19 +03:00
Rasmus Thomsen 47053ede6b build: fix includedir in pkgconfig file
We want to include via <apk/$headerfile> and not via <$headerfile>,
so we want to add an include statement for the dir the apk folder
which contains the headers is contained in.
2020-04-01 19:14:28 +03:00
Rasmus Thomsen 4966bc5ede build: enable building of development package
- always create .so and .a with the apk libary code
- create .pc file
- install headers and above mentioned files

Maintainers edit: merged commits, cleaned up sed script logic,
and few other minor fixes.
2020-03-16 15:36:46 +02:00
Timo Teräs 6d11ec36e6 rename all iostream source to io_*.c 2020-02-14 16:53:12 +02:00
Timo Teräs 60b87557e5 rename all applets sources to app_*.c 2020-02-14 16:49:55 +02:00
Timo Teräs 0b82bcc53e lua: fix build and update to lua5.3
Fixes #8360
2019-12-30 16:17:14 +02:00
William Pitcock fff8bfa588 list: new applet
The list applet provides a convenient way of inspecting both the available
and installed package databases by listing their contents.  In some ways,
it is similar to `apk search` but is considered to be a superset of
`apk search` functionality.

A few `apk list` criterion are not yet ready though, such as `apk list --depends`
which searches by runtime dependency (replacing `apk info --rdepends`).
2018-01-28 23:55:29 +00:00
Timo Teräs 86436fce2f build and use bundled libfetch natively 2017-10-05 16:59:14 +03:00
William Pitcock b4b95e9ae7 manifest: new applet which dumps checksums in sha1sum format for a package 2017-05-20 06:19:00 +00:00
Timo Teräs 5723afded3 fix cross-compiling to pick right libfetch.a 2016-07-06 14:19:08 +03:00
Natanael Copa 98a13624a1 build: allow override compiler/linker flags for external libs
Make it possible to individually override openssl, zlib and libfetch
cflags and linker flags. This makes it possible to build apk-tools
without having pkg-config installed.
2016-06-13 09:32:02 +00:00
Timo Teräs 5ecc97e724 add simple stats applet 2015-06-12 11:20:01 +03:00
Timo Teräs 555363f056 url: use libfetch to retrieve http/https/ftp files 2014-10-08 10:10:45 +03:00
Timo Teräs 1e36692a8a finally fix building PIE binaries
the dynamic applet registration never worked with PIE, and as
a temporary hack -nopie was added to default link flags in 2008.

this commit reworks the applet registration mechanism to something
that is compatible with PIE, and removes the hack. finally!
2014-05-12 19:45:36 +03:00
Natanael Copa fcb540ab69 build: lua module build fixes
- do not link with -llua. We should not link apk or lua module with it.
- default to lua 5.2
- allow override the lua version with LUA_VERSION
- allow override the lua pkg-config package with LUA_PC
- only add the pkg-config lua --cflags to the lua module
2013-06-26 16:42:10 +02:00
Timo Teräs 5725f656b0 policy: new applet
to show different versions of package and the repositories from
which it is available from.
2013-06-18 14:54:18 +03:00
Timo Teräs b8c44536ca solver: rewrite as deductive solver -- core features
Implementing basic dependency handling, install_if and awareness
of pinning.
2013-06-13 18:22:00 +03:00
Timo Teräs 86bfc631ab build: openssl seems to require -ldl for now, so add that 2012-03-28 11:28:41 +03:00
Timo Teräs fd812dc722 lua: fix bindings, and build by default 2012-02-28 14:36:03 +02:00
Timo Teräs 64e5a64442 test: rewrite the testing framework to use the real applets
also merge the expected output to the *.test files.
2012-02-23 22:05:02 +02:00
Natanael Copa 17918f6765 build: fix make install of shared lib and lua module 2011-09-16 07:12:45 +00:00
Natanael Copa 8e887db746 build: support building lua module without shared libapk
Use the build option SHARED_LIBAPK for building shared.
2011-09-14 14:18:23 +00:00
Timo Teräs c6d9962d81 solver: add per-name specific flags, and fix the fix applet 2011-09-13 11:47:34 +03:00
Timo Teräs a5a7021658 applets: start using solver code
still todo:
  - 'fix' is missing
  - 'del -R' does not work
  - 'upgrade' does not do self-upgrade first

... and a lot of testing.
2011-09-09 16:32:31 +03:00
Timo Teräs 48d368e7d5 solver: move topology sorting to solver code
this allows quite some optimizations to running time and memory
requirements.
2011-08-05 14:34:58 +03:00
Natanael Copa 9cd57a8fc7 Makefile: make it possible to override pkg-config via PKG_CONFIG 2011-07-27 05:56:38 +00:00
Timo Teräs 79b53d4d76 solver: new package selection logic (which is not yet used)
* basic code for a backtracking, forward checking dependency satisfier
 * works better when there are tricky dependencies to solve
   (when can't just upgrade everything to most preferred versions)
 * the new code always evaluates all of 'world' constraints
   (old code just does incremental updates based on heuristics)
 * is probably somewhat slower than old code (probably unnoticeable
   difference in most cases)
 * makes easier to write support for provides and repository pinning
 * test applet and a bunch of test cases added which uses the new code
 * from the old feature set install_if is not yet implemented
2011-07-26 17:08:43 +03:00
Timo Teräs 169cb3a97e dot: applet to generate the dot attributed graph language files
This applet can be used to generate data for graphviz tools.
Useful to visualize package dependencies, and possible errors
in the repository.

Usage examples:
  apk dot gnome-desktop | tred | dot -Tpng gnome-desktop.png
    -- to generate simplified dependency chart of gnome-desktop
  apk dot --errors | dot -Tpng index-errors.png
    -- to generate chart visualizing dependency errors in index
2011-07-24 14:56:52 +03:00
Timo Teräs dd6008995a static build: do not use openssl engines
We want minimal static build. And this now also breaks with our openssl
since it tries to automatically dlopen some of the engine modules.
2010-06-30 16:55:50 +03:00
Natanael Copa fc4c60f233 Makefile: do not require lua pkgconfig unless you intend build lua module 2010-06-16 07:37:17 +00:00
Natanael Copa efdd2f10f5 Makefile: Don't build or install the libapk and lua module by default
Make the libapk and lua module optional at buildtime and off by default.
This is because enabling libapk requires that mkinitfs also copies the
libapk.so or the initramfs will not work.

To build libapk:

 make LIBAPK=yes

To build lua module (will enable LIBAPK=yes):

 make LUAAPK

To link apk to libapk (will enable LIBAPK=yes):

 make SHARED_LIBAPK=yes

All the above applies to make install target as well.
2010-06-14 09:41:06 +00:00
Timo Teräs bcbe575c3b build: fix CFLAGS, and use pkg-config for lua 2010-06-11 13:41:52 +03:00
Natanael Copa 7aed449427 lua: initial lua module 2010-06-11 07:02:18 +00:00