This release fixes swupd to use the full path provided by the certpath
option and not append a hardcoded certname to it, fixes memory corruption
on multiple swupd_init calls, and fixes the lock file descriptor leaking.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
The mixer and image creator treat the certpath as the full path of the
certificate filename, and swupd should too. If someone is overriding the
certificate with the cert path option, use the supplied string and don't
append a pre-defined name to it.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
When swupd_init() is called more than once in
the same supwd run, pointer corruption ocurs on
some global variables causing memory corruption
and finally a SIGABRT. This patch fixes that
condition by properly setting all globals to
NULL when swupd_deinit() is called; or more
properly free_globals().
This release adds a bundle-list subcommand to make the cli more clear,
cleans up unused files in testing dirs, and ports the post update scripts
calls to the modern clr-boot-manager directly, which is able to handle various
kinds of kernel/boot updates. Support for automated building within a docker
environment has been added to allow developers to test their changes against
latest inside of a clean Docker container.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This change adds a simple "./continous.sh" script which will allow
developers to test their changes against "clearlinux:latest" within a
clean Docker container.
If the container does not already exist, it will be created on demand.
Future builds will be done near instantly within the container.
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
Explicitly mark the return results of system as unused. This helps to
cut down on the compiler spam as we (by design) do not check the return
results of the scripts portion.
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
In the current system we depend on the legacy boot infrastructure, which
has been provided by clr-boot-manager in the way of compatibility scripts.
These scripts all do the same thing, which is to invoke clr-boot-manager
with the "update" subcommand.
Given that clr-boot-manager doesn't need to know the context of the
operation, i.e. it is able to deduce whether kernel or bootloaders need
updating, regardless, it makes little sense to use any of these scripts,
and we should begin to deprecate them.
In clr-boot-manager 2.0, we will look to remove these compat scripts
completely, however they will continue to exist until then to facilitate
necessary format bumps, etc.
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
The swupd unit tests need a group of
options for execution environment.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This adds are required standard options
to select content server, version server,
format, and so on.
Options added:
-u, url for version string and content file downloads
-c, url for content file downloads
-v, url for version string download
-p, path to verify
-F, format suffix for version file downloads
-n, Do not attempt to enforce certificate or signature checking
-S, Specify alternate swupd state directory
-C, Specify alternate path to swupd certificates
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
"bundle-add" sub-command used to validate "list" option in a unit test,
now that option is part of "bundle-list" sub-command with a new
name: [-a, all], for this reason the test has been updated in order to
validate it using "bundle-list" sub-command.
Furthermore this test has been moved to new directory called
"bundlelist/all" this in order to keep source code integrity.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
The option [-l, --list] is no longer part of "bundle-add"
sub-command, now this option has been taken by "bundle-list"
sub-command using a new name [-a, --all], this information
is updated in swupd man page and markdown file.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
The current option name (--list) for bundle-list sub-command
could sound redundant and confuse, [-a, --all] is a more
a more appropriate name since it can show "all" available bundles
in certain clear linux release.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This option has been used to list all available bundles
in certain clear linux release, it is present in "bundle-add"
sub-command however at this moment this option is more consistent
if "bundle-list" sub-command get it.
This is in order to keep coherence and semantic.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This release introduces a new certificate for swupd to verify Manifest.MoM
signatures with. The old certificate served too many purposes, so to logically
seperate it, swupd will now have its own certificate solely for verifying
updates, while another will be used to verify build artifacts.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
The current certificate used to verify the Manifest.MoM signature is also used
to verify various build artifacts, and thus should be split up into multiple,
single function certs. This introduces a new certificate that will be used
exclusively to verify signatures for updates, while the old one will be used
to verify build artifacts like the image.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This release enables mandatory signature verification, which means the
Manifest.MoM signature MUST verify correctly for an update operation to
continue, else swupd will exit. This ensures that wherever the content comes
from, i.e thru a CDN, clients are guaranteed to receive the "correct" content
that they were intended to consume. It also forces clients to remain on the
secure update path if only verifiable content is allowed on the system.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This sets swupd signature verification to mandatory, failing and exiting
for any verify error, though --nosigcheck enables user to bypass all
signature-based security checks.
The signed MoM serves as the top level chain of trust, and it is used to
extend content trust down to the individual file level. When the signature
of the top-level MoM is invalid or cannot be verified for any reason, we
warn and abort the operation.
Passing --nosigcheck will allow this to proceed, explicitly accepting the
unverifiable MoM and outputting a log entry to the Journal. This is not
recommended and unsupported by upstream once the chain of security is broken,
because it may imply update content was or may be installed that was not
generated by the official upstream.
Signed-off-by: Brad T. Peters <brad.t.peters@intel.com>
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
This release updates errors so they return proper values in various code
paths, adds the bundle-list subcommand, fixes style for compliance via
clang-format, adds support to supply a certificate at runtime, and updates
testing to support mandatory signature verification.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
The other subcommands already use this error code, so make 'update' use
it too.
Also, the calls to 'strerror(errno)' don't make sense in this context,
so remove them.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Make sure tar extraction errors count towards pack errors, and use the
generic ENOSWUPDSERVER if download retries do not resolve the issue.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When pack or fullfiles fail to download for 'verify --install' or
'verify --fix', respectively, the operation fails, but it does not leave
the system in a corrupt state, so there is no need to report stats in
this situation.
Also, make sure to use errors from the download functions in case
they return specific error codes (converted here to their positive
variants).
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
It was only being reset for the first call, but it should be reset
immediately before *every* call to ensure correct error detection.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Again, to consolidate usage of custom error codes, EINVALID_OPTION is
always used for command-line option parsing failure.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This information describes the funcionality
of "bundle-list" sub-command. It is added to
swupd man page and swupd markdown file.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This is a new sub-command for swupd called
"bundle-list", this command will show which
bundles are installed in the local system.
This information is obtained reading
/usr/share/clear/bundles path in local filesystem.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
This function reads installed bundles from local standard
directory and store them in a list pointer passed as argument, this
function is the base for functionality as listing installed bundles to
user.
Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
As it turns out, systemd is so efficient spotting new telemetry
records and spawning swupd-probe to retrieve them, that on several
occasions it does so before the entire record is written out by
printf(). This results in the server receiving an empty record from
the swupd telemetry process - it is reading the record data before
writing succeeded.
To guard against this, we atomically move (rename(2)) the record
after it was fully generated. This assures that the full record data
is present before swupd-probe can see it.
To do this safely, we mkstemp() the record outside the telemetry
spool in /var/lib/swupd, and then move it after it is complete
into /var/lib/swupd/telemetry. This requires, unfortunately, that
we use basename(3), and another string for the final file name,
since rename(2) doesn't allow moving to a folder (it requires the
file argument).
To simplify the discovery of C code style issues and enforce the rules
specified in .clang-format, I've added a new 'compliant' target for
running the appropriate clang-format command.
In case code style issues are found, source files are modified in place,
and the resulting diff can be viewed. The exit code in this case will be
1, so make will exit with an error. This helps to automate testing for
code style issues.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
With mandatory signature verification being enabled, the tests will have
to generate a certificate and sign their Manifest.MoMs to properly run the
swupd operations.
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
Each of the subcommands that may perform signature verification should
be able to override the default cert path using the function defined in
the previous commit. If signature verification is *not* enabled, the
overrides are no-ops.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
There is a need to override the cert path at runtime, so migrate to
using a global variable that is set in init_globals().
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Because the semantics of how these routines operate are not completely
obvious, make sure they are documented.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
To better support running the functional test suite with signature
verification enabled, make the certificate location configurable. Note
that the basename of the certificate used for verification can be
configured separately with the --with-swupdcert=NAME option.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>