880 Commits
Author SHA1 Message Date
Otavio Pontes 42462547e5 Release v3.18.0
This release includes:
 - Multiple fixes to memory leaks and invalid memory access
 - Improvements in clean command, removing more unnecessary Manifests
 - Adds new flags, keepcache, that keeps all staged cache after an update and
   max-parallel-downloads (renamed from max-pack-parallel-downloads) that lets
   user set the number of parallel downloads for packs and fullfiles.
 - Major improvements in swupd test library. Porting to new testlib was
   concluded and all tests from old library was ported.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
v3.18.0
2018-10-10 21:22:42 +00:00
Otavio Pontes cffe1a66a4 Fix documentation and bash script after parameter rename
max-parallel-pack-downloads was renamed to max-parallel-downloads
and documentation needs to be fixed

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-10 14:22:46 -07:00
Auke Kok 3dc2de55e3 Make parallel downloads flag global, used for fullfile downloads too.
Adjust getopts, since this is relatively new. -D stays the same
and now applies to fullfiles too.
2018-10-10 19:43:34 +00:00
Otavio Pontes d3d09d6bca time: initialize time list before using it
Fixes #600

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-09 13:26:21 -07:00
Otavio Pontes b9f5158818 Set as static functions that aren't exported
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-09 13:25:57 -07:00
Castulo Martinez 55ebbfa2f2 Verify versions can be read
read_versions is a function that attempts to read the current version
of the target system and the server version, but if there is an error
reading any of those values no action was performed so it was necessary
to validate these values wherever the function was being used,
duplicating code.

This commit adds a verification to make sure the current version of the
target system and the server version was able to be identified.

Closes #589

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-10-09 13:25:47 -07:00
Erich Cordoba f4e09e08cd Avoid print time stats if the queue is empty.
If the -t parameter is set for a given empty directory, then
the time queue will be empty causing that the TAILQ_FOREACH_REVERSE
macro segfaults.

The proposed solution is to check if the head is NULL at the beginning
of the print_time_stats function.

Fixes #600

Signed-off-by: Erich Cordoba <erich.cm@yandex.com>
2018-10-08 12:48:05 -07:00
Matthew Johnson db777c9efc clean: remove manifest hash hints from cache
Fixes #484

The manifest files with their hashes appended to the filename in the
cache are used internally to prevent swupd from re-calculating manifest
hashes every time they are opened. These should only persist for the
duration of the update and should not persist afterwards to prevent
root-priveleged owners from modifying internally-used data. This patch
causes swupd to remove them by default without having to pass --all. The
files will be automatically removed upon update.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-08 10:49:00 -07:00
Matthew Johnson 74b2d526d7 Removed unused configuration option
The systemd configuration options were unused.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-08 10:48:06 -07:00
Matthew Johnson 204e2a4b58 Add more compile options to --version
When invoking swupd --version print more information about compile-time
configuration. This feature was requested after a bug was introduced to
an unreleased Clear Linux build when swupd was built with the wrong
format ID. This allows QA to determine exactly which compile-time
options were set during runtime without inspecting the binary.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-08 10:48:06 -07:00
Otavio Pontes b85e7e40d9 manifest: Memory leak when signature verification fails
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-03 15:44:44 -07:00
Castulo Martinez 6f846b9069 Adding the --keepcache option when doing updates
After running an update, the state directory is cleaned up.
Sometimes it is useful to be able to peek at the state directory
after an update, this is specially true when testing updates,
this way tests can verify what manifests were downloaded during
the update.

This commit adds the --keepcache option to swupd update so it can
be used when writing tests for updates.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-10-03 15:43:11 -07:00
Castulo Martinez f7ef320b6a Fixing memory leak in retrieve_manifests
This commit fixes a memory leak with the dir variable.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-10-03 15:41:27 -07:00
John Akre c9ee84c70c Add minversion support to testlib
Soon, a minversion header field will be included in the MoM. This change
updates the test library to add a minversion header field to MoMs and adds
functions to create a minversion update. Also, the skip-verified-fullfiles
test was replaced by the update-minversion test. The update-minversion test
verifies that unchanged files with a version bump caused by a minversion
update are skipped during an update.

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-09-27 15:03:43 -07:00
Castulo Martinez 80074dc191 Explicitly test for use of full-files and packs
This commit adds a couple of tests meant to validate adding bundles
using zero-packs or falling back to using full-files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 5091d0daa2 Enable peeking at the state directory with testlib
The test library contains a few assertions meant to verify the
existence or non existence of files and directories. In the case
of swupd, it is sometimes common that these files can be in directories
that are not readable by non root users, which is the case of the state
directory.

