107 Commits
Author SHA1 Message Date
Patrick McCarty 8775f5e3d8 Release v3.5.2
This release addresses the following bugs:

- Fixes 'search' to list symlinks in search results.
- Fixes potential NULL dereferences in 'search' and 'bundle-remove'.
- Fixes a couple of quoting issues when running tar commands.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.5.2
2016-04-22 11:53:51 -07:00
Brad T. Peters b3b08eedd3 Add symlink match to Search
Match search term against symlinks as well as files. This is
necessary in order to find hits for perfectly valid searches
2016-04-22 11:51:24 -07:00
Ikey Doherty 9c0a3f7122 Avoid potential null pointer dereferences and uninitialised values
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2016-04-22 11:45:20 -07:00
Ikey Doherty bd2151ddc0 Clean up tree in accordance with clang-format
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2016-04-22 11:45:14 -07:00
Dmitry Rozhkov a7fa670e82 staging.c: Protect tar command against special characters
It may happen that a bundle contains a directory named '#' and
other files under this directory, thus not only target files
need to be escaped in tar commands, but also target directories
where the files get installed.

Also a target file may have a name with '@' as its first symbol.
Since the symbol has a special meaning in case of bsdtar the
name needs to escaped in tar commands with the prefix './'.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2016-04-22 11:15:21 -07:00
Patrick McCarty 678066c21c Release v3.5.1
This release fixes two crashes, when either 'check-update' or 'update
--status' are run without options, and improves error handling and
reporting when the current OS version cannot be determined.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.5.1
2016-04-18 11:33:25 -07:00
Patrick McCarty ef101ba126 Rename the version-getter functions
Since we are either determining the current OS version, or the latest OS
version, at any given time, rename these functions to reflect that.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-18 11:23:56 -07:00
Patrick McCarty 0ea8b9deb4 Use more predefined error codes in check_update()
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-18 11:05:56 -07:00
Patrick McCarty 38a2a2e9b4 Use unique error code for current version check failure
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-18 11:04:31 -07:00
Patrick McCarty 60607995bf Implement the same fix for 'update --status'
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-18 10:52:31 -07:00
Patrick McCarty 70537bb0ad Correctly set all necessary globals for check-update
Various other globals need to be initialized, such as version_url,
format_string, and state_dir, so init_globals() needs to be called.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-18 10:38:31 -07:00
Patrick McCarty 7b14eddad8 Fix for deleted file accounting
With the recent change to swupd-server that removes old deleted files in
the initial manifests for a new format, the case in which these files
are absent from the new manifest should not be counted as deleted.

Also, fix another deleted file accounting issue: the file could have
been deleted anywhere in the range current < N <= new, not just at the
latest (new) version.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-15 14:14:49 -07:00
Patrick McCarty bdeff015dc Release v3.5.0
This release adds some new features and fixes a few bugs.

New features:

- The state directory is now configurable (defaults to /var/lib/swupd)
  with the -S/--statedir option.

- Adds a bash completion script for the swupd binary. It is not
  installed by default, but lives in the toplevel directory of the dist
  tarball (swupd.bash).

- Adds support for "-m latest" when running 'verify --install', which
  will download update content for the latest version for the current
  format.

Bug fixes:

- Fixes a crash in 'hashdump' when the -b option is not specified.

- Fixes a crash in 'bundle-remove' that occurs when attempting to remove
  a bundle that exists in the tracking directory but does not exist in
  the Manifest.MoM.

- Fixes a bug with manifest consolidation that can result in files not
  being deleted during an update when they should be.

- Quiets progress messages related to the new bundle includes
  functionality.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.5.0
2016-04-13 15:35:53 -07:00
Patrick McCarty 058ff85218 Print update/verify status message after fd leak check
In case there are file descriptor leaks, those issues would be printed
after the status message, but it should be the other way around: the
last printed message should reflect the result of the action.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-13 12:15:30 -07:00
Patrick McCarty 9b9bffded2 Call free_globals() in main_update() instead
This call site seems like a better location, more aligned with how the
other subcommands call free_globals().

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-13 11:58:31 -07:00
Patrick McCarty cc7095c9b9 Create the lock file in the state directory
Now that the state directory is configurable, it is more convenient to
store the lock file there, since at most one instance of 'swupd' should
be modifying a given state directory at any time.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-13 11:52:18 -07:00
Patrick McCarty 2b5063fa13 Consolidate several initialization steps into swupd_init()
Since most of these checks are used by all subcommands, and are written
in slightly different ways, move all of the checks into swupd_init() to
do the checks in one place and prevent misordering of these calls.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-13 11:52:12 -07:00
Patrick McCarty 311050ddd1 Add a functional test for the expected delete/delete consolidation
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 15:19:15 -07:00
Patrick McCarty c7b5c9e5ba Fix manifest consolidation when files are deleted in different versions
In the case where a file is deleted from all bundles in the latest
version, but the bundles may have deleted the files in different
versions, make sure the latest version is always chosen to consider for
the update.

