1205 Commits
Author SHA1 Message Date
Otavio Pontes 80719c1607 mirror: mirror --set/--unset fails when --path is not used
Before swupd_init if --path is not used, path_prefix is NULL. Calling
set_default_path_prefix() to force it back to correct value.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-09 13:03:39 -07:00
Otavio Pontes fbc90a0c87 mirror: Warning message should be printed only when theres' no default url
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-06 14:57:18 -07:00
Castulo Martinez 449cde45c5 Bug_fix: Check if directory is absolute, not file
During staging, if a file is marked for deletion, and the path to
the file, or the file istelf is a simlink, then it is not removed. This
is incorrect, if the file itself is a symlink it is fine to remove it,
the only case when it should not be removed is when the path to it
contain a symlink.

Closes #1424

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-06 14:45:17 -07:00
Castulo Martinez 609d785f37 BUG_FIX Don't follow links removing during staging
When during an update a directory was removed and replaced by a symlink
to another directory that contains one or more files with the same name
as files in the directory that was removed, swupd will remove the
directory from the target system and then it will try to remove each one
of the files that were contained in the directory. Since the directory is
now a symlink to another existing directory, it may end up deleting the
files from the other directory. swupd should not follow links when
removing files during the staging process.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-06 14:44:18 -07:00
Otavio Pontes 5ef7670718 Revert "BUG_FIX Don't follow links removing during staging"
Commit caused some files not to be deleted on updates. Waiting for a fixed
version of patch.

This reverts commit b02a3a3ed7.
2020-04-06 09:40:41 -07:00
Otavio Pontes a0ca9e5c97 Prefer strtok_r() istead of strtok()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Otavio Pontes cf009d24dd helpers: Prefer str_or_die() than other printf methods.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Otavio Pontes 35a91aa8cf string: Protect strlen for overflowing by using strnlen
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Otavio Pontes 3338c2a758 log: Prefer vasprintf instead of vsnprintf
vasprintf is already used by other string functions, so create a base
function to be reused and make a copy for log.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Otavio Pontes 19c4dbb6d6 verifytime: Adding more lib dependencies to verifytime
As there are more string functions that will be needed by log and
verifytime and it would be impractical to copy everything, prefering
to include more dependencies instead.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Otavio Pontes ccd57aa794 Don't redifine a standard const
PATH_MAX is already defined by the system, so don't redefine it

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 12:17:54 -07:00
Castulo Martinez 950478729d Fix memory leak during do_staging()
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-02 12:17:37 -07:00
Castulo Martinez b02a3a3ed7 BUG_FIX Don't follow links removing during staging
When during an update a directory was removed and replaced by a symlink
to another directory that contains one or more files with the same name
as files in the directory that was removed, swupd will remove the
directory from the target system and then it will try to remove each one
of the files that were contained in the directory. Since the directory is
now a symlink to another existing directory, it may end up deleting the
files from the other directory. swupd should not follow links when
removing files during the staging process.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-02 10:11:10 -07:00
Castulo Martinez c40b7b094b 3rd-party: repair regenerates scripts of binaries
During a 3rd-party repair, the wrapper scripts of all binaries verified
should be regenerated regardless of if the binary was repaired or not.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 14:37:50 -07:00
Castulo Martinez 20912f8a95 3rd-party: updated binaries need new scripts
When updating a 3rd-party bundle, if any of its binaries is modified,
or the binary is new swupd needs to recreate the wrapper script.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 14:37:50 -07:00
Otavio Pontes 54fcaad51e signature: Accept expired signatures for latest file
It is considered safe to accept expired signatures to validate the latest
file because we are always checking again the signature of the MoM file.

Adding tests to validate that:
 - Expired signatures for latest file works
 - Expired signatures for MoM fails even when latest signature is correct

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-01 08:38:15 -07:00
Otavio Pontes 0c96d28565 signature: Add flags to signature verification to be able to extend it
Replace a bool value with an enum flags, so we can add more modifiers to
function.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-01 08:38:15 -07:00
Otavio Pontes d6ff0586ef 3rd-party: Add 3rd-party share directories to XDG dirs
When creating a wrapper for 3rd-party binaries, append relative
/usr/share and /usr/local/share to XDG_DATA_DIRS variable and /etc
to XDG_CONF_DIRS.

