23873 Commits

Author SHA1 Message Date
Freya Gustavsson 4f8a3ca41b test: Increase timeout for app list
Due to frequent timeouts during testing lets increase the timeout to
make sure it has time to update before the timeout.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-05-05 14:39:55 +02:00
Freya Gustavsson 7b76aa45b3 apps: Support empty lang attribute
When we look for a specific language for an element in AppStream, such
as Summary or Description, we first try to find the requested language
otherwise we fallback to the first element we found.

As the first item might not be the default language in some cases we
could get a format like this

<summary xml:lang="fr">Gestionnaire d'abonnement dans Cockpit</summary>
<summary>Subscription Manager in Cockpit</summary>
<summary xml:lang="it">Gestore abbonamenti nel Cockpit</summary>
<summary xml:lang="ja">Cockpit のサブスクリプションマネージャー</summary>
<summary xml:lang="ka">გამოწერების მმართველი Cockpit-ში</summary>
<summary xml:lang="ko">Cockpit 서브스크립션 관리자</summary>
<summary xml:lang="ru">Менеджер подписок в Cockpit</summary>
<summary xml:lang="zh-Hans-CN">Cockpit 中的订阅管理器</summary>

In this case we'd choose the first summary found which would be French
instead of English.

Instead, we can first look for the language we want, and if we found an
element without language attribute we use that as a fallback. If both
fail we still fallback to the first element found.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-05-05 14:39:55 +02:00
Marius Vollmer 6da6219575 networking/firewall: Track DBus name owner explicitly
So that we don't rely on the name appearing at the same time as the
systemd unit becoming active.  This is no longer the case since
firewalld 2.4.1, see https://github.com/firewalld/firewalld/pull/1528

The tests run into the same issue, and now needs to wait for firewalld
to be officially running before trying to manage it via firewall-cmd.
2026-04-30 10:09:24 +03:00
Marius Vollmer 673120b7d0 cockpit: Fix type of DBusClient.subscribe, it's "arg0" not "arg" 2026-04-30 10:09:24 +03:00
dependabot[bot] b4765b83f1 bump stylelint in the stylelint group across 1 directory
Bumps the stylelint group with 1 update in the / directory: [stylelint](https://github.com/stylelint/stylelint).

Updates `stylelint` from 17.7.0 to 17.9.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
- [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint/stylelint/compare/17.7.0...17.9.0)

---
updated-dependencies:
- dependency-name: stylelint
  dependency-version: 17.8.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: stylelint
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-29 18:05:04 +02:00
Jelle van der Waa f7cc2f6b18 test: bump candlepin container start timeout
In CI starting the container takes a bit longer, so give it 3x more time
to get started.
2026-04-29 15:47:29 +02:00
GitHub Workflow f9f5c75cee po: Update from Fedora Weblate
Closes #23191
2026-04-29 15:06:00 +02:00
dependabot[bot] 1de555388e bump the patternfly group with 2 updates
Bumps the patternfly group with 2 updates: [@patternfly/react-core](https://github.com/patternfly/patternfly-react) and [@patternfly/react-table](https://github.com/patternfly/patternfly-react).

Updates `@patternfly/react-core` from 6.4.1 to 6.4.3
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@6.4.1...@patternfly/react-core@6.4.3)

Updates `@patternfly/react-table` from 6.4.1 to 6.4.3
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@6.4.1...@patternfly/react-table@6.4.3)

---
updated-dependencies:
- dependency-name: "@patternfly/react-core"
  dependency-version: 6.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patternfly
- dependency-name: "@patternfly/react-table"
  dependency-version: 6.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: patternfly
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-29 09:08:04 +02:00
Martin Pitt 160609c29a tls: Distinguish timeout from buffer overflow in recv_all error
The recv_all() function can fail for two different reasons when the
loop at line 145 exits:
- Buffer filled (count >= size) without receiving EOF
- Timeout from wait_for_io()

Print the correct error message.
2026-04-28 13:18:10 +02:00
Martin Pitt 5e08ad61b7 tls: Handle fatal errors in wait_for_io()
As per poll(2), all errors except `EINTR` (which we already retry)
are not runtime errors, but programming errors that ought to be fatal.
The only edge case is maybe `EINVAL`, but if our `n_fds == 1` is already
exceeding RLIMIT_NOFILE, we are in deep trouble anyway, and exiting is
still the right thing to do.

