350 Commits
Author SHA1 Message Date
Tudor Marcu 0ca6035b65 Release v3.8.2
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>
v3.8.2
2017-02-27 11:39:09 -08:00
Tudor Marcu bfb26b5c40 Change certpath to be full path of certificate
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>
2017-02-27 11:40:11 -08:00
Jaime A. Garcia beda77b168 fix memory corruption on multiple swupd_init call
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().
2017-02-27 11:36:23 -08:00
Jaime A. Garcia d0918037ac Fix swupd_lock file descriptor leaking
The swupd_lock is not properly closed
when the work is done with bundle-list
subcommand.
2017-02-07 13:41:04 -08:00
Tudor Marcu 339d0bba95 Release v3.8.1
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>
v3.8.1
2017-02-02 11:40:35 -08:00
Ikey Doherty 3c651ce00f Add support for automated building within docker environment.
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>
2017-02-02 11:38:49 -08:00
Ikey Doherty 235bd4fba3 Apply clang-format to some stray in-tree items
Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-02-01 17:39:23 -08:00
Ikey Doherty f477daead8 scripts: Silence system() invocation warnings
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>
2017-02-01 17:39:23 -08:00
Ikey Doherty 6324401974 scripts: Port to the modern clr-boot-manager usage model
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>
2017-02-01 17:39:23 -08:00
Mario Alfredo Carrillo Arevalo 504000ec3a Fix swupd options for bundle-list --all unit test
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>
2017-02-01 11:03:43 -08:00
Mario Alfredo Carrillo Arevalo d9cae3724f Add bundle-list environment options
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>
2017-02-01 11:03:43 -08:00
Patrick McCarty bce9fb436f test: remove unused .signed files
These files have never been used by the functional tests, so remove them
from the tree.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Patrick McCarty 54d494b0fb test: update swupdlib to not consume .signed files
These files are not used by swupd-client, so do not add them to the MoM
tarball.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Mario Alfredo Carrillo Arevalo b49fb6419b Update swupd unit test
"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>
2017-01-31 12:38:29 -08:00
Mario Alfredo Carrillo Arevalo f3c053f782 Update documentation about bundle-[add|list] sub-commands
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>
2017-01-31 12:38:29 -08:00
Mario Alfredo Carrillo Arevalo 38ecfc3b31 Change [-l, --list] by [-a, --all] option in bundle-list
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>
2017-01-31 12:38:29 -08:00
Mario Alfredo Carrillo Arevalo 210d0c6a1c Move [-l,--list] option to bundle-list sub-command
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>
2017-01-31 12:38:29 -08:00
Tudor Marcu e3d85319cf Update travis with correct certificate URL
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-01-30 11:38:39 -08:00
Tudor Marcu 5f342d7c88 Release v3.8.0
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>
v3.8.0
2017-01-26 01:27:08 -08:00
Tudor Marcu a1c0d9995a Update swupd signature verification certificate
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>
2017-01-26 01:19:11 -08:00
Tudor Marcu 6278ebff25 Release v3.7.6
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>
v3.7.6
2017-01-25 14:58:36 -08:00
Tudor Marcu 428d09d003 Move signature verification to mandatory
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>
2017-01-25 15:00:24 -08:00
Tudor Marcu cd110a1875 Release v3.7.5
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>
v3.7.5
2017-01-24 17:46:12 -08:00
Tudor Marcu 06c6211561 Fix style for compliance
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-01-24 17:27:15 -08:00
Patrick McCarty e796a6c7ee update: ensure non-negative exit status
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty d92f891842 update: return generic error for version check failures
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty 8bf790840c Ignore STATEDIR/version write failures
Since this file is currently unused, a write failure should not affect
exit status.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty 6bbb774d94 Use EMANIFEST_LOAD for manifest-related errors
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty b97181dde3 Use ENOSWUPDSERVER for all check_network() failures
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty 45ce2dc18a update: return ERECURSE_MANIFEST where appropriate
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>
2017-01-24 17:30:42 -08:00
Patrick McCarty 0c8014829e build: ignore file created by autogen.sh
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty 42a8e35bda test: ignore new generated files
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty d0a3c84d37 verify: return EFULLDOWNLOAD for fullfile download errors
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Patrick McCarty 166645aa3b Improve pack download error handling
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>
2017-01-24 17:30:42 -08:00
Patrick McCarty f6742d904b verify: if downloads fail, do not report stats
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>
2017-01-24 17:30:42 -08:00
Patrick McCarty 3969071ece Reset errno before every call to readdir()
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>
2017-01-24 17:30:42 -08:00
Patrick McCarty ef0738eaef Use EINVALID_OPTION for parse failures
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>
2017-01-24 17:30:42 -08:00
Patrick McCarty 0e6bb27ecc Always return EMOM_NOTFOUND for load_mom() failure
There is a dedicated error code for load_mom() failure, so use it
everywhere.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-24 17:30:42 -08:00
Mario Alfredo Carrillo Arevalo ee69a9d581 Add doc about bundle-list sub-command
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>
2017-01-18 09:52:49 -08:00
Mario Alfredo Carrillo Arevalo bcce348e1b Add new bundle-list sub-command
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>
2017-01-18 09:52:49 -08:00
Mario Alfredo Carrillo Arevalo c244d36be3 Add function that reads local installed bundles
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>
2017-01-18 09:52:49 -08:00
Auke Kok af8fa61a6b Telemetry: Atomically create telemetry record.
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).
2017-01-18 09:46:05 -08:00
Patrick McCarty 005ecd8810 build: add 'compliant' target for fixing code style issues
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>
2016-12-21 16:09:13 -08:00
Tudor Marcu a4fb9ae027 Add missing certificate attributes conf
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:18:08 -08:00
Tudor Marcu cd48c3f6be Add prereq file to make tests work in parallel
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:14:27 -08:00
Tudor Marcu a565cd0304 Update tests for mandatory signature verification
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>
2016-12-20 16:13:55 -08:00
Patrick McCarty 4a04e83f41 Add command-line options to override default cert path
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>
2016-12-20 15:39:13 -08:00
Patrick McCarty 0d85b51731 Add runtime override capability for the cert path
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>
2016-12-20 15:39:13 -08:00
Patrick McCarty 9c910c871e Add more docstrings in globals.c
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>
2016-12-20 15:39:13 -08:00
Patrick McCarty 07a7b03700 Make the certificate location configurable
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>
2016-12-20 15:39:13 -08:00