Commit Graph

139 Commits

Author SHA1 Message Date
Ilia Ross
04b47e5815 Add API-only access for Webmin accounts
This PR adds an `api_only` global permission that restricts a Webmin account to one supported API endpoint, such as virtual-server/remote.cgi.

External integrations need credentials that can call an API without also granting access to the Webmin interface or generic RPC. Existing module permissions do not provide this endpoint-level restriction. The new setting allows administrators to create dedicated integration accounts while Webmin continues performing authorized operations through its privileged backend.

The restriction is enforced in two places:
- MiniServ checks the authenticated account's policy before dispatching CGI, static-file, DAV, or WebSocket requests. Requests outside the configured endpoint receive HTTP 403.
- `init_config` requires the permitted CGI to explicitly opt in before initialization. This also protects Webmin-initializing CGIs hosted by another web server.

Generic RPC is denied for API-only accounts, even when an existing RPC permission would otherwise allow it. The endpoint's own module and operation permissions still apply. Selecting an endpoint does not grant permission to execute every API command.

Webmin Users gains an API-only setting for users and groups. Existing restrictions survive ordinary edits, resets, copies, cloning, renaming, group propagation, and cluster synchronization. Clearing a restriction requires an explicit permission edit. Group updates preserve restrictions already assigned to individual members.

MiniServ reads the policy on each request from the account's existing storage backend: local files, MySQL, PostgreSQL, or LDAP. Policy-read errors deny access instead of treating the account as unrestricted.

