Enable an alternative swupd certificate location (the location of the
default or given cert with an ".alt" appended to it). The purpose of
this change is to allow more reliable and flexible key rotations.
If either the main cert or alt cert fails when doing content
verification then the other will be tried (and be used for the next
operation). In this way, as long as both certs don't fail for the same
content verification, progress can be made with either cert.
Signed-off-by: William Douglas <william.douglas@intel.com>
We already detect and report that certain tests require at least two
builds within the current format, but only one exists. Change that from
a test *failure* to a *skip*.
Example:
We need at least 2 versions in format 38 to continue with this test
Test teardown complete.
not ok 2 RCT002: Repair a big system
# (from function `test_setup' in file test/real_content/real_content_lib.bash, line 144,
# from function `setup' in test file test/real_content/../functional/testlib.bash, line 4647)
# `test_setup' failed
#
becomes:
ok 2 RCT002: Repair a big system # skip We need at least 2 versions in format 38 to continue with this test
This test creates an alternate swupd root certificate. If one already
exists, back it up, and restore it when the test is done. Previously,
this test just blindly deleted the certificate if it existed.
- Testing fixups
- Update to use CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
- Recursive delete handle user data gracefully
- Rework curl error checking
Signed-off-by: William Douglas <william.douglas@intel.com>
Eliminate some uses of wc -l that don't help. Take advantage of lines
array to count bundles.
Separate STDERR messages from $output and ${lines[@]} that are used for
bundles.
Previously, these messages were printed to STDOUT:
Overriding version and content URLs with...
Overriding content URL with...
Overriding version URL with...
But especially with --quiet, the output to STDOUT should be strictly the
requested data. So print these as warnings instead.
Set response explicitly in case of curl_easy_getinfo error (though in
practice the response isn't modified and so program behavior is the
same as before this change).
Signed-off-by: William Douglas <william.douglas@intel.com>
systemctl reports that the timer file is missing now as a return code
4 so update the unknown start number.
Also with this change SWUPD_NO is no longer always returned so add a
new helper to check if a status is one of multiple options.
Signed-off-by: William Douglas <william.douglas@intel.com>
Previous use of CURLINFO_CONTENT_LENGTH_DOWNLOAD is deprecated so
switch to the updated CURLINFO_CONTENT_LENGTH_DOWNLOAD_T API.
This change does not propagate the curl type used to the rest of
swupd-client but instead tries to use reasonable type casts for their
given purpose.
Signed-off-by: William Douglas <william.douglas@intel.com>
Currently sys_rm_recursive was used in any instance of deleting swupd
content from the system (update, repair and bundle-remove). This can
cause user data loss when unkown files are in directories that swupd
is deleting.
To prevent this, this patch changes how deleting content in swupd
operates. Swupd content removal is now done with sys_rm and the return
value is checked in case the removal failed due to a directory that
still had files in it. When this specific failure occurs, the
directory is added to a new list for reprocessing removals as it is
expected once the rest of the deletes on the system occur the failures
will go away as the directories will be empty (these deletes are
processed in alphabetical reverse order so leaf directories are
processed first). If the removal fails again it is presumed the
contents of the directory are not files swupd knows about and as such
should be kept somewhere else.
For handling the retention of user data, directories (with only the
content unknown to swupd) are renamed (currently using a
.deleted.$timestamp. prefix of the old name) and stored at the same
directory level they were previously found with one exception. The
exception is for nested deleted content best illustrated with an
example:
/swupd-dir1/user-file1
/swupd-dir1/swupd-dir2/user-file2
When swupd tries to remove the /swupd-dir1 content, it will store the
user files as follows:
/.deleted.$timestamp1.swupd-dir1/user-file1
/.deleted.$timestamp1.swupd-dir1/.deleted.$timestamp1.swupd-dir2/user-file2
To demarcate what was part of swupd content vs user content.
Signed-off-by: William Douglas <william.douglas@intel.com>
The remove_files_in_manifest_from_fs function isn't used and was a
user of a rather dangerous recursive remove function. Get rid of it to
avoid potential confusion.
Signed-off-by: William Douglas <william.douglas@intel.com>
In cases where curl perform returns an error but is actually a 400
level response, swupd needs to check curl info to see this. If the
info reveals a 400 level response, return the corresponding download
status error to prevent useless download retries.
Signed-off-by: William Douglas <william.douglas@intel.com>
The error message about skipping unsupported file optimization levels
only needs to be printed once so do that instead of potentially
spamming it.
Signed-off-by: William Douglas <william.douglas@intel.com>
Add support for new APX optimization level. Change increases the
maximim potential optimization level but does not yet allow the files
to be used (installed). get_opt_level_mask still needs to be updated
to account for system supporting the new optimization level (and
adding APX_SKIP_FILE support) before the APX files can be installed.
This change is being done at this time to allow mixer to create these
files without swupd error messages during updates.
Signed-off-by: William Douglas <william.douglas@intel.com>
Instead of having this be a local test, have a format target for the
Makefile and use a github action for clang-format to avoid differences
between developer systems clang-format and runner clang-format
versions.
Signed-off-by: William Douglas <william.douglas@intel.com>
Allow the usage of non-SSE files from manifests. This involves testing
what the currently running system supports for optimized content and
installing the best matching available binary the manifest provides.
There is an exception for operations where the prefix is set to
something other than the rootfs where SSE binaries will be used in all
cases.
Signed-off-by: William Douglas <william.douglas@intel.com>
mixer-tools populates the optimized mask based on a matrix of values
where the mask includes both the optimization of the file on the line
but also the combined masks of all matching files.
This means a file mask needs to be translaed from the mask to what its
actual optimization level is and what other optimizations levels are
available to be useful. This change adds 2 new elements to the file
struct. The opt_level stores a files optimization level and
available_levels stores a bitwise or of the different optimization
levels that can be found in the file list for the same file.
For instance an AVX2_3 mask indicates the file is AVX2 with both SSE
and AVX512 files also available (SSE | AVX2 | AVX512 == 3).
Signed-off-by: William Douglas <william.douglas@intel.com>
In the case of the system default paths being set, potential errors
from state_set_*_path functions were being ignored. Handle errors and
exit accordingly.
Previously the directories were not attempted to be created in this
code path so there was no error handling needed but with the mkdir
addition, no longer handling this erro will cause segfaults later on
as the mkdir failure prevents the path setting further causing
uninitalized variables to be used.
Signed-off-by: William Douglas <william.douglas@intel.com>
Remove duplicate '9' in string for generating OPTIMIZED_BITMASKS array
and regenerate. This also requires an additional element is added to
the array to get to the 64 characters usable in the map.
Signed-off-by: William Douglas <william.douglas@intel.com>
- Major change in how manifests are parsed.
The manifest's modifier flag has been reworked, previous flag settings
are now ignored and they get the default behavior of the new
settings. Only default modifiers are currently supported, all other
types are skipped at this time.
Signed-off-by: William Douglas <william.douglas@intel.com>
The modifier field will be a character that translates roughly into a
base64 encoded bitmask. The first 3 bytes are the optimization level
and the last three are the max optimization level any files with that
same filename can have.
For now though skip all lines that don't match SSE_OPT (the previous
values the modifier field would have: 'b', 's' and 'C' all map to
the SSE_OPT bitmask).
Also rework the manifest unit tests a bit more. Noticed the exported
flag was wrong in the data and the X flag for the 3rd field was
completely unchecked for in swupd code. Added testing for the ignored
'b', 's' and 'C' values of the modifier field and checked the non-sse
is in fact skipped as a file for now.
Signed-off-by: William Douglas <william.douglas@intel.com>
The api test needs to compare the current commit on the remote branch
to the master branch. Based on the documentation, 'fetch-depth: 0' is
intended to fetch all branches and tags.
Signed-off-by: William Douglas <william.douglas@intel.com>
The logic is testing a flag that mixer does not set and would like
to change the purpose of in a new version. Remove the test (needs a
format bump before mixer can use the flag) for the flag.
Signed-off-by: William Douglas <william.douglas@intel.com>
The disk space check was trying to match exact number of download
attempt messages which was not working consistently.
Move to simply detecting the failure messages once.
Signed-off-by: William Douglas <william.douglas@intel.com>
Also skips a few tests that do not run well with docker (changing date
and disk filling have a hard time). Adding comment for how to run
docker (needs the --cap-add LINUX_IMMUTABLE option passed).
Signed-off-by: William Douglas <william.douglas@intel.com>
There are some problems with how we are using multiplexed curl causing
huge slowdowns (2-5 times slower).
For now rather than rework the multiplexed curl code, switch to using
the synchronous code path.
Signed-off-by: William Douglas <william.douglas@intel.com>
The order of files in this test aren't very completely stable so make
do with looking at output chunks that seem to be reasonably consistent
across different environments.
Signed-off-by: William Douglas <william.douglas@intel.com>
Detect docker container usage when running test to handle cases where
systemd is unlikely to be running.
Signed-off-by: William Douglas <william.douglas@intel.com>