920 Commits
Author SHA1 Message Date
John Akre 166b85cb95 manifest.c: Clean statedir-cache when statedir is corrupt
When a statedir manifest is corrupt, the statedir-cache must also be
cleaned so that the manifest can be downloaded over the network on the
second attempt.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-20 14:45:34 -07:00
John Akre 6f9bdc362c helpers.c: Verify statedir-cache owned by root
The contents of the statedir-cache can be copied to the statedir, so it
must follow the same permission requirements.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-20 14:45:34 -07:00
John Akre eac860e338 Add statedir-cache support
The --statedir-cache flag specifies a secondary statedir that will be
checked before downloading files over the network.

The primary reason to use the statedir-cache is to enable the os-install
command to take advantage of hardlinks when installing content across
partitions. In this case, update content stored in the statedir-cache
(source partition) will be copied to the statedir (target partition) before
installing content into the target partition. Since the update content
will exist on the target partition before installation, hardlinks can be
used instead of copies.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-20 14:45:34 -07:00
Otavio Pontes e8e9c39f84 packs: Fix memory leak
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 12:43:31 -07:00
Otavio Pontes 0696de4435 curl: Initialize curl as needed
Instead of initializing curl library on start, initialize it only when needed.
The advantage of this approach is that we can run some commands offline, if
there's no file to download.

Fixes #801
Fixes #895
Fixes #277

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 914700dc0a curl: Use same curl config on function to get content size
Use same init function for the curl handle used on
swupd_curl_query_content_size()

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 6495066fd4 curl: Check for http in globals and not curl
Instead of checking if the url is valid and approved in curl we can check
that in globals. This is important because we should fail even if we aren't
going to download any file and curl may not be initialized

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 441f270e5c fullfile: Fix memory leak on errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 0f70f3048a curl: Don't export capath parameters in check_connection
Don't let users to set the capath to use to test the connection.
This property should be only used by curl module.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 5ae49aaad2 curl: Use same retry strategy defined on sync curl on async curl
Don't retry downloads that are set as dont_retry by sync curl even on
async curl.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes 23de8a6cec curl: Stop using CURLOPT_PIPEWAIT flag temporarily
We're seeing a problem in current curl when using the flag
CURLOPT_PIPEWAIT and trying to download a file from an unexistent or
unreachable server.

Easiest way to reproduce that on swupd is to disable your while you are
in the download phase of any swupd command. Without this patch swupd will
hangs and wont timeout.

The downside of removing this flag is that curl will prefer to open more connections
instead of waiting to check if it can multiplex. So it's a good thing to have
this enabled back in the future

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Otavio Pontes eda855d1ef update: Save swupd binary path before executing any update process
On updates swupd binary can be replaced so readlink will fail to get the
swudp binary path. In this case we should run that before running any update
process.

And besides that hardcode /usr/bin/swupd as the default swupd path in the case
there's something wrong with readlink

Fixes #1067
Fixes #1068

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-15 15:23:55 -07:00
Otavio Pontes 71518b4888 version: Change API of read_versions back to original
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 14:31:33 -07:00
Castulo Martinez a41bea9fd5 Show the real latest version using check-update
When running the check-update command we get the latest version for the
format we are currently in, but we really want to get the latest version
regardless of the format.

This commit fixes the issue.

Closes #482

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-14 14:31:33 -07:00
Otavio Pontes f19e8dce06 search-file: Don't estimate the total download size for manifest
Estimating the total download size is almost as slow as downloading the
manifests. So just don't do it.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
Otavio Pontes 299977fec4 update: Download search-files indexes on update
If --update-search-file-index flag is used on update, all search-file indexes, i.e.
all Manifests will be downloaded on update. This shouldn't be used if you have
disk or network restrictions, but it shouldn't be very download intensive after the
first usage because delta manifests are going to be used.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
Otavio Pontes f30e7e7597 search-file: Rename the file to a proper name
The search command was renamed to search file, so rename the file and
main functions name

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
John Akre 970f3a257a bundle.c: Return included manifest loading errors
Previously, when adding included manifests errors were thrown away which
resulted in swupd operations that could succeed, even when failing to
load an included manifest. Now when an included manifest fails to load,
swupd will return a failure.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-12 14:38:34 -07:00
Otavio Pontes 72eb7a94b3 globals: Fix unitialzed memory access
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-07 16:38:24 -07:00
Castulo Martinez 83ddcdb301 Enabling ability to read multiple config files
This commit enables the ability to provide many paths for the
configuration file and read configuration from all of them if more than
one config file is found. If the same option is defined in more than one
configuration file it will just be overwritten by the one last read.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-07 15:52:04 -07:00
Otavio Pontes 6bc965b031 globals: If path_prefix doens't exist, creates it
This is very handy for testing because we can just run:

$ swupd os-install --path testing/

And the testing/ directory will be automatically created. It's the same
behavior we have for the state dir.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-07 15:50:53 -07:00
John Akre 031c06776e os-install: Add download flag
When the --download flag is set for the os-install command, update
content will be downloaded to the statedir and no content will be
installed.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
Castulo Martinez 6a4b15b430 Fixing message when using repair and --picky
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-07 09:43:41 -07:00
Castulo Martinez b4c346840e Removing unused assignment to variable
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-07 09:42:51 -07:00
Otavio Pontes a22f621a5e log: Print download sizes in MB and not Mb
MB stands for Megabyte and Mb stands for Megabit, so use the correct
unit.

Fixes #1044

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-05 16:10:02 -07:00
Otavio Pontes 58360629cf extra_files: Fix uninitialized variable
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes d339feb172 culr: Print debug info if unable to set user agent
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes 770bf33a29 curl: Create a local pointer before passing it to another function
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes 80f7860888 curl: CURLE_RECV_ERROR should always be considered an error
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes 2b61f8a237 hash: Force a minimum size for swupd hash
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes bd0a9d6b9e binary_loader: Check for errors on malloc()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes bb19899bff update: Fix memory leak on check_manifests_uniqueness()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes 2e6747f9f6 packs: Fix memory leak on download error
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes f63290584e globals: Invalid usage of realpath
Using correct parameter to realpath()

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes fb1cc0c978 telemetry: Report errors when telemtry fails to report problem
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes f908ebccba clean: Simplify function to count occurences of a char
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 16:29:32 -07:00
Otavio Pontes d97c219f69 mirror: Removing invalid ! in check connection
check_connection() returns an int. We shouldn't use ! before comparing it to zero.
If check_connection() return is zero it's a success.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-01 15:11:58 -07:00
Otavio Pontes a547d9974d sys: Add NULL on run_command() call
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-31 12:16:13 -07:00
Castulo Martinez e82e21d7a3 Updates to the man pages
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-30 09:54:56 -07:00
Castulo Martinez 476cfe14f6 Warn users when using "swupd verify -B"
Using the -B option with verify can have some undesired side effects
since the option is usually missused by users.

This commit adds a warning explaining what are the possible side effects
of using the "-B" option.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 8ee29306ca Minor cosmetic changes for os-install
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 93662e4d81 Improve the flag restrictions for repair
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez a65fe6804e Print only one warning for verify
When using the "verify" command, we show a warning saying the command
has been superseded by "diagnose". But if the user also uses the
"--install" or "--fix" options with "verify" we show another warning
saying those options have been superseded.

We only want to show one warning depending on the options chosen by the
user so we suggest them to either use "diagnose", "repair" or
"os-install" instead.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez b81a3edaae Improve the flag restrictions for verify/diagnose
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 62925f2191 Removing --bundle flag from diagnose
The -B/--bundle option is confusing and causing users to wipe out their
systems. This option was really just meant for os-install, so this
commit removes it from "swupd diagnose"

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 2e3a584558 Removing --bundle flag from repair
The -B/--bundle option is confusing and causing users to wipe out their
systems. This option was really just meant for os-install, so this
commit removes it from "swupd repair".

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez f8ccba6d27 Test swupd-update.timer also for autoupdate status
When determining if autoupdate is enabled, swupd should not only check
the status of swupd-update.service but has to check swupd-update.timer
as well.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 13:52:46 -07:00
Castulo Martinez 9cd5993c48 Change to clarify the use of -l/-B in search-file
Closes #1019

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 13:48:40 -07:00
Castulo Martinez c0b340bbd2 Fixes a bug when deleting extra files
When swupd repair is run with --picky or --extra-files-only it attempts
to remove all those files that are in the picky tree and that are not
mentioned in any manifest (from installed bundles). If swupd
encounters an error removing any of these files or directories, it
prints a message showing the failure. This message was wrong since it
was not showing the whole path to the file being deleted when the path
included a prefix.

This commit fixes the issue by appending the prefix to the path so it
shows correctly.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 13:43:49 -07:00
Otavio Pontes d9710e78d0 sys: Check for errors on calls to dup2 and open
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-26 15:52:57 -07:00