Commit Graph

1259 Commits

Author SHA1 Message Date
Castulo Martinez a2593a556e Print the json output to stdout instead of stderr
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-05-13 14:29:27 -07:00
Otavio Pontes 3e7721583d swupd.bash" Remove extra " when setting COMPREPL
Bash completion was adding line breaks because of that extra " on COMPREPLY

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-05-10 12:43:06 -07:00
Castulo Martinez 2d29ae07f4 Removes iter manifests from bundle-add completion
There is a bug in the code that causes swupd bundle-add <TAB><TAB>
to list regular bundle names as well as iterative manifest names.

This commit fixes the issue by removing the iterative manifests from
the list of results.

Closes #906

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-05-09 15:33:00 -07:00
Castulo Martinez 755c5549a0 Update the copyright to 2019
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-05-09 14:50:07 -07:00
Otavio Pontes c0703398a0 sys: Adding a missing --no-block flag on call that shouldn't block
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-24 09:32:59 -07:00
Otavio Pontes 6c4b44ac37 docs: Use doxygen style on header API documentation
Documentation coverage on src/lib is now 100% and the goal is to eventually
reach that for everything on src/.

Also improve some documention on headers.
2019-04-23 14:59:43 -07:00
Otavio Pontes 798665efb5 docs: Check API documentation coverage
Add command docs-coverage on Makefile and run that on travis builds. For not only enforcing
a 100% coverage on headers inside src/lib/

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-23 13:27:10 -07:00
Otavio Pontes d4ddcb2c9a docs: Use doxygen style on header API documentation
Documentation coverage on src/lib is now 100% and the goal is to eventually
reach that for everything on src/.

Also improve some documention on headers.
2019-04-23 13:27:10 -07:00
Otavio Pontes 30f4ec4436 docs: Add a doxyfile to make it easier to check documentation coverage 2019-04-23 13:27:10 -07:00
Otavio Pontes eb6371afa5 curl: Use a struct declaration instead of void pointers
We can declare the scruct in a header file and define it in a source file so
we can avoid using void pointers for the handle. It's a better approach because
compilers can trigger errors if we use a different type.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 13:30:26 -07:00
Castulo Martinez eb694590a4 Re-enable the json tests
The json tests had been disabled because they were unstable. This issue
was fixed in a previous commit, so these tests should be enabled again.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-18 10:29:49 -07:00
Castulo Martinez 755e7e1527 Use swupd_progress_callback for fullfile download
This commit makes use of the swupd_progress_callback() function to
report progress downloading fullfiles based on how much data we have
downloaded vs the number of files downloaded. This callback will only be
used when the number of files to be downloaded are less than MAX_FILES,
calculating the total download size can be very costly if the files are
too many. If the files to be downloaded are more than MAX_FILES we will
fallback to reporting download progress based on file count as before.

When installing bundles or doing updates, swupd creates a list of files
that need to be downloaded. This list may contain files that were
already downloaded via packages and it often does. These files are then
skipped at the moment of downloading them since they are already in the
system. This causes a misleading output that shows the user that
fullfiles will be downloaded when they are actually not.

This commit filters the list of fullfiles to be downloaded to only
contain those ones that actually need to be downloaded.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-18 10:29:49 -07:00
Castulo Martinez d7210882e6 Use the swupd_progress_callback for packs download
This commit makes use of the swupd_progress_callback() function to
report progress downloading packs based on how much data we have
downloaded vs the number of files downloaded.

This commit also fixes a bug in the download_subscribed_packs function.
Swupd was not downloading the correct pack for bundles not installed in
the system that had been recently added as dependency of another
installed bundle.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-18 10:29:49 -07:00
Castulo Martinez 591aef2ebe Report progress based on downloaded content
When swupd reports progress of content it needs, it does so by counting
how many files it needs to download (fullfiles or packs) and how many it
has already downloaded. This gives a rough estimate of what is the
progress of the overall download, but it can also be very misleading
since some files may be very different in size compared to others. This
is specially true when talking about packs, one pack could be a couple
of megabytes big while another one could be a few hundred megabytes.

This commit adds a curl callback that can be used to report download
progress periodically based on how many bytes have been downloaded vs
how many bytes have to be downloaded in total, giving the ability to report
progress accurately.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-18 10:29:49 -07:00
Otavio Pontes db512848c7 signature: Add a unit test for signature
Create a unit test for signature checking.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 18939abdcc signature: Add check for OCSP when checking the certificate
If OCSP is enabled in the certificate and key usage is set as critical we
need to use OCSP to check if the certificate was revoked. As OCSP isn't
supported on swupd, just abort the operation.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 62a9f81ed2 signature: remove signatures safeguard from global file
We don't need to protect with SIGNATURES ifdef everywhere, just on signature.c

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 47c61f8658 signature: Move swupd specific code away from signature
Make it more generic. Now it's possible to validate any signature, not only MoMs

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 88101532bc macros: Move UNUSED_PARAM to macros
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 58aa0c28af signature: Don't use global variables when not needed
Local variables should be kept local and been freed in local context.
Don't keep them global unless used out of context.

