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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>
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>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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).
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>
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>
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>