With that, change `wait_for_io()` to return a bool, so that error
handling in the caller becomes simpler and more robust.
2026-04-28 13:18:10 +02:00
Martin Pitt 6aae6ba43f tls: Robustify fd initialization in request_dynamic_wsinstance
This makes it crystal clear that `fd` is never uninitialized.
2026-04-28 13:18:10 +02:00
Martin Pitt 44489dde42 tls: Convert port numbers from network to host byte order
In connection_create_metadata(), the port numbers extracted from
sockaddr_in.sin_port and sockaddr_in6.sin6_port are in network byte
order (big-endian). These values were being used directly without
conversion to host byte order, causing incorrect port numbers to be
logged and reported in the metadata JSON. This didn't break anything as
nothing uses the `origin-port` property right now.

For example, on little-endian systems, port 443 (0x01BB in network
order) would be reported as 47873 (0xBB01 when interpreted as host
order).

Fixed by applying ntohs() to convert the port values to host byte order
before use. This ensures correct port numbers are logged and passed to
cockpit-ws in the metadata.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-28 13:18:10 +02:00
Martin Pitt e4a441f7db tls: Clean up error/redirect response headers
HTTP/1.1 clients expect persistent connections by default. Send an
explicit "Connection: close" for errors and redirects so that browsers
show errors reliably.

Also drop the bogus Content-Type for a redirect.
2026-04-28 13:18:10 +02:00
Martin Pitt 1d0120f568 tls: Add overflow checks to strtol/strtoul calls
Check for overflow when parsing LISTEN_PID and LISTEN_FDS environment
variables, as documented in strtol(3). However, don't explicitly check
for `ULONG_MAX` and friends, as that is both brittle and also slightly
incorrect (as ULONG_MAX may actually be a valid fd). So
explicitly zero errno and then check for any error (which can really
just be ERANGE, unless the string is really broken and specifies a
base).

systemd controls these environment variables, so this isn't practically
relevant, just defense in depth and helping security scanners.
2026-04-28 13:18:10 +02:00
Martin Pitt 2328cc580b tls: Fix connection_count when pthread_create fails
If pthread_create() fails, connection_count was incremented but the
thread was never created. This could cause the idle timeout to never
trigger even when there are no actual connections.

Creating the thread first would introduce a race condition (the thread
could run to completion and decrement it before we increment). Hence,
explicitly revert the increment on failure.
2026-04-28 13:18:10 +02:00
Martin Pitt 073fe3546d tls: Add defense-in-depth CRLF validation to http_redirect()
Add explicit validation that host and path values don't contain CR or
LF characters before using them in the redirect response.

Add an additional defense-in-depth check to ensure header injection
remains impossible. Currently, this validation cannot be triggered
because read_line() already ensures that lines can't contain `\n` and
validates that lines end with either "\r\n" or "\n". Hence we also can't
unit test this.
2026-04-28 13:18:10 +02:00
Martin Pitt aeab81a573 tls: Add header safety unit test
c-tls' httpredirect.c parses HTTP requests with read_line() which
ensures that `\n` cannot appear in the middle, and lines end with
`\r\n`. This should prevent attempts of header injection or HTTP split
responses. Ensure that this is the case.
2026-04-28 13:18:10 +02:00
Martin Pitt 3d99e056e7 tls: Fix poll() EINTR loop in wait_for_io()
`ENOENT` was a typo, `poll()` never returns ENOENT. The intention
clearly was to retry on EINTR.
2026-04-28 13:18:10 +02:00
Marius Vollmer 61514d935d test: Avoid the "su - -c cmd user" pattern
Use the more explicit "-l" option instead of "-".  The latter is being
mishandled by util-linux 2.42 in this pattern.

See https://github.com/util-linux/util-linux/issues/4292
2026-04-27 17:49:50 +03:00
Marius Vollmer 3b4624ff0f bridge, shell: Robust session idle timeouts
Previously, only the Shell would participate in implementing session
idle timeouts.  This means that a session was not guaranteed to time
out when the browser decided to suspend JavaScript execution.

Now the main actor for session idle timeout is the bridge: When
JavaScript starts, it will instruct the bridge to start the session
idle timeout timer.  When it expires, the bridge will exit and end the
session even if JavaScript has been stopped.

While waiting for the timers to elapse, the bridge will send events
out over a new "session-control" channel type that inform the pages
when the final countdown has started, and when it is time to logout.

