1386 Commits
Author SHA1 Message Date
Brett T. Warden 8742b3a168 Redirect URL override messages to STDERR
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.
2024-08-26 13:25:12 -07:00
William Douglas 6e02330aa1 Add error handling for curl_easy_getinfo
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>
2024-08-13 14:25:09 -07:00
William Douglas 9fdf88c74b Test fixups and update for newer systemd
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>
2024-07-29 11:46:45 -07:00
William Douglas 279f715759 Use curl CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
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>
2024-04-08 10:25:50 -07:00
William Douglas 02d276564d Rework content deletion handling
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>
2024-04-05 10:28:41 -07:00
William Douglas 2fd2f6c58f Cleanup unused code
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>
2024-04-05 10:28:41 -07:00
William Douglas bf538679f0 Reformat files with make format
Signed-off-by: William Douglas <william.douglas@intel.com>
2024-04-04 13:51:32 -07:00
William Douglas ae19d9d561 Rework how curl errors are checked
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>
2024-04-04 13:51:32 -07:00
William Douglas 3d8634edda Avoid printing optimization level error repeatedly
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>
2024-01-22 06:50:40 -08:00
William Douglas 0d2d11d0fc Add APX flag support
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>
2024-01-22 06:50:40 -08:00
William Douglas cdcd279371 Fix test errors configuring the system mask
Also make a mask check more consistent with the rest of the code.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-26 10:16:36 -07:00
William Douglas 19a6b3a443 make compliant fixups
Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-25 14:44:10 -07:00
William Douglas ce82b5da51 Enable use of optimized manifest files beyond SSE
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>
2023-04-25 14:44:10 -07:00
William Douglas a9aac28ae7 Update opt_mask handling to match mixer-tools
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>
2023-04-11 12:20:25 -07:00
William Douglas 6eb95df3e2 Fixup format string specifiers
Correct format strings to be the right type.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-11 12:20:12 -07:00
William Douglas ba9649e223 Handle errors from statedir_set_*_path
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>
2023-03-07 15:10:16 -08:00
William Douglas 5ecf766ba8 Fix typo in OPTIMIZED_BITMASKS
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>
2023-03-03 10:11:00 -08:00
William Douglas 77f16b0120 Add new handling for modifier field
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>
2023-03-02 12:35:32 -08:00
William Douglas a011f9429a Remove logic for flag not in use
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>
2023-02-28 13:25:05 -08:00
William Douglas a9608851ee Move packs to download synchronously
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>
2023-02-21 23:26:19 -08:00
William Douglas bf5e1f1297 Fix missing header
Header file ordering hid a missing list structure definition.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas dbeb3662a4 Apply changes from clang-format
Running:
clang-format -i -style=file src/*.[ch] src/lib/*.[ch] \
src/3rd_party/*.[ch] src/cmds/*.[ch] src/swupd_lib/*.[ch] \
src/verifytime/*.[ch]

with clang v15

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 7e00e0a20b Switch off of string n functions
These functions lead to spurious errors and warnings for our use
cases.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-07 12:51:05 -07:00
William Douglas b6a4aff5b7 Remove deprecated function use
Since OpenSSL 1.1.0 this function is no longer needed.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-07 12:51:05 -07:00
Arjan van de Ven 4774daf00d allow for non-versioned delta files 2022-10-07 12:51:05 -07:00
Brett T. Warden 39515d2fc0 Announce overrides of content and version URLs
When using -v, -c, or -u to set alternate version or content URLs, print
out a message so it's more obvious.
2022-10-05 11:08:47 -07:00
Castulo Martinez 04dfaa1db7 Allow paths that contain symlinks for cachedir
When the path provided by a user for the --statedir (or --cachedir)
contains a symlink swupd will fail to extrar tar files since
libarchive does not support extracting files through symlinks.

This commit fixes the issue allowing users to use symlinks in the
--statediri/--cachedir path.

Closes #1581

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-15 15:24:34 -07:00
Castulo Martinez 68b4eee984 Adding flags to set data and cache in swupd
This commit provides the --datadir and --cachedir flags that can be used
to specify different locations for the data and cache. If the same
location is desired for both (default) then users can still use the
existing --statedir flag.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-08 12:10:39 -07:00
Castulo Martinez 40472f5a21 Updating "clean" to remove new and old cache dirs
"Swupd clean" removes cache from certain pre-defined directories. This
commit udpdates the locations where clean looks for cache so it includes
the new locations where the cache is stored.

Swupd will continue looking at old cache locations until the bump to
format 31.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-08 12:10:39 -07:00
Castulo Martinez 8d54e6c995 Separating the cache from the data used by swupd
Currently there is only one location, known as "statedir", where swupd
stores data and cache. Normally it make sense to keep the data in a
path that is relative to the path prefix of the target system, since the
data is specific to that system, but cache can be independent of the
system, and that way it can be reused for other target systems if
desired.

This commit splits the cache and data into two different locations.
It also stores the cache in a path that is dependent of the mirror url
being used by swupd. The commit also makes all references to files in
the cache or data directories through getter functions thus removing the
hardcoded reference to the file's location, making it easier to move the
location in the future if needed. Lastly, this commit changes the read
permissions for the data directory and the manifest directories in the
cache to be user readable.
2020-06-08 12:10:39 -07:00
Otavio Pontes 91173f50b2 heuristics: Use a sorted list algorithm to apply heuristic rules
Instead of comparing all rules to all files we can use the fact that the
file list is already sorted to compare only the elements that we need.

So if n is the number of files and m is the number of rules we moved from a
O(n*m) code to O(n+m).

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-29 14:42:54 -07:00
Otavio Pontes 99823e0d66 sys: Use a list for get_mounted_directories()
Instead of saving it in a global string, just use a list of strings to
return the current mounted directories. Also moving function to sys.c

Also fixes hashdump command to correctly print the warning if file is a
mounted directory.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-29 14:42:54 -07:00
Otavio Pontes a9301c660a heuristics: Create heuristics rules
Instead of using multiple ifs, create heuristics rules to be applied
to each file.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-29 14:42:54 -07:00
Otavio Pontes 8d40ad38bd heuristics: Remove function with unused result
Function is_under_mounted_directory() has a bug in the file comparsion function,
so it's returning always false. As this is broken and this doesn't look to be
needed, removing it.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-29 14:42:54 -07:00
Castulo Martinez e3326a4e34 Removing dead code in clean.c
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-21 14:31:20 -07:00
Otavio Pontes 721aae6358 clean: Clean manifests in deprecated location
Manifest directory has moved and we need to clean manifests in previous location.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-19 13:47:37 -07:00
Castulo Martinez 9d995c1ad5 Move manifest deltas to the manifest dir in state
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
Castulo Martinez 8e4c017365 Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
Otavio Pontes c83391321c Revert "Move manifest deltas to the manifest dir in state"
This reverts commit 845b74f95b.
2020-05-15 08:18:45 -07:00
Otavio Pontes d5d3c599d2 Revert "Moving downloaded manifests to their own directory"
This reverts commit 336fee7a9d.
2020-05-15 08:18:37 -07:00
Otavio Pontes 24ecf6c913 delta: Improve message on delta errors
Print a more useful error when we fail to locate a file to apply a
delta. Add a suggestion for the user to run `swupd repair` and make
it clear that the problem is in their system and not in the update
content.

Fixes #1425

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 13:41:59 -07:00
Castulo Martinez 845b74f95b Move manifest deltas to the manifest dir in state
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -07:00
Castulo Martinez 336fee7a9d Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -07:00
Castulo Martinez e473385084 Bug_Fix: Only update templates if repos exist
Closes #1566

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 10:49:45 -07:00
Otavio Pontes 062cab09cf curl: Remove '*' character in error output
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 09:26:12 -07:00
Castulo Martinez 9958f9c4ce Moving some remaining functions to statedir.c
Some of these references to statedir where left in the code, this commit
moves them to the statedir.c module so references to content of the
statedir are not hardcoded. Files in the statedir can move to different
locations freely this way.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 08:27:24 -07:00
Otavio Pontes 7263b2d774 verify: Don't apply heuristic to os-install
Don't run heuristics for os-install or repair --quick.
On os-install we want all files to be always installed. On repair --quick
we don't process any do_not_update files

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-13 08:24:37 -07:00
Castulo Martinez 66d002d0ce Repairig amemory leak in delta.c
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-13 08:24:24 -07:00
Otavio Pontes 260fed75d5 thread_pool: Number of threads can be zero
Actually thread_pool supports zero threads, that means exactly running in
serial. So rolling back to what it was before the integer conversion fix of
commit 2a7f181e00.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-13 08:24:06 -07:00
Castulo Martinez e552a95645 Add function to remove the content of a directory
Instead of having a function to remove the contents of a specific
directory in the statedir this commit creates a generic function to
remove the contents of a directory without removing the directory
itself.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00