I have encountered updates where a deleted file was selected during
consolidation that was deleted in an older version than the version I
updated from, although it was deleted more recently in another bundle.
Since the older deleted file does not get added to the update list, the
file is not deleted during the update.

To avoid these scenarios, always consider the case when two files are
marked deleted in the sorted list, and choose the newer of the two.
Note that this case must be considered before the other delete
conditions, because it is more specific.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 15:19:15 -07:00
William Douglas 1b9032a448 Add support for verify --install -m latest
Instead of specifying a version number argument to -m allow passing the
latest string which will query for the latest version and use that as
the install target version.
2016-04-12 21:33:19 +00:00
Patrick McCarty 362d85d153 Refresh the completion script
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 12:59:07 -07:00
Patrick McCarty cffea758d6 Create state directory after init_globals()
Because init_globals() sets the value for the state directory, make sure
it's created after that call.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 12:33:38 -07:00
Patrick McCarty 9322620a5e Add missing break statement for 'update' option parsing
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 12:00:42 -07:00
Jaime A. Garcia 14bfa6da49 add --statedir option to alternate state directory
This option overrides the global setup for state_dir
variable that is now used to find out where swupd
is going to do work (state dir).

If not --statedir option is passed along, the global
STATE_DIR definition value is going to be used instead,
this last one can also be changed at compilation time.

Signed-off-by: Jaime A. Garcia <jaime.garcia.naranjo@intel.com>
2016-04-12 11:13:14 -07:00
Patrick McCarty 85538d5920 Restore one printf() from previous commit
Because it is useful for 'bundle-add' to report invalid bundle names,
and invalid names will never appear from includes in the 'update' path,
restore the printf() for the invalid bundle name case.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 11:05:12 -07:00
William Douglas 3d0c071e1a Reduce noise for updates and bundle-adds
Stop printing a message when bundles are included and going to be
installed or if bundles are already included and going to be skipped
when doing the add_subscriptions call.

Instead update the install_bundles call to notify users when an
installed bundle was attempted to be be installed again.
2016-04-12 11:03:47 -07:00
Patrick McCarty b744710e9c Distribute the completion script 2016-04-12 10:44:30 -07:00
Patrick McCarty ccf88f5295 Generate initial bash completion script
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 10:43:58 -07:00
Patrick McCarty 44cff67cb4 Move some auxiliary scripts to the scripts directory
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-12 10:42:32 -07:00
Jose R Guzman cf9d47383c Adding script to create autocompletion function for complete command.
Signed-off-by: Jose R Guzman <jose.r.guzman.mosqueda@intel.com>
2016-04-12 10:11:16 -07:00
Jaime A. Garcia 8cfeb710be fix segfault in bundle-remove on invalid bundle
When trying to remove a bundle that has not
valid name contained into /usr/share/clear/bundles
a segfault arise. This patch solves that by
properly validating the bundle name is valid
within MoM.

Signed-off-by: Jaime A. Garcia <jaime.garcia.naranjo@intel.com>
2016-04-08 20:18:03 +00:00
Patrick McCarty 846648382d Fix crash when running hashdump
In a previous commit, the init_globals() call was removed from the
hashdump code, which resulted in path_prefix not being set in case the
--basepath option was not specified, and led to a NULL pointer
dereference.

Fix the issue by calling the new set_path_prefix() function. The NULL
value will honor the --basepath option if specified, or set the default
path_prefix.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-08 11:38:05 -07:00
Patrick McCarty 68f893c471 Refactor path_prefix initialization
Similar to how the content URL, version URL, and format string globals
are now set, do a similar reorganization to set path_prefix in its own
function and update all subcommands to use this new function.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-08 11:38:00 -07:00
Patrick McCarty 9bca07e763 Release v3.4.0
This release includes the following changes:

- Modifies default behavior for the "search" subcommand; it now searches
  for all matches by default and can be limited by using the --scope
  option.

- Removes default URLs and format number from the binary and instead
  uses config files to store the defaults. The config files live in the
  /usr/share/defaults/swupd directory.

- Adds missing -c and -v options to the subcommands that needed it, and
  adds the -F option for bundle-remove.

- Adds additional changes to support the bundle includes feature, to be
  soon enabled in swupd-server: installing older included bundles as
  part of an update, and new bundle includes support for 'verify'.

- Fixes removal of standalone, empty directories with 'verify --fix'.