User activity is also reported over such a channel.
2026-04-24 15:30:02 +03:00
Marius Vollmer 4ca20fa07d test: Don't require a perfect policy in TestSelinux.testTroubleshootAlerts
Previously, we tried to survive unexpected alerts by dismissing those
that existed at the start of the test. But new ones might unexpectedly
appear also while the test is running.

So let's give up on the initial cleanup and make the test robust
against unexpected alerts.  The row-id attribute helps greatly and was
indeed already used in part of the test.
2026-04-24 15:29:27 +03:00
Marius Vollmer b10c044d74 test: Run user metric hogs without SELinux
"systemdrun --usr --machine admin@" can't connect, see
https://bugzilla.redhat.com/show_bug.cgi?id=2461071.
2026-04-24 15:29:27 +03:00
Marius Vollmer 590d6d1e64 beiboot: Declare "Fedora 44" as supported
And remove Fedora 41 since we don't test that anymore.
2026-04-24 15:29:27 +03:00
Marius Vollmer 5c98ca4ae3 test: Adapt to dnf5 backend of PackageKit
- When stalling the download artificially, we never make it to the
  progressbar.

- "Cancel" remains allowed during setup.

- It provides perfect description and bug summaries.
2026-04-24 15:29:27 +03:00
Martin Pitt 2941731a58 common: Add overflow protection to cockpit_base64_size()
Checking this here is slightly out of place, but more robust than adding
assertions to all four callers.
2026-04-24 14:03:23 +02:00
Martin Pitt fa52ede8a0 common: Add overflow assertion to cockpit_hex_encode()
Assert that the memory allocation calculation does not overflow. For
large allocations (which are not practical, but a bug or attack) this
gives a clear and defined error, instead of undefined behaviour.
2026-04-24 14:03:23 +02:00
Marius Vollmer 407a557ded storage: Don't ignore "edit excuse" when constructing key slot rows
We would let the user attempt to edit "Unknown type" slots, which
would crash.

Fixes #23095
2026-04-24 14:23:49 +03:00
Martin Pitt 123c7610c6 Revert "tls: Generate test certificates with traditional RSA key format"
GnuTLS works fine with the modern PKCS#8 format. I just got confused by
test failures as I previously forgot to update the fingerprints in
testing.h previously.

This reverts commit 670d811f94.

Regenerate test certificates with modern PKCS#8 format.
2026-04-24 13:57:26 +03:00
Martin Pitt df95146cac session: Use proper JSON escaping for PAM error messages
The previous code in exit_pam_init_problem() only escaped ' and /. But
PAM modules can return arbitrary messages (including potential
user-defined content), which could contain control characters like
newlines, tabs, or other special characters that would break JSON
encoding.

Re-use cockpit_json_print_string_property() instead, which does escaping
correctly.
2026-04-24 08:42:54 +02:00
Martin Pitt 449a3e8a79 session: Fix EINTR handling in scan_btmp
The EINTR retry loop in scan_btmp was inverted: This caused an infinite
loop on any error except EINTR.
2026-04-24 08:42:54 +02:00
Martin Pitt 29f0ae167d pam-ssh-add: Handle waitid() EINTR
If the call is interrupted by a signal (e.g., SIGCHLD from another
process), that was previously treated as a fatal error.
2026-04-24 08:39:12 +02:00
Martin Pitt 8b015a3bf8 pam-ssh-add: Fix fragile exit status check
pam_ssh_add_load() checked `result.si_code == 1` to distinguish partial
key loading failures from other errors. This is incorrect and fragile.

The `si_code` field in siginfo_t indicates *how* the child process
terminated (e.g., CLD_EXITED for normal exit, CLD_KILLED for signal),
not the exit status. The exit status is in `si_status`.

The value 1 happens to equal CLD_EXITED on Linux, so this worked by
accident. But it's not portable and semantically wrong (comparing a
termination reason to a magic number).

The intent is to check if ssh-add exited with status 1, which indicates
partial failure (some keys failed to load).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-04-24 08:39:12 +02:00
Martin Pitt c291ed011d pam-ssh-add: Remove duplicate stdio macro definitions 2026-04-24 08:39:12 +02:00
Martin Pitt 6fc10bafa4 pam-ssh-add: Fix strtoul error handling for SSH_AGENT_PID
Follow the strtoul(3) manpage pattern for proper error detection.

