1
0
mirror of https://github.com/freifunk-gluon/packages.git synced 2024-06-17 12:44:00 +02:00
Commit Graph

53 Commits

Author SHA1 Message Date
Matthias Schiffer
a5259c0245
autoupdater: improve handling of interrupted HTTP requests
Check return code of uloop_run() and pass the signal number up when the
loop was interrupted. After cleanup, uninstall uloop's signal handlers
and re-raise the signal to terminate the process.

This allows interrupting the autoupdater using Ctrl-C during downloads,
instead of having it continue with the next mirror (if multple are
configured). As uloop's signal handlers only set a flag to interrupt
uloop_run() and have otherwise no effect, the autoupdater can still only
be interrupted during HTTP requests, ensuring we can't leave the system
in an inconsistent state.
2023-02-24 22:34:26 +01:00
Matthias Schiffer
e4bd7a4549
autoupdater: uclient: fix segfault after interrupted HTTP request
uloop_run() may finish without ever reaching request_done(), for example
when the main loop is interrupted by a signal. In this case,
uclient_disconnect() was never called, leaving a number of callbacks
like timeout handlers registered in the uloop context.

When the main loop was later resumed in a subsequent HTTP request without
completely reinitializing the uloop context, these timeout handlers could
still fire, even though the old uclient context had already been freed,
resulting in a use-after-free.

To avoid this, move the uclient_disconnect() call out of request_done()
to ensure that it is always called before uclient_free().
2023-02-24 21:00:02 +01:00
Matthias Schiffer
5521926500
autoupdater: uclient: remove early returns from get_url()
Simplify control flow by removing early returns. This allows us to
deduplicate cleanup (uclient_free() for now).
2023-02-24 20:59:58 +01:00
David Bauer
b804281664 autoupdater: ignore minor compat-version
Ignore a mismatching minor compat-version. A minor version hints an
incompatibility with configuration, which Gluon re-generates based on
the intent on upgrade. Thus, only mismatching major versions present
a reason to block installation.