Validation passed with the four separately submitted supporting fixes (#2897, #2898, #2899, #2900) ,applied: 169 focused tests, syntax checks, and live Debian tests using file-backed and PostgreSQL accounts. Live checks covered account creation, lifecycle operations, both CGI modes, sessions, RPC, static files, DAV, and WebSockets.

The supporting fixes remain separate PRs. This API-only branch currently has seven lifecycle test failures that depend on the file-cache and group ACL cleanup fixes landing.
2026-10-23 22:06:12 +02:00
Ilia Ross
1cade5b59e Fix dropdown menu positioning
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
2026-10-23 05:37:52 +02:00
Ilia Ross
17a393a589 Fix MySQL import fallback for loopback and tunneled servers 2026-10-23 01:30:47 +02:00
Ilia Ross
c12fb7d438 Fix MySQL data imports with private temporary directories
This patch fixes CSV imports on systems such as AlmaLinux where MariaDB's `PrivateTmp` setting hides Webmin's temporary files.

The earlier permissions fix could not solve this because the database service still could not see the file.

Imports now use a unique directory under `secure_file_priv`, or the database's data directory, while retaining restricted file permissions and automatic cleanup.

The directory uses the `#sql-` prefix so MariaDB does not treat it as a database during listings, backups, or checks.

Verified live on Debian 13, AlmaLinux 10, Ubuntu 26.04 MariaDB and MySQL 8.4, including database listings and full dumps taken while an import is in progress.
2026-10-23 00:47:32 +02:00
Ilia Ross
3ccad807df Fix SMTP plaintext fallback after STARTTLS failure
This patch fixes mail sending and SMTP monitoring silently continuing without encryption when STARTTLS is rejected.

That fallback could expose passwords and email contents despite encryption being selected.

Both paths now require a valid STARTTLS success response and stop on failure, while successful TLS and explicitly configured plaintext connections remain supported.
2026-10-22 22:51:22 +02:00
Ilia Ross
3441040461 Fix mailbox attachment XSS bypasses 2026-10-22 22:23:23 +02:00
Ilia Ross
0cc60f0f4b Fix unsafe commands in existing Webalizer schedules 2026-10-22 21:47:59 +02:00
Ilia Ross
baad8643ae Fix log path HTML injection in Webalizer 2026-10-22 21:32:31 +02:00
Ilia Ross
1c2cff183e Fix username XSS in Fetchmail pages 2026-10-22 21:22:52 +02:00
Ilia Ross
130987be89 Fix MySQL server-side import of temporary files
This patch fixes MySQL imports that fail because the database server cannot read the temporary file.

Since the temporary copy is created with mode 0600, a server-side `mysqlimport` fails for imports from a local file, and for uploads by users with a Unix user restriction.

Before running the import as root against a local server, the file is now given the group of the running server process with mode 0640, so the server can read it while other users still cannot. The process is found through the server's reported PID file and must be `mysqld` or `mariadbd`; otherwise the permissions are left unchanged.
2026-10-22 21:05:39 +02:00
Ilia Ross
f6544c2700 Fix editing MySQL views with special-character names 2026-10-22 19:43:39 +02:00
Ilia Ross
9bad05a55d Fix XSS across MySQL database pages 2026-10-22 19:31:58 +02:00
Ilia Ross
400c326a1b Fix XSS in printer test forms and job lists 2026-10-22 18:30:42 +02:00
Ilia Ross
4bf0c7d652 Fix mail queue attachment XSS (more) 2026-10-22 17:35:27 +02:00
Jamie Cameron
d59f5326a1 Merge pull request #2886 from webmin/dev/fix-rpc-deserialization
Fix RPC deserialization
2026-10-21 20:35:07 -07:00
Ilia Ross
dbb360b127 Add Data::Dumper parser module 2026-10-22 01:45:44 +02:00
Ilia Ross
f59a235d17 Fix stale bytes in input reads
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
This patch fixes leaving old bytes in the input buffer when a later read is shorter.

Those extra bytes can corrupt ordinary HTTP RPC requests. Fast RPC is unaffected (discovered in deep tests with Virtualmin WP Workbench).

The reader now matches Perl's native read behavior, with regression tests for buffered and socket reads, offsets, and zero-length reads.
2026-10-20 03:10:24 +02:00
Ilia Ross
91d3dd843b Fix unsafe fast RPC deserialization without dropping Data::Dumper support
https://github.com/webmin/webmin/pull/2886#issuecomment-6207458026
2026-10-19 01:49:05 +02:00
Ilia Ross
7ebf5c474c Fix UI library theme styling
This patch fixes UI library buttons, badges, dropdowns, alerts, and other stateful elements to follow the active theme consistently.

It maps action states and sizes to native theme button classes while retaining safe CSS fallbacks.
2026-10-17 23:21:06 +02:00
Jamie Cameron
6a67d6f4be Merge pull request #2893 from webmin/dev/fix-rpm-package-install
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
Fix RPM package install completion
2026-10-16 20:41:17 -07:00
Ilia Ross
57cb547ead Add section title, segmented control and stacked field widgets to the UI library 2026-10-17 02:17:20 +02:00
Ilia Ross
2568bc5f07 Fix mixed DNF package installation
This patch fixes package installation when a request contains both installed and missing packages.

DNF 4 uses one `install` transaction, while DNF 5 updates installed packages first and installs missing packages only after the update succeeds.

It preserves architecture package handling, always installs required repository packages, and prevents an empty package list from becoming a full system update.

The complete transaction reads from `/dev/null`, and tests cover DNF 4, DNF 5, installed, missing, mixed, and empty package sets.

Live AlmaLinux testing also confirmed both the single-command and chained-command paths.
2026-10-17 02:03:27 +02:00
Ilia Ross
fb70225187 Fix RPM package install completion
This PR fixes package installation pages stopping after "Re-fetching available packages .." on RPM systems, before the System Status refresh, reboot check, and return link appeared.

The regression was introduced by https://github.com/webmin/webmin/commit/658f930, which wrapped RPM queries in `clean_environment` while the Package Updates installer had already cleaned the environment.

The inner clean overwrote the only saved environment, leaving `WEBMIN_CONFIG` unset and causing the System Status library to fail after the page headers had been sent.

Nested `clean_environment` calls now save separate snapshots, allowing each `reset_environment` call to restore the matching environment exactly while preserving Virtualmin's API script runner behavior.
2026-10-17 01:27:12 +02:00
Ilia Ross
7f4a2cf5cd Fix SSL certificate checks for regular RPC
This PR fixes SSL certificate verification for regular `/rpc.cgi` connections.

It reuses the existing certificate requirements already passed to Fast RPC, so both transports honor `checkssl`.

<!-- ANT-2026-1G97HEC6: Reported by Adam via email on October 11, 2026 at 12:08. -->
2026-10-16 05:25:50 +02:00
Ilia Ross
5231d6de0f Drop certificate checks from RPC deserialization fix 2026-10-16 05:16:40 +02:00
Jamie Cameron
98f10775a0 Merge pull request #2890 from webmin/dev/fix-mysql-backup-privilege-boundaries
Fix MySQL backup privilege boundary bypasses
2026-10-15 20:01:00 -07:00
Ilia Ross
31e251ce1c Fix chip expectations in the UI library widget tests 2026-10-16 04:34:28 +02:00
Ilia Ross
0843de05cb Fix MySQL backup privilege boundary bypasses
This PR fixes privilege boundary bypasses in MySQL database backups.

It restricts custom dump parameters and shared backup settings to users with unrestricted root backup access.

It also prevents database names, table names, and compatibility values from being interpreted as dump options.

The changes include focused tests and passed live regression testing with MySQL and MariaDB.
2026-10-16 03:08:07 +02:00
Ilia Ross
ffa551a24b Fix RPC deserialization and certificate checks
This PR fixes unsafe RPC deserialization by dropping `Data::Dumper` from fast RPC, rejecting `$VAR1` input, and keeping remote objects as plain data.

Original report by Adam emailed October 11, 2026 at 05:34.
2026-10-15 15:02:39 +02:00
Jamie Cameron
692cb6ea70 Merge pull request #2876 from webmin/dev/fix-symlink-loops
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
Close inactive / close-inactive (push) Has been cancelled
Fix symlink resolution loops
2026-10-13 20:51:55 -07:00
Ilia Ross
b5ce991eb3 Fix non-root MySQL backup hooks
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
This patch addresses non-root MySQL backup hooks remaining unreachable after original patch https://github.com/webmin/webmin/commit/6873c65.

Now it makes before and after commands available when backups run as a configured non-root Unix user.

Root hook execution remains limited to cron-eligible Webmin users, and Usermin remains excluded from backup hooks.
2026-10-13 16:40:45 +02:00
Ilia Ross
3d22baaeea Fix sandboxed MySQL and Virtualmin restores
This patch fixes a horrible regression introduced by the original sandbox patch 166cfefa28.

MariaDB sandbox mode blocks the `source` command used by Webmin and Virtualmin restores, breaking all restores.

SQL files are now passed directly to the client while preserving binary-log suppression and compatibility with older clients.
2026-10-13 13:51:44 +02:00
Ilia Ross
222a2fd31b Fix convert to JSON to support canonical flag for independent key sorting 2026-10-13 05:26:42 +02:00
Ilia Ross
759359db48 Add drop-down menu, dialog, breadcrumb and pager widgets to UI lib 2026-10-11 17:52:04 +02:00
Ilia Ross
e99841ebc6 Fix directory symlink handling in temporary file helpers 2026-10-10 21:33:46 +02:00
Ilia Ross
22c31d206f Fix symlink loops when opening temporary files
This change fixes infinite loops in `open_tempfile()` and `open_lock_tempfile()` when opening cyclic symlinks.
2026-10-10 17:45:52 +02:00
Ilia Ross
f7f2fcbdb8 Fix growing symlink loops
This change fixes memory exhaustion from symlinks such as link -> link/child.
2026-10-10 17:42:51 +02:00
Ilia Ross
34040bd0df Fix false symlink loop detection
This patch fixes valid symlink paths being mistaken for loops by [c51f0ed4](https://github.com/webmin/webmin/commit/c51f0ed4).

It simplifies only the checked path prefix, preserving the unresolved remainder.

Original loop cases still stop quickly, while long valid chains remain supported.

I reproduced incorrect PHP selection in Virtualmin and WP Workbench, and GoAccess choosing its root log-creation branch instead of the domain-user helper.
2026-10-10 16:51:51 +02:00
Ilia Ross
8f9663fd9c Add stat tile shapes and consistent spacing 2026-10-09 04:27:59 +02:00
Ilia Ross
5e90e1438a Fix module name validation (once again)
This patch fixes `get_module_info()` accepting module names with a trailing newline after the regex anchors were changed.

It preserves the strict validation introduced in my `2f4f017ac` to prevent loading files outside installed modules.

The check directly rejects undefined or empty names and any character outside ASCII letters, digits, underscores, and hyphens, including newlines anywhere in the name.

Regression tests pass and verify that invalid names are rejected before module lookup while valid names remain accepted.
2026-10-08 22:40:36 +02:00
Ilia Ross
e327940bd6 Add action buttons with badge styling 2026-10-08 05:37:20 +02:00
Ilia Ross
18d5344043 Fix empty action log details
This patch fixes blank sections in action details when multiple actions are logged in one process.
2026-10-08 04:53:32 +02:00
Ilia Ross
77ffa83f8f Fix MariaDB listings with stray directories
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
ⓘ Skip invalid `#mysql50#.` entries in SQL and mysqlshow database listings so stray directories don't break the MariaDB page. Preserve valid dot-prefixed, hash-prefixed, and legacy database names.

Reproduce by creating an ordinary `.config` directory in MariaDB's data directory and opening the Webmin MariaDB module. On AlmaLinux, starting `user@27.service` also reproduces the issue because the globally enabled Podman user restart service creates `.config` and `.local` in the mysql account's home. Podman is one possible source, and the failure doesn't depend on it.

Fixes https://forum.virtualmin.com/t/error-accessing-mariadb-server-through-webmin/138118
2026-10-07 16:30:56 +02:00
Ilia Ross
0be0ba411a Fix restart signal race
This PR fixes Webmin being killed when package updates trigger overlapping restarts.

I found this while upgrading packages on a Debian 13 Pro, with the upgrade finished, but Webmin stopped responding, and tracing showed a second `SIGHUP` killing it during startup.

The fix keeps restart and reload signals pending across `exec()` and installs their handlers early in startup.
2026-10-06 03:56:47 +02:00
Ilia Ross
61d3618cc5 Fix external IP checks to use requested address family #1300 2026-10-04 22:06:49 +02:00
Jamie Cameron
ff83f05768 Merge pull request #2861 from webmin/dev/fix-websocket-transfers
Fix stalled WebSocket transfers
2026-09-30 19:55:09 -07:00
Ilia Ross
1bfd92c21c Add full OS version detection
This PR adds `real_os_version_full` so the dashboard can show Debian point releases such as 12.15.

It preserves existing version comparisons and updates the field through installation, OS refreshes, and manual settings.

Older detection caches are refreshed automatically.

Fixes: https://forum.virtualmin.com/t/os-detection-version-with-point-release-on-dashboard/138091
2026-09-30 23:40:01 +02:00
Ilia Ross
ea691b895e Fix stalled WebSocket transfers
This PR fixes WebSocket transfers that stall when unread data remains buffered.

Miniserv now drains buffered browser data before waiting for more network traffic.

The receive library avoids extra blocking reads and handles temporary read errors without disconnecting.

Tested and verified over HTTPS with Terminal and live stats on Rocky 10 and Ubuntu 26.04.

I discovered these issues while working on and testing new Cloudmin's SSH-based guest File Manager integration, which I decided to drop for now.
2026-09-30 22:46:47 +02:00
Ilia Ross
c8a6a0f69a Add label_html row option to ui_dl
Some checks failed
Tests / prove (push) Has been cancelled
Package and upload artifacts / build (push) Has been cancelled
2026-09-30 16:53:05 +02:00
Ilia Ross
6b7832acd0 Fix stale miniserv configuration reads
This PR fixes WebSocket routes being lost when miniserv configuration changes multiple times within one second.

Read `miniserv.conf` directly so locked updates use the current configuration.

The previous cache could reuse stale data because it compared modification times in whole seconds.

Add a regression test covering route additions and removals with an unchanged modification time.
2026-09-30 01:36:26 +02:00