Fixes#252Fixes#370Fixes#371
When failing to add bundle with a file with the wrong hash remove the
file and fall back to the verify_fix_path. Improve warnings so they
don't look like errors until they are actually errors.
Add tests so we don't regress in this regard.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Most of the functional tests properly reverted the chown operations in
teardown(), but three of them were missing the reverts.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When output was changed to stderr for user output, this broke
automatic generation of the bash completion function.
Add suitable redirection to the generation script to capture stderr.
Add test to check the generated file looks reasonable.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Instead of relying on swupd-server to put the post-update action in the
correct manifest and in the correct format, do the format change
detection on the client.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
The target-dir is wiped every run, so putting the .gitignore in the
target-dir directory doesn't work.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Fixes#306
Because 'ignore-list' contains patterns that cannot match lines from
'lines-checked', they should also be absent from the diff output that
compares 'lines-checked' to 'lines-output'. Implement this by post
processing 'lines-output' to omit ignored lines.
This change improves error reporting when check_lines() finds mismatches
between 'lines-checked' and 'lines-output' for a particular test.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since I changed check_lines() to propogate the matcher.awk exit status,
this test failed due to a missing 'lines-checked' file. Add the file to
fix that issue.
Also, remove the -x and -v options to the shell invocation, because more
lines of output are produced and that should not be checked.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Fixes#307
Previously to this change, lines-checked may have contained lines
matching patterns from the ignore-list, but matcher.awk does not expect
this situation and may result in difficult-to-diagnose test failures.
Instead, pre-validate lines-checked and if this validation fails, exit
with status code 2.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
If the test passes, BATS will not print the output anyway, so always
echoing $output (regardless of exit status) is better.
Also, make sure check_lines() returns the correct status.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Because the next commit will be adding validation to ensure
lines-checked lines do not match ignore-list patterns, ignore-list must
be processed first.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
I will be reusing this logic, so moving it into a user-defined AWK
function will help with maintenance.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This test renames foo to bar with no changes to contents, and baz to
bat with minimal changes.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Allow chown_root and revert_chown_root to take multiple parameters, in
particular they can now take -R to do a recursive chown.
New functions clean_web_dir, clean_state_dir and clean_target_dir to
clean things up (clean_test_dir is now an alias for
clean_state_dir).
New function set_os_release to set the value in target_dir
New function unpack_target_from_manifest. This takes two parameters
release and name. It reads the manifest, locates the files from the
web-dir/$release/staged directory and copies them into target-dir, and
also creates the directories. Helpful in creating initial versions of
target-dir. Should be expanded to do deletion.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
A colon-separated list of alternative CApath options can be passed to
swupd-client at the configuration time using --with-fallback-capaths
option.
In runtime, fallback CApath support is implemented as part of the
connectivity check. The implementation will try the default (built into
curl) and then will iterate through the list in the order they were
specified. It is done only once on the first call.
The code is reorganized to keep the connectivity check inside curl
wrapper:
* Deleted check_network implementation from version.c
* Removed have_network global (globals.c)
* Scoped swupd_curl_test_resume to curl.c
* Change use of check_network to swupd_curl_check_network
Also:
* Fixed an issue where SSL was only enabled if a URL was matching the
content URL
Fixing the compiler issue for check_network in check_update.c triggered
test failures. Fix the test failures and improve the error output for
when check_network() fails.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Now we have dots (or percentages) when files are being downloaded
these can intermingle with the normal output if they are flushed.
Alter the fix-missing-file test to remove dots from the lines to be
compared, and alter the lines-checked to add in the lines which would
normally be ignored but no longer match due to the missing dots,
e.g. "Downloading packs."
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Now that bundleadd verifies each file it downloads the incorrect hashes
cause test failures. Update these hashes to be correct.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
The --has-dep=BUNDLE argument will display a tree representing all
installed bundles that recursively include BUNDLE.
One may pass the --all argument as well to list the dependency tree for
BUNDLE including all installable bundles available on the server.
**Example output without --all:**
Installed bundles that have os-installer as a dependency:
format:
# * is-required-by
# |-- is-required-by
# * is-also-required-by
# ...
* mixer
|-- os-clr-on-clr
**Example output with --all:**
Attempting to download version string to memory
All installable and installed bundles that have os-installer as a dependency:
format:
# * is-required-by
# |-- is-required-by
# * is-also-required-by
# ...
* clr-devops
* mixer
|-- os-clr-on-clr
|-- os-clr-on-clr-dev
|-- clr-devops
|-- os-clr-on-clr-dev
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
A bundle will fail to be removed from the filesystem when other bundles
require that bundle as a dependency. Print a list of each of these
bundles along with the error message.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Since this step can take a while print a header to give an indication of
what the progress percentage is tracking. Update functional tests to
include new output.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Add a progress indication for redirected output such as for logging,
testing, or third-party software such as ister.
For every 10 files or steps completed a dot (".") is printed to the
screen.
Adds a few more progress indications for silent loops.
Also adds leading newlines to some existing print statements so they are
printed on their own line.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
As the state_dir (normally /var/lib/swupd) contains things like the
downloaded bundles, it is important that there is no access to
non-root users who could potentially explot races to replace files
between them being checked and them being installed.
Ensure that the state_dir is root owned, and mode 0700, as well as the
critical directories below it.
Note that a proper fix would involve using chdir to move into the
directory and only use relative paths. This would prevent faulty
permissions higher up the directory tree being exploited. It *might*
be possible to use openat(2) to prevent this exploitation.
Add a test to ensure that the enforcement is taking place.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Adds status checks for each swupd command called in the functional
tests. At this point several of these tests fail due to some successful
commands returning error statuses.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Check that the simple test server in the checkupdate/slow-server/ test
is available before actually running the swupd command. This check is
done by testing the return status of a curl command on the server up to
ten times until successful.
Since this is an historically touchy test, output an additional
debug.log in the test directory with much more verbose logging (using
set -x).
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Instead of allowing only one "actions:" field in the Manifest.MoM, allow
for several and read each into the post_udpate_actions list. This allows
us to add more actions down the road if desired.
Currently the only use for the "actions:" field is to indicate when a
re-update is required. This is handled by checking if the string
"update" is in the post_update_actions list.
Finally, remove the warning to the user to perform the post update
action themselves, as this will be handled by swupd itself. Functional
tests updated to reflect the missing output.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
We draw a hard line with error codes, such that:
Error code 16 is reserved for failures resulting from the basic
network check. Any call to check_network() that fails will
return this error code. No other error path returns this
error code.
Additionally, check_network() is called in every normal code path.
All other, possibly network related issues, return a different
error code. If the basic network check succeeds, but e.g. pack
downloads fail, we return a new (23) error code so that we
can better establish the conditions through telemetry and
determine whether the error is on the client or the server,
which is highly likely with this new error code 23.
The download_subscribed_packs() could fail for network issues or other related
problems, and because the only option for getting new packs is by downloading
zero packs or fullfiles, swupd should retry to get the packs before falling
into the verify_fix_path flow which signifies pack downloads errored out.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This is a wrapper around remove_bundle()
to add consistency for bundle-remove
subcommand respect bundle-add that accepts
one or more bundles to be removed.
This must not be the optimal implementation
but it works fine and gives a better user
usage experience.
Arrange for "bad names" to give non-zero exit code
Arrange for "do nothing" in particular when packages are already
installed to give a zero return code.
This means that typos in names result in failures, but that trying to
add an existing package is fine.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
The system clock may be terribly off, especially on new hardware that has not
yet been calibrated. Updates rely on the certificate and system time being
sane to verify validity, so if a mismatch is found the certificate will
be deemed invalid and the update stopped. This patch attempts to fix the
system time to something sane using the time from the swupd binary itself,
which should not have been touched by any user except root. If the time is
normal and verification fails, the cert cannot be trusted.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Currently if you try and add a non existent bundle, e.g. "foo" you get
two lines of output
foo bundle name is invalid, skipping it...
bundle(s) already installed, exiting now
This is caused by the add_subscriptions function calling itself
recursivly but failing to pass up results in a meaningful way. This
change makes the return value of add_subscriptions be a bitmask so it
can signal errors and packages added distinctly.
I did think about changing this function to return a struct but
decided this was a step too far.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
The mixer and image creator treat the certpath as the full path of the
certificate filename, and swupd should too. If someone is overriding the
certificate with the cert path option, use the supplied string and don't
append a pre-defined name to it.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
In the current system we depend on the legacy boot infrastructure, which
has been provided by clr-boot-manager in the way of compatibility scripts.
These scripts all do the same thing, which is to invoke clr-boot-manager
with the "update" subcommand.
Given that clr-boot-manager doesn't need to know the context of the
operation, i.e. it is able to deduce whether kernel or bootloaders need
updating, regardless, it makes little sense to use any of these scripts,
and we should begin to deprecate them.
In clr-boot-manager 2.0, we will look to remove these compat scripts
completely, however they will continue to exist until then to facilitate
necessary format bumps, etc.
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
The swupd unit tests need a group of
options for execution environment.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>