Set /etc/swupd permissions to 0777 to let the default umask policy
handle stripping bits appropriately.
If we can write files to /etc/swupd, do it, making the directory first,
if necessary. If not, bail out cleanly. Only delete the
mirror_contenturl and mirror_versionurl files from the directory, not
the directory itself.
Add tests to verify normal behavior and corner cases.
If content_url is local, do not attempt certain certain download
retries. I've focused on changing only the spots that caused 'make
check' to sleep as a first step. But I agree the retry logic needs
some extra care as posted in #221.
This patch reduces the time of running 'make check' in my system from
2m44s to 24s.
Current idea is to have the manual pages stored in the repo in nroff
format, as well as restructured test format. Users can just use the
nroff. Add test to ensure that the pages match.
Fixes#316Fixes#425
Make sure that running "make" hasn't fixed the local manual pages but
not checked them in.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Consider all deltas from a pack instead of only those who are involved
in a rename. This will allow the server to make better packs
regardless of the from/to version, with the possibility of a delta to
a file that was not necessarily marked with the rename flag.
This makes deltapeer member of file unused, so it was removed. The
peer member continues to be used for its original role: mapping the
same files (same filename) between two manifests, usually the state of
the local system and some new version to be installed.
The test case added is like test/functional/update/rename, but without
the rename flags present. Since in that test there are some fullfiles
missing, it will only pass if swupd-client applies the deltas in the
pack.
Make swupd save a copy of the current MoM in a readable location, so
the completion code for bundle-add has access to it.
Stop generating the completion code, just use the file directly.
Remove the short option from the completion code, whilst they are
useful for an expert there is little point typing minus tab and then a
letter rather than minus and the letter.
Add crude filename completion for hashdump.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Create a test-bundle manifest with a stupid number of files, see that
it is rejected. Unfortunately because of retries this takes a long
time (70 seconds) time to run.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
The previous value - 13,805,671,819 is bogus, and we want to be able
to test if the value is reasonable.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
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>