Without proper error checks, invalid PID strings could be partially
parsed or overflow could go undetected, potentially storing an incorrect
PID value that could later be used to kill the wrong process.
2026-04-24 08:39:12 +02:00
Freya Gustavsson b37097f941 test: Add misc.print to mypy parsing
Adds `print.py` to mypy config and fixes an unused ignore.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-04-23 13:10:05 +02:00
Freya Gustavsson 27397bae8d src: Add compact JSON to Printer
By default the printer now outputs compact JSON which is more aligned
with what is expected of Cockpit. When using `control` it will now print
it compact by default.

This can be changed by using `--pretty-json` argument.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-04-23 13:10:05 +02:00
Jelle van der Waa a96916297a lib: convert cockpit-components-modifications to TypeScript
Assisted-by: Claude Opus 4.6
2026-04-23 11:18:20 +02:00
Jelle van der Waa 5951c9c3b4 overview-cards: port ProfilesMenuDialogBody to TypeScript
Assisted-by: Claude Opus 4.6
2026-04-23 11:18:20 +02:00
Jelle van der Waa 0eaec25ffc packagekit: port PropTypes components to TypeScript
Assisted-by: Claude Opus 4.6
2026-04-23 11:18:20 +02:00
Jelle van der Waa 93555bf3c8 packagekit: coerce justCurrent to a boolean
`isChecked` accepts `undefined | boolean` not `null | boolean`, but in
our Cockpit code we commonly use `null` as the initial state.
2026-04-23 11:18:20 +02:00
Jelle van der Waa b9109f22e8 packagekit: add missing name property for radio's
This property is required.
2026-04-23 11:18:20 +02:00
Jelle van der Waa 9a706af793 lib: Port cockpit-components-privileged to TypeScript
The only major change is that `exactOptionalPropertyTypes` is enabled in
our TypeScript configuration disallowing us to pass optional properties
as undefined.

Assisted-by: Claude Opus 4.6
2026-04-23 11:18:20 +02:00
Martin Pitt bd0b6910e7 debian: Bump Standards-Version to 4.7.4
No changes necessary as per
https://www.debian.org/doc/debian-policy/upgrading-checklist.html#version-4-7-4
2026-04-23 10:31:38 +02:00
Luca Boccassi 6dbb80d090 debian: Drop static user cleanup
The cockpit-wsinstance static user was replaced with DynamicUser in
version 330. Cleaning up the obsolete user on upgrade is no longer
necessary, as Debian stable already ships version 337. Drop both the
workaround and the adduser dependency.
2026-04-23 10:31:38 +02:00
Marius Vollmer e74fdfe0b0 users: Don't rely on chage to recognize "99999" max days as "never".
It has stopped doing that in Fedora 44 and elsewhere.

The documented value for "never" is -1, and we recognize this now as
well.  We also use "passwd -x -1" when setting password expiry to
"never".
2026-04-23 10:29:02 +02:00
Freya Gustavsson fd980a6b48 packit: Use empty string for fix-spec-file
We had another failure with Packit release infra where Packit workflow
failed due to type incorrectly being `None` where it needs to be either
string or list.

Checking with Packit team again and they apologized and proposed we just
use empty string. This took place in ther Matrix.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-04-23 10:04:38 +02:00
tomasmatus f6024a7d3c insights: do not use insights-detail.json
Same as https://github.com/cockpit-project/subscription-manager-cockpit/pull/104
on subscription-manager-cockpit. This file is no longer generated by
insights-client.

With this the overview card only shows subscribed/unsubscribed status
and links to the subscriptions page.
2026-04-22 16:07:17 +02:00
Martin Pitt 5a1cb2d59c tls: Make rm safer
Not really practically relevant, but fixes shellcheck failure

> SC2035 (info): Use ./*glob* or -- *glob* so names with dashes won't become options.
2026-04-22 14:02:59 +02:00
Martin Pitt fbc8363eca tls: Regenerate test certificates
These were done with setting the clock back to "yesterday", so that
alice-expired.pem is actually expired.
2026-04-22 14:02:59 +02:00
Martin Pitt 670d811f94 tls: Generate test certificates with traditional RSA key format
OpenSSL 3.x changed the default private key format from traditional RSA
(BEGIN RSA PRIVATE KEY) to PKCS#8 (BEGIN PRIVATE KEY). The GnuTLS-based
tests fail with PKCS#8 format keys, producing
GNUTLS_E_PREMATURE_TERMINATION errors during TLS handshake.

Use the -traditional flag with openssl genrsa to generate keys in the
legacy RSA format that GnuTLS can handle properly.

This wasn't yet the case in 2020 when we refreshed the certificates the
last time.
2026-04-22 14:02:59 +02:00