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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
stime is deprecated in newer versions of glibc, so using the recommended
clock_settime() instead.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>