This commit makes a change so these assertions use root for testing
the existence of these files and directories so we don't get false
positives in the tests.
The commit also adds one more env variable with the --keepcache
option so we can use it in tests that require the state directory
to be persisted.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez d76b34889d Removing old test library swupd.bash
The old test library swupd.bash was replaced by testlib.bash.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez ecc8fc562e Replacing old update and verify tests
The old update and verify  tests used the swupdlib.bash library that
was replaced by testlib.bash.

This commit replaces those old update and verify tests with new
versions of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez d354652d24 Replacing old search tests
The old search tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old search tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 808f70cd1c Replacing old mirror tests
The old mirror tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old mirror tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez bb95381844 Replacing old hashdump tests
The old hashdump tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old hashdump tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez aa372a346a Replacing old completion tests
The old completion tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old completion tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 4f3d9c11d5 Replacing old checkupdate tests
The old checkupdate tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old checkupdate tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 57e82bb51b Replacing old bundleremove tests
The old bundleremove tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old bundleremove tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez ad43b4c918 Replacing old bundlelist tests
The old bundlelist tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old bundlelist tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez c857216c01 Replacing old bundleadd tests
The old bundleadd tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old bundleadd tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 8d9054d9fc Print function for testlib
When a user wants to print to the terminal from a test that
is using the bats framework, it is necessary to use file descriptor
3.

This commit provides a wrapper function called print so it is
easier for user to print to terminal from tests.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Otavio Pontes d4f3251e66 testlib: Add guards to sed to avoid incorrect replaces
When updating the manifest version we were replacing any line with the word
version to "version: new_version". This is a problem now that we are adding
a minversion field to the manifest. That could be a problem too when there
was a file named version.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-09-27 11:48:35 -07:00
Otavio Pontes 5411f3d019 Release v3.17.15
This release fixes 3 bugs:
 - Error when downloading packs from a local mixer introduced by v3.17.14
 - Bash autocomplete missing for mirror command
 - Swupd wasn't returning the correct error code when a new include was
   imported with errors.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
v3.17.15
2018-09-25 21:33:03 +00:00
Otavio Pontes 6749ca2436 download: Process all completed downloads in poll_fewer_than()
When downloading from file:// curl can process all reads and writes on the
first call of curl_multi_process() and then curl_multi_wait() will set numfds
to 0 and poll_fewer_than() will return without processing the download (i.e
extracting it).