Fix #1411

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-31 14:41:11 -07:00
Castulo Martinez c875ebc428 Correct the comment from sys_path_join()
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-30 15:05:44 -07:00
Otavio Pontes 819f4d1b6a swupd_init: Make sure swupd is always runnin in an existing path
If the path where swupd is running is removed getcwd errors will occurs, mostly
because of multiple commands swupd executes. So move to directory "/", no mather
where swupd is going to be installed, to make sure the path is always existent.

Fixes #1078

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-30 13:59:43 -07:00
Castulo Martinez da0ef3e05e Remove extra slash from paths
This commit removes the extra slash '/' from the path from:
- the update_boot function
- the verifytime script

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-30 13:39:04 -07:00
Castulo Martinez a734463f3f Bug_fix: Fixing memory leaks
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-27 10:00:07 -07:00
Otavio Pontes 3412dd7c6b delta: Don't retry to use manifest deltas
When a manifest delta was incorrect, the full manifest was used. But in the
case of a correct delta that produces an invalid manifest, swupd was never
trying to download the full manifest.

Changing code to try to use deltas only once. On first error, always retry
downloading the full manifest.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-26 18:57:21 -07:00
Ming Chen 86ed7f709f curl: Don't resume download in case of HTTP 416 error
When tens of thousands of files are transferred (eg. update/repair to a
recent build from a very old one), there are chances that curl returns
CURLE_RECV_ERROR when downloading some of the files even if those files
are already successfully downloaded. In such cases resuming download
will always fail with HTTP 416 error - requested range not satisfiable.

This change adds a new download status for HTTP 416 and in case of that
status, start the download from the beginning all over again for the
affected files.

Signed-off-by: Ming Chen <ming.a.chen@intel.com>
2020-03-26 09:57:18 -07:00
Otavio Pontes 85d0d1b19e mixin: Print deprecation warning
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-26 09:54:32 -07:00
Castulo Martinez 5ab4f32545 3rd-party: add force option to "3rd-party add"
When swupd is adding a 3rd-party repo and it finds a non empty directory
that matches the repo's name in the content path it warns the user and
aborts. This may have been caused by a corrupt repo.

This commit adds a --force flag to allow users to instruct swupd to
remove the existing directory and its conent and continue adding the
3rd-party repo.

Closes #1388

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-25 09:11:23 -07:00
Castulo Martinez 43d909838a Remove extra slash from path in 3rd-party funcs
This commit introduces a function to build a path from multiple string
variables and at the same time it removes all duplicated slashes in the
path.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-24 15:00:11 -07:00
Otavio Pontes 8300140fbc nosigcheck: Rephrase warning when --nosigcheck* is used
Also don't print duplicated messages anymore

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Otavio Pontes 434ed2c6e7 version: Add flag --nosigcheck-latest
In some situations it might be useful to skip signature verification of
latest, but continuing checking the signature of the files that are going
to be installed.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Otavio Pontes 077d0bf2b4 mirror: Fixing problems on handle_mirror_if_stale()
- Reorganizing function to be easier to read
 - If path is problematic and there's no access version url config, use the
   one set using compile flags
 - Use correct url to check for local

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Otavio Pontes 168e41c36f version: Enforce signature verification on missing sig
Always enforce signature verification for latest file. If it's missing
we should abort the command.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Otavio Pontes 6e95d64b8a version: Signature check shouldn't fail when we can't get the sig size
Getting the size of a file is not always supported by the webserver, so
we should try to assume a value to download the signature. 4k is good enough
for the signature used by default for swupd/mixer.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Castulo Martinez 01173b5279 3rd-party:bug_fix: don't add unreachable repos
When adding a 3rd-party repo, if the repo cannot be added it is reverted
back. However if a user uses an incorrect URL that hangs and the user
cancels the process, the repo add is never rolled back, which will cause
the invalid repo to be left in the system.