Also adding parameter for CRL. So it's now enabled on signature, but not
used on swupd.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 8876b55c22 signature: Removing unused variable
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes cd3637adfd Signature: Check if signature should be checked in a more appropriate context
Take this global check from signature module. Users of signature checker
should worry if you are or aren't going to check the siganure. Module should
always check that.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 6d2ab6a20c signature: Minor changes in style to make code style consistent
- Renaming functions
 - improvements in comment headers
 - Minor .h style changes

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-18 10:20:41 -07:00
Otavio Pontes 22f68e4981 swupd: Don't include libcurl headers
We have a layer isolating curl API calls, so don't include libcurl
headers on swupd.h.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-17 12:05:47 -07:00
Otavio Pontes c4db7f30fd globals: Replace tabs for spaces on printf
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-17 08:31:44 -07:00
Castulo Martinez ebd657fde0 Removing code not used from bundle-add
Cleaning up some code that does nothing in bundle-add.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-17 08:23:17 -07:00
Otavio Pontes 6f97b70003 archives: Don't assume tarball includes '/' for directories
At first I assumed that all tarballs would have a trailing '/' for directories
and this isn't true. But we can't assume that we won't have a trailing '/'. So
archives_check_single_file_tarball() is now ignoring trailing '/' when comparing
files. That is the same behavior of the function that
archives_check_single_file_tarball() replaced.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-15 13:29:00 -07:00
Otavio Pontes fb57047151 search: Fix test ID duplication on search
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-15 13:28:44 -07:00
Otavio Pontes 61bf5dc999 verify: Fix tests ID duplication on verify
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-15 13:28:44 -07:00
Castulo Martinez 1b9efc01ce Checking for duplicated or missing test IDs
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-15 13:28:44 -07:00
Otavio Pontes b4d852f29b configure: Cert Path was incorrect when default was used for signature check
When we enabled signature check by default we introduced one bug in configure that
was not setting the correct cert path when the flag --enable-signature-verification
was omitted. That wasn't triggered by our tests because we use an alternative signature.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-12 10:41:22 -07:00
Otavio Pontes d4f34bc1a9 archive: Use libarchive to check for tar contents
Stop using binary tar to check for tar contents. Use libarchive instead

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:52:19 -07:00
Otavio Pontes a688c1e77d archive: Don't mix up ints and bools
It's a bad programming practice to mix both

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:52:19 -07:00
Otavio Pontes cd3831c696 archives: move archive module to lib
archive is independent from swupd specific code, so move it to lib/

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:52:19 -07:00
Otavio Pontes d9dedbac91 scripts: Use run_command() instead of system() for all scripts
Also reorganize, change some functions name and create a .h for scripts module.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:13:54 -07:00
Otavio Pontes 4f21c8339c sys: Fix typo
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:13:54 -07:00
Otavio Pontes 7021f8bfa0 scripts: Pre update script was never run for custom paths
We can't append the path_prefix parameter in the file name because it's not
part of the file name. Also uses run_command() instead of system().

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:13:54 -07:00
Otavio Pontes 20922d970b autoupdate: Don't use system() to set up autoupdates
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:13:54 -07:00
Otavio Pontes 7ef0809882 sys: Use run_command() to print messages to the journal
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 16:13:54 -07:00
Otavio Pontes 9525c93265 test: Disabling json tests for now
Disabling json tests that checks for progress because tests are unstable.
If we have any minor changes in the code that could affect how curl is called
we could have different progress reports and because of that we would have false
negatives.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-10 15:27:30 -07:00
Otavio Pontes 7e4d607dab sys: First parameter in argv isn't the basename of the binary
The default is to use the full path of the binary that is being executed and
not the basename.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-09 12:27:03 -07:00
Otavio Pontes 1cd5688ea3 update: use execv() instead of system() to re-execute update
Note that we don't need to use run_command() (fork + exec) because
we don't need to handle any output on swupd. We can just replace current
process with the new swupd execution.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-09 12:26:50 -07:00
Otavio Pontes ff36af7b7d Makefile: Adding extra compiler flags
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-04-03 14:43:04 -07:00
Otavio Pontes f3cdfb0125 verifytime: Add missing \n
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2012-04-19 21:45:46 -07:00
Castulo Martinez 069af9decf Enabling the --json-output flag as a global option
The --json-output flag can be enabled for every swupd command.

This commit converts it to be a global flag, and enables it in every
swupd command.

Closes #869

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-04-01 12:03:23 -07:00
Otavio Pontes 08765f32c4 Makefile: Adding extra compiler flags
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-03-29 13:05:05 -07:00
Otavio Pontes b34390efec search: Fix incorrect usages of printf
Use log functions instead

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-03-28 16:35:01 -07:00
Otavio Pontes 7d6fa1db05 search: Add support to regular expressions in search-file
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-03-28 16:35:01 -07:00
Otavio Pontes 9d6d8aa894 search: Improving search-file results and speed
Reimplement search file to print output in search time instead of saving
everything to be printed later. This makes search a lot faster and reduce
the memory footprint of this function.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-03-28 16:35:01 -07:00
Otavio Pontes ea376e1021 search: Improve manifests download
Use functionalities from manifest.c instead of reimplementing that on search.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-03-28 16:35:01 -07:00