Also change a bit the poll_fewer_than() to follow the timeout approach from the
official curl_multi_wait() example (https://curl.haxx.se/libcurl/c/multi-single.html).

Fixes #582

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-09-25 11:00:18 -07:00
Otavio Pontes b8c6f67870 swupd.bash: Add autocomeplete for mirror command 2018-09-13 14:11:03 -07:00
Castulo Martinez ee11c0fb87 Return error if adding subscriptions fails
When adding included manifests during an update the add_subscriptions
function is used, this function returns a value of either add_sub_ERR=1,
or add_sub_BADNAME=4 when it fails to add a subscription, and the code
is currently considering any value > 0 to be a successful value.

This commit fixes the issue by making sure the add_subscriptions
function doesn't return a code of 1 or 4 which would mean it failed
adding a subscription.
2018-09-13 10:48:31 -07:00
Otavio Pontes c7faa4af30 Release v3.17.14
This release adds support for using SSL client certificate if provided via
/etc/swupd/client.pem, it makes some updates to the swupd test library and
travis CI environment and makes a number of bug fixes:
 - Memory managements improvements for swupd search
 - No longer use network in swupd clean
 - Temporarily disable parallel pack downloads due to timeout bug when
   downloading large packs.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
v3.17.14
2018-09-12 16:16:18 -07:00
Castulo Martinez ed736667f9 Add iterative manifest to bundle update in testlib
This commit adds the iterative manifests (to-manifest) and the delta
manifest (from-manifest) when creating a bundle update. This manifests
should contain only those files that changed in the latest version.

Closes issue #557
2018-09-11 15:08:21 -07:00
Otavio Pontes 15b987ccb1 download: Add a parameter to control the parallel pack downloads
Add parameter --max-parallel-pack-downloads to control the number
of packs to be downloaded in parallel. This is usefull if for some
reason the default value is too high or low for your configuration.
2018-09-11 14:27:10 -07:00
Otavio Pontes 9d4b1400b7 download: Infer max_xfer_bottom instead of using a parameter
When downloading in parallel we may infer the minimum downloads in parallel
by using the maximum download value. The advantage of doing this is that
estimating a good value for this parameter can be confusing to users of the
API and it isn't something it's expected to be different from different
situations.

We are defining the max_xfer_bottom to (max_xfer / 2), so the number of
simultaneos downloads will always be a number between (max_xfer / 2)
and max_xfer.
2018-09-11 14:27:10 -07:00
Otavio Pontes 481dbfda07 packs: Don't download packs in parallel as default
There's a known issue (#562) when trying to download large files in parallel.
As a temporary fix, don't donwload packs in parallel, so we won't trigger this
problem.
2018-09-11 14:27:10 -07:00
Otavio Pontes 675dff27fc download: Respect number of max simultaneous downloads
Current code performs xfer_queue_high + 1 downloads at the same time.
2018-09-11 14:27:10 -07:00
Otavio Pontes 9edc02c15b helper: Incorrect check when using unlink
According to manual unlink will return -1 on errors and set errno to error
code.
As in this point there's nothing we can do about a OOM error, just ignore it.
2018-09-07 15:51:20 -07:00
Otavio Pontes 352f7f3a18 memory: Check for allocation errors consistently
Use a macro to abort on memory allocation errors in all calls to
calloc, realloc or malloc
2018-09-07 15:51:20 -07:00
Castulo Martinez 3ef7b3c507 Anchoring regex patterns when needed
There are some cases in the library where sed or awk is used to find
certain lines within files. To match these lines we use a pattern.
In some cases this pattern should be anchored to the beginning of the
line, in case a string with that pattern appears in a file (for example
in a bundle manifest name) in the last field. This is unlikely, but
it's better to avoid unintentional matches.
2018-09-06 15:00:10 -07:00
Castulo Martinez 67a926fbce Info about bump_format and update_bundle to docs
Adding documentation about the bump_format and update_bundle
functions to the readme.
2018-09-06 15:00:10 -07:00
Castulo Martinez e50d993084 Option to make update to os-core with new versions
When a user creates a new version in a test environment and uses
the -r option an updated version of the os-release and format files
are added to the files directory. This is useful for some tests
like update tests.

This commit adds a second step of adding the updated files to the
os-core bundle so it is easier to create updates. With this commit
if using the option -r it means the new version will include an
update to the os-core bundle.
2018-09-06 15:00:10 -07:00
Castulo Martinez 4caa28369d Adding function to bump formats between versions
This commit adds a new function to bump formats between two
subsequent versions in the server side content.
2018-09-06 15:00:10 -07:00
Castulo Martinez 27095ed662 Add function to update bundles between versions
This commit adds a new function to the test library which is
useful for creating bundle updates between versions in the server
side.
2018-09-06 15:00:10 -07:00
John Akre 6bc19e0e77 Use an SSL client certificate if provided
To support clients that need to authenticate with a web server
containing protected swupd content, an SSL certificate should be
presented if defined. This commit enables client certificate
authentication with swupd and adds relevant tests.

credit: gtkramer implemented client certificates in swupd

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-09-05 16:15:03 -07:00
John Akre 6eb95d4198 Add web server test objects to testlib
This commit adds the following test objects to testlib:

- start_web_server
- destroy_web_server

This change moves the implementation of web server creation and
destruction from individual tests to the test library.

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-09-05 16:15:03 -07:00
John Akre 48aaa28f29 Add certificate support to testlib
This commit adds functions to testlib for the following:

- generate_certificate
- create_trusted_cacert
- destroy_trusted_cacert

These functions are used to create a self-signed public/private key
pair, create a trusted key store for the test environment with a public
key, and to delete the trusted key store. For the test environment to use
the trusted key store, swupd must be configured using
--with-fallback-capaths=<path to key store>. This configuration option
has been added to autogen and travis.

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-09-05 16:15:03 -07:00
Vinicius Costa Gomes c34174d140 search: Allocate the filename for each result dynamically
Instead of reserving PATH_MAX bytes for the filename (of each result),
allocate it dynamically. This should use less memory overall, at the
cost of making more small allocations.

This fixes #556.
2018-09-04 12:43:14 -07:00
Otavio Pontes 7e52b4eb71 clean: Don't use network on swupd_clean
Fixed issue #551
2018-08-24 15:53:17 -07:00