This commit fixes the issue by making sure the repo is reachable and
somewhat valid before adding it to the config file.

Closes #1384

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-20 14:31:24 -07:00
Otavio Pontes 233d4c7e9d Staging: Don't create hardlinks when installing symlinks
Alternative solution to solution proposed on #1318

Instead of trying to create a link just don't try to link symlinks.
Tested patch using bsdtar and implemented automated testing to
validate solution.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-19 12:52:34 -07:00
Otavio Pontes b3e18c8325 curl: Using same progress function used on async to sync downloads
Moving from PROGRESS function to XFERINFO that is recommended by the
manual.

This fix a warning in the build, so we can turn on -Werror in tests

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-19 08:55:02 -07:00
Otavio Pontes 0dbb561c6b curl: Use correct parameter to set XFER data
It looks like CURLOPT_PROGRESSDATA is working, but the correct parameter
to use for XFERINFO is CURLOPT_XFERINFODATA. There's no guarantee this will
work in the future, so porting to the recommended parameter.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-19 08:55:02 -07:00
Otavio Pontes a16ef453c6 sys: Improve debug when running external scripts
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-17 14:01:10 -07:00
Otavio Pontes 2e332d479d globals: Set function as static
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-16 13:49:45 -07:00
Castulo Martinez 44e595691c Bug fix: os-install --bundles with os-core fails
When doing a system install with "os-install --bundles" if the list of
bundles to install includes only "os-core" the install fails.

This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-13 10:03:32 -07:00
Otavio Pontes 9c85b275a3 docs: Replace vi with vim and os-core for xterm
Vi isn't a bundle anymore. Replacing all examples to vim.
os-core isn't a good bundle for example. Using xterm.

Related to #1369

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-13 08:04:37 -07:00
Otavio Pontes f130b303a9 build_opts: Print third party build info on swupd -v
We print all flags selected on build time on swupd -v. This is useful
to check if an specific swupd binary has one specific feature enabled.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-12 15:37:28 -07:00
Otavio Pontes 57e42323bf signature: Dummy signature_verify_data() function missing
When building swupd with --disable-signature we need to have all
signature functions with a dummy implementation that doesn't validate
the signature.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-10 11:00:43 -07:00
Otavio Pontes 2f6370f40d manifest_parser: Don't ignore iterative manifests
We had a format bump and now Iterative manifests aren't supported
anymore. We are safe to remove that from the parser.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-10 10:43:00 -07:00
Otavio Pontes 4ab5677570 clean: Fix comment about iterative manifests 2020-03-10 10:43:00 -07:00
Castulo Martinez d3cf8ac1e1 Do not follow links when validating staged files
When updating 3rd-party bundles, swupd validates the files to be updated
to make sure there were no changes in file permissions that could be
risky for the system, it uses stat to get the file permissions. The
problem is that stat follows links, and while the files are in staging,
the links are really pointing to invalid locations so stat will always
fail.

This commit fixes the problem by not following links when validating
file permissions.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-10 10:19:22 -07:00
Otavio Pontes 126fff4e0d 3rd-party: Fixing some error handling problems on 3rd_party repo
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-06 16:58:14 -08:00
Castulo Martinez d949305082 Reordering 3rd-party subcommands in help
Reordering so it matches the order of the regular swupd commands. Also
adding missing values to config file.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-06 15:08:34 -08:00
Castulo Martinez 68de707c04 Implementing the 3rd-party info command
Implementation of the 3rd-party info command to show the version of the
3rd-party repository along with the update URL.

Closes #1354

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-06 14:54:23 -08:00
Otavio Pontes aeb026db1c Revert "staging: don't convert symlinks to hardlinks"
This reverts commit be1deab965.

Castulo found a critical bug introduced by this commit. Reverting while we are
investigating the root cause and proposing a solution
2020-03-05 13:25:21 -08:00
Otavio Pontes be129d9c7d time: stop using deprecated function stime()
stime is deprecated in newer versions of glibc, so using the recommended
clock_settime() instead.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-05 12:07:47 -08:00