- Fixes fullfile delta application with path_prefix set.

- Fixes error handling in the event bundle manifests cannot be loaded.

- Fixes removal of symlinks with 'verify --fix'.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
v3.4.0
2016-04-05 14:13:50 -07:00
Patrick McCarty afce2631d6 Fix check for symlinks in a dirname path
The intended behavior here is to check if the directory path for the
current file contains any symlinks, not the full path itself. By not
checking the directory path only, verify --fix would not delete any
symlinks that were marked deleted.

Also, because the directory path is being examined now, we can obtain
the directory file descriptor (dirfd) and use unlinkat(2) to delete
files and directories instead of unlink/rmdir; doing so avoids race
conditions in that paths may change between calling realpath() and
unlink().

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 11:27:31 -07:00
Patrick McCarty 8dc4cb8e18 Fix a bundle-remove test that failed to load manifests
The Manifest.os-core was present, but the compressed version was not.
Fix the issue by providing the compressed version.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 22:33:41 -07:00
Patrick McCarty 303796a127 Always handle return codes from recurse_manifest()
There were a few places in the code that needed to check for errors
returned by recurse_manifest(). Notably, if remove_bundles() failed to
load the full set of manifests for installed bundles, bundle-remove may
have removed more files than it should, due to the lack of context
provided by the other bundle manifests.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 22:30:35 -07:00
Patrick McCarty ae6514d7be Remove unused STAGING_SUBVOL macro
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 21:50:40 -07:00
Patrick McCarty 23dd3cc2dd Fix fullfile delta application with path_prefix set
Fullfile deltas were only being applied to the root filesystem, since
the prefix was a compile-time constant string (STAGING_SUBVOL) set to
"/" by default.

Instead, use path_prefix for the prefix so that the deltas can be
applied when specifying --path on the command line. This also enables
writing a functional test for the delta application, added in this
commit.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 21:50:31 -07:00
Patrick McCarty b849edf662 Correction to the empty-dir deletion test
os.path.isfile() will return False if the target file is missing, *and*
if it is not a file. I intended for the check to only determine if the
target directory is missing, so os.path.isdir() is the correct call.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 20:49:25 -07:00
Patrick McCarty 0f5893746b Add functional test for empty directory deletion
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 18:34:58 -07:00
Patrick McCarty cf831dfe50 Fix directory removal for verify --fix
In manifests, deleted files/links are not distinguished from deleted
directories, so we cannot rely on the value file->is_dir to indicate how
the delete should happen. Instead, call S_ISDIR(), since lstat() was run
immediately before.

Also, fix the reporting of a successful directory removal.

Note that there is still a bug with sorting of deleted files in
manifests in that the directories should be deleted only after their
containing files/dirs/etc are deleted, but in the case of a standalone
empty directory needing to be deleted, the current code covers that.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 17:35:43 -07:00
William Douglas a4fe27abad Add includes support in verify
Make verify include aware by adding includes from the official manifest
to the subs list before consolidating the manifests.
2016-04-04 21:24:45 +00:00
William Douglas 7e636c07d1 Fix update when include manifests are not new
Previously include manifests that were not newer than the current
version would be silently ignored even if they had not been previously
installed causing bundles to miss included dependencies.

Fix this by adding a is_tracked field to struct file that is nonzero
when the bundle the file is contained in is marked as tracked via having
a /usr/share/clear/bundles/$name file.

The is_tracked == 0 version of the file will be dropped in the
consolidate_manifest phase if that filename from another bundle has
is_tracked != 0 to avoid downloading and installing an already existing
file.

The is_tracked == 0 version of the file will then be added to the update
list from the consolidated manifest if that file was not previously
installed on the system (in addition to the other cases it would already
have been added to the list for).
2016-04-04 21:24:43 +00:00
Patrick McCarty ddbca5ab86 Improve validation of format string
The returned value of strtoull() is an unsigned long long type. Also, it
cannot be negative, so simply check that it is not zero.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
Patrick McCarty ea14cf04df Simplify fgets() error handling to use one goto
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
Patrick McCarty afa836b9d5 Remove init_globals() call in hashdump
The hashdump subcommand does not require any of globals initialized that
are set by init_globals(), so remove the call.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
Patrick McCarty a0999e72d5 Add missing -F option for bundle-remove
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
Patrick McCarty 54a5dd8a8a Undeprecate the -u option for check-update
Since check-update may need to download content in the future, keep the
-u option around.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00
Patrick McCarty 5407e70e44 Use formatstaging for functional tests
Since a numeric format now requires a config file, and aligning the
client format with the test format is a maintenance problem, use the
"staging" format for all tests.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-04 11:42:25 -07:00