This is required to provide a migration path from swconfig to DSA based
ethernet architectures.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-06-26 01:55:38 +02:00
Maciej Krüger
5bca0364d0
pretty-hostname: instantly apply hostname
This makes it work like the CLI
2022-01-20 11:05:35 +01:00
Grische
0648b2dbf7
autoupdater: verify the image before upgrading (#247)
Let sysupgrade run a --test upgrade to verify that the image is
compatible before attempting an upgrade.
This fixes an issue where a router can get stuck without network
connectivity when a a remote autoupgrade was triggered.

Fixes #193
2021-09-08 17:41:05 +02:00
citronalco
83534952a5
autoupdater: Add HTTP-Header X-FIRMWARE-VERSION (#246)
X-FIRMWARE-VERSION gets set to the content of the file referenced by UCI setting "autoupdater.settings.version_file"
If "autoupdater.settings.version_file" is unset X-FIRMWARE-VERSION is
omitted
2021-07-16 19:25:06 +02:00
Jason
85af243158
autoupdater: Fixed segfault on wrong long option
If an autoupdater long option (prefixed with '--') are unknown then a segmentation fault occurs.
Example:
root@node:~# autoupdater --xyz
Segmentation fault

[Matthias Schiffer: changed sentinel syntax]
2020-01-10 00:34:44 +01:00
Matthias Schiffer
9d26ec1cf9
pretty-hostname: do not use module() 2019-06-16 12:45:29 +02:00
Ruben Barkow
71d0566b37 autoupdater: clarify usage of -n in help 2019-05-04 17:19:08 +02:00
Matthias Schiffer
30be52e03b
autoupdater: consider end of string smaller than all characters except for '~'
This fixes ordering for the following patterns:

* 1.0 < 1.0a
* 1.0a < 1.0ab
* 1.0a < 1.0a1

Note that trailing zeros are still ignored (1.0 == 1., 1test0 == 1test),
which matches the behaviour of dpkg and opkg.
2018-12-18 23:16:17 +01:00
Matthias Schiffer
688051cb21
autoupdater: fix regression in version compare
Version strings with the same prefix, e.g. "1.0" and "1.0~pre", or even
"1.0" and "1.0.1" were considered equal. This is a regression in the C
autoupdater rewrite.
2018-12-18 20:22:40 +01:00
lemoer
ed7ed7dcba autoupdater: allow skipping the version check (#187)
this commit introduces a new cli flag "--force-version"
2018-06-03 12:13:50 +02:00
Matthias Schiffer
31e2000604
treewide: remove redundant definitions from package Makefiles 2018-03-07 20:51:48 +01:00
Tobias Schramm
5c6476ea58
autoupdater: use safe allocation functions
Give the user a better error message when allocations fail by using our
checked allocation functions.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[Matthias Schiffer: squash, use safe_realloc]
2018-02-22 02:39:48 +01:00
Tobias Schramm
3566cabef5
autoupdater: add safe allocation functions
safe_malloc() and safe_realloc() are wrappers around malloc() and realloc()
than abort the process if the memory allocation fails.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[Matthias Schiffer: add safe_realloc()]
2018-02-22 02:39:47 +01:00
Tobias Schramm
0b61fee98e
autoupdater: Check if allocation of uci contect was successfull
Previously the return value of uci_alloc_context was not checked leading
to a possible null ptr dereference

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
[Matthias Schiffer: use abort()]
2018-02-22 02:27:57 +01:00
Tobias
c802276581 autoupdater: uclient: fix nullpointer dereference on invalid URL (#183)
Previously supplying an invalid url for download would result in
uclient_new returning NULL and crash the autoupdater as soon as
cl->priv is accessed.

Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
2018-02-19 17:10:44 +01:00
Matthias Schiffer
fc194bc7c8
autoupdater: uclient: add error handling in connection setup
Avoids a segfault when the connection fails early.
2018-01-22 10:57:35 +01:00
Jan-Philipp Litza
49cb4b3fdb
autoupdater: new implementation
This new version of the autoupdater is implemented in C instead of Lua,
allowing us to interface with libuclient (HTTP downloads) and libecdsautil
(signature checks) directly instead of spawning external processes,
saving RAM and making error handling more robust.

[Matthias Schiffer: add commit message]
2018-01-13 00:22:27 +01:00
Matthias Schiffer
cae8f9c4ce
autoupdater: fix indentation 2017-02-25 18:09:39 +01:00
Matthias Schiffer
6a2d288006
autoupdater: use SHA256 checksums instead of SHA512
We already use SHA256 for the manifest signature, so we'll be able to unify
the implementations after some refactoring.
2017-02-25 01:05:32 +01:00
Matthias Schiffer
ac55ad56b5
autoupdater: convert spaces to tabs 2017-02-24 23:04:05 +01:00
Jan-Philipp Litza
463f872844 autoupdater: add possibility to specify mirrors on commandline (#123) 2017-02-24 11:46:43 +01:00
Matthias Schiffer
485186ace2
autoupdater: handle wget hangs during manifest download
Make sure that the download is cancelled after the timeout even when wget
doesn't produce output at all.
2017-01-24 21:26:20 +01:00
Matthias Schiffer
90380414f1
autoupdater: add timeouts to wget calls
The -T parameter only seems to limit the maximum time between received
packets, but not the overall run time.

This adds simple timeouts to the wget calls (5 minutes for the manifest,
30 minutes for the image). The implementation is very simple, only checking
the manifest timeout each time a line was received, and the image timeout
once a second. A more elegent fix seems like overkill, as the Lua
autoupdater will be replaced with a new implementation after Gluon 2016.2
anyways.
2016-09-08 03:09:30 +02:00
Matthias Schiffer
1acb4b1d3a
autoupdater: add lockfile to prevent concurrent runs 2016-09-08 02:30:20 +02:00
Matthias Schiffer
c24cdae830 pretty-hostname: don't cancel script whey trying to remove nonexistent pretty_hostname 2016-08-27 21:23:24 +02:00
Matthias Schiffer
2cfa9dad0b pretty-hostname: remove quotes from the package title 2016-08-27 17:28:04 +02:00
Matthias Schiffer
be83ca57e4 pretty-hostname: add package to manage a "pretty" hostname 2016-08-27 16:32:15 +02:00
@RubenKelevra
7327bfdde5 autoupdater: remove outdated list of hardware (#145) 2016-08-13 15:39:16 +02:00
Jan-Tarek Butt
6a618e61da
autoupdater: drop caches a second time after download
This is useful to free memory after stopping more services after the
download.

[Matthias Schiffer: improved commit message]
2016-07-19 02:42:18 +02:00
Matthias Schiffer
f375cb7b30
autoupdate: remove potential trailing slash from mirror URL 2016-07-15 02:50:07 +02:00
lemoer
06f2a62b97 autoupdater: add upgrade.d directory. 2016-02-19 17:24:28 +01:00
Matthias Schiffer
b7ce1a2002 autoupdater: add download.d and abort.d directories
All executables in download.d are executed before after the update manifest
has been verified, but before the image is downloaded. This can be used to
stop non-essential services to free RAM.

abort.d is run when the download has failed and should revert the actions
of download.d.
2016-01-11 22:03:55 +01:00
Matthias Schiffer
3d98695abc autoupdater: avoid unnessesary shell processes
Use functions that don't run commands though a shell where easily possible,
add 'exec' to remaining io.popen calls.
2016-01-11 21:53:19 +01:00
Matthias Schiffer
129b1146c3 autoupdater: fix indentation 2016-01-11 17:24:58 +01:00
Jan-Philipp Litza
fc35a19d2a autoupdater: Remove dependencies on luci-base 2015-08-31 21:15:27 +02:00
Matthias Schiffer
fd5e16160a autoupdater: fix usage of Gluon-specific package.mk 2015-07-01 22:09:39 +02:00
Matthias Schiffer
dcc5a5ab74 autoupdater: fixes for the new LuCI version 2015-05-22 02:05:00 +02:00
Erik Tews
ef6b4675d6 autoupdater: Timeout for wget.
Added a 120 second timeout for wget to prevent it from stalling forever.
2015-02-11 01:06:59 +01:00
Matthias Schiffer
1df94acf98 autoupdater: rework command line parsing, allow overriding branch
Unexpected command line arguments will now cause the updater to abort.
2015-01-27 00:33:41 +01:00
Matthias Schiffer
c1068fef42 autoupdater: exit when the image name is not defined for a hardware model 2014-09-09 16:07:35 +02:00
Matthias Schiffer
02bc9f4e66 Dependency fixes for the new LuCi version 2014-08-06 12:06:49 +02:00
Matthias Schiffer
a54d13eb31 autoupdater: rename oneshot updates to fallback, improve handling for frequent runs
The oneshot update now won't be considered until 24h after the priority delay
has passed (so regular updates should have at least one chance to do the updates
even for PRIORITY=0 updates)
2014-07-25 16:54:53 +02:00
Matthias Schiffer
ea3d8703b4 autoupdater: all fallback for situations with no valid time available 2014-07-22 01:55:48 +02:00
Matthias Schiffer
514f46bfe0 autoupdater: add new fields to the sample manifest 2014-07-21 17:35:22 +02:00
Matthias Schiffer
7b9b3058de autoupdater: add -o (oneshot) switch
This switch is used for the fallback mode which ensures that updates are
performed even when a node is off when updates are usually done.
2014-07-21 17:27:47 +02:00
Matthias Schiffer
aae7bf92ed autoupdater: implement new probablity logic 2014-07-21 17:27:47 +02:00
Matthias Schiffer
12fa328bca autoupdater: add a utility function to parse RFC3339 timestamps 2014-07-21 17:27:47 +02:00