Commit Graph

2073 Commits

Author SHA1 Message Date
Castulo Martinez cf263bbd07 Move function to set the path to the statedir
Moving the function to the appropriate statedir module.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 62bb6bd8a0 Function to get the version from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 8ba1812c6f Function to get the delta pack from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 251c2cb68f Functions to get the manifests directory and delta
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 74ec454110 Function to get the path to the swupd_lock file
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez a3a1ad1d3d Function to get telemetry record from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Otavio Pontes a993c1a3fc Enforce warning to check for integer conversion errors
Converting from different int types are not always correct, so turning the
gcc warning that check for conversions that might change the value or sign of
the number.
2020-05-12 12:27:06 -07:00
Otavio Pontes 043351ab09 Fix integer to float conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes e1fd274599 Fixing multiple unsigned to signed int conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 235ea872a8 strings: Use correct variable type for str_len return
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 2a7f181e00 int: Fix some integer conversion errors when using malloc
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 9fd1632ef0 int: Add functions to safely convert signed ints to unsigned
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 5f67a46354 string: Add function to convert from string to unsigned ints
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes fb43852440 motd: Remove motd code that was not being used
check-update was trying to create a motd in a deprecated directory and
it was always failing.

Removing code for now.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:16 -07:00
Otavio Pontes 07fb739c10 test: Add test to make sure we won't forget '\n' on log messages
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:09 -07:00
Otavio Pontes 7f5c1b6ab3 log: Adding missing '\n' at the end of log messages
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:09 -07:00
Castulo Martinez 14bbc2c44d Add functions to get manifest from the statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez eee1585f64 Add functions to get fullfile tars from statedir
This commit adds these function:
- statedir_get_delta_dir: to get the "download" directory
- tatedir_get_fullfile_tar: to get thet downloaded fullfile tar
- statedir_get_fullfile_renamed_tar: to get the renamed fullfile during
  untarring

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez 9844f2a1d0 Add function to get delta dir from statedir
This commit adds the following function:
- statedir_get_delta_dir()

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez 858965f52e Move function to create state dirs to statedir mod
This commit moves the function to create the state directories to the
statedir module.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Castulo Martinez 39bfd77831 Add function to get staging files from statedir
This commit adds the following functions:
- statedir_get_staged_dir()
- statedir_get_staged_file()

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Castulo Martinez ca2601efc7 Consolidate functions to track bundles
Currently we have two functions to track bundles, bundles should always
be tracked in the same location, if there is an exception to this rule
then it should be handled separately.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Castulo Martinez 7e921eca64 Tracking dir functions in statedir.c
This commit adds the statedir.c module and moves the function to get the
tracking directory to this module. It also adds a new function to get
the path to a tracking file into the module.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Otavio Pontes 49131e7059 heuristics: Remove duplicated heuristics check
We check for is_config() and is_state() twice in heuristic check. Removing
the duplication

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Otavio Pontes 6613fc5ffa heuristics: Add test to validate heuristics
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Otavio Pontes d237e4d499 heuristics: don't set is_boot for files that are not kernel files
Bootloader updates should trigger a call to boot manager, but they shouldn't be
treated like boot files.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Otavio Pontes 3bb6c8a9de heuristics: Consolidate main heuristics with the ignore heuristics
Ignore call was confusing and value was ignored for the main usages.
It should always run with the main heuristic functions.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Otavio Pontes 46400708e6 heuristics: Consolidate need_update_boot and need_update_bootloader
Both variables were used to call the boot manager, so renaming them to
neew_update_bootmanager

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-08 13:34:53 -07:00
Castulo Martinez bca38243d8 3rd-party: add bundle-remove --orphans flag
Implementing the --orphans option to remove bundles no longer required
by tracked bundles from 3rd-party repositories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Castulo Martinez 4d0a6d29a1 Implement bundle-remove --orphans flag
This commit implements the --orphan flag for bundle-remove which can be
used to remove bundles that are no longer required by tracked bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-08 09:30:50 -07:00
Otavio Pontes 430ac8b0a7 exit_codes: Add header documentation
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 14:31:27 -07:00
Otavio Pontes 9f4e466ed3 swupd_cmds: Adding header documentation to file.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 14:31:27 -07:00
Otavio Pontes 8fb81bad0f swupd_cmds: Unecessary strlen used to compare.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 14:31:27 -07:00
Otavio Pontes 8d7a7dad6e Organizing src/ directories in categories
src/
    src/3rd-party/ # Everything that is 3rd-party related
    src/cmds/ # All sub-commands from swupd (except 3rd-party ones)
    src/lib/ # Modules that implement functions not dependent on swupd
               behavior (i.e. system interations, logging)
    src/swupd_lib/ # Modules that implement functions dependent on swupd
                     behavior (i.e. hash calculation, signature verification,
                     manifest/bundle handlers)
2020-05-07 14:31:27 -07:00
Otavio Pontes 516e29bad8 autotools: Add src to the default include list
Adding src to default list of includes to make it easier to organize swupd header
files in directories.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 14:31:27 -07:00
Otavio Pontes 4e2e81fa4d Makefile: Adding -Wshadow to prevent accident shadowing
Make sure we are not accidently using the incorrect variable
by not allowing 2 variables with the same name.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 13:28:35 -07:00
Otavio Pontes 3870dc5181 mixin: Remove some mixin leftovers
Some manifest functions used by mixin were left behind

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-07 13:22:28 -07:00
Otavio Pontes fc1f874c89 macros: Create wrapper for malloc and calloc functions
Use always calloc to allocate memory and abort on errors

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-06 09:54:24 -07:00
Otavio Pontes 8876e25bc2 verifytime: Missed a return on ENOENT error
If the file doesn't exist in system, we can't proceed.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-06 09:06:55 -07:00
Otavio Pontes 039f47d51c verifytime: Initialize variables
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-06 08:38:15 -07:00
Otavio Pontes e8000ab614 config: CONFIG_FILE_PATH shouldn't be treated as a path
CONFIG_FILE_PATH contains a list of paths not just one path. So
we shouldn't use realpath to point to it.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 14:29:55 -07:00
Otavio Pontes 13a684f196 sys: Fixing documentation of ls_sys
To be parsed doc commend should start with **

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 13:20:16 -07:00
Otavio Pontes 076aeff0d0 target_root: Use run_commmand to execute tar|tar command
Porting code to better way on interacting with system commands using the
run_command function. As run_command don't support multi-thread for
performance reasons, we are now using a file instead of a pipe. As tar|tar
is now a fallback, this won't have any performance impacts on any case
where with no problems and errors.

Fixes #640 and #671

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 12:22:48 -07:00
Otavio Pontes 04eacb16be verifytime: Making verifytime completely independent again
We have added more dependencies in verifytime, but this was harder to
keep as it looks like, so making it completely independent from swupd
libs.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 12:14:54 -07:00
Otavio Pontes e9c103b6e4 verifytime: Fix integer signal conversion errors
time_t is signed, so we should handle it as a signed int, not unsigned.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 12:14:54 -07:00
Castulo Martinez 0b47050848 3rd-party: add --orphans flag for bundle-list
Implementing the --orphans flag for 3rd-party bundle-list.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Castulo Martinez 4cd51ca5d8 Add --orphans flag to bundle-list
Adding the --orphans flag to bundle-list which shows those bundles that
are installed ut no longer required by any tracked bundle.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Castulo Martinez b27e51356d Functions to list installed and tracked bundles
This commit adds a couple of functions:
- bundle_list_track():  list the bundles that are tracked in the system
- bundle_list_installed(): list the bundles installed in the system

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-05 10:37:44 -07:00
Otavio Pontes d29865f8a9 swupd.bash: Fixing tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-05 09:09:53 -07:00
Lucius Hu e4d0468cfe swupd.bash: Multiple improvements
- All options and subcommands are automatically generated from help messages.
- Used `_init_completion` to set $cur, $prev, $words variables, which are
  equivalent to $2, $3, $COMP_WORD, but far more readable.
  - It also allows possibility to use other functions provided in
    `/usr/share/bash-completion/bash_completion`, for future
- A minor change on getting current OS version via `swupd info --quiet` from
  reading `/var/lib/swupd/version`, which is non-readable to non-root users
  - Though MoM file is still non-readable to non-root users
- We only ship modern Bash, so the test on Bash version near the end of the
  script is removed
2020-05-05 09:09:53 -07:00