mirror of
https://github.com/webmin/webmin.git
synced 2026-06-25 05:20:29 +01:00
This PR adds a standalone Systemd Services and Units module for managing systemd units across system and user scopes. The module keeps systemd-specific behavior separate from the legacy Bootup and Shutdown module and is implemented as standalone `strict`/`warnings` Perl code rather than depending on its existing init helpers. Those helpers intentionally smooth over multiple init systems, while this module keeps systemd-specific file handling, user-manager behavior, ACL checks, and control operations explicit, scoped, and easier to audit. It includes: - Tabbed views for services, timers, sockets, paths, targets, storage, resources, devices, and user units - Guided creation and editing for common unit types, with contextual fields, validation, and help - User-scoped unit management with linger support and safe handling of home-directory unit files - Runtime actions for start, stop, restart, enable, disable, status, logs, properties, dependencies, and system-unit mask/unmask - Drop-in override inventory plus create, edit, and delete flows - Manual unit-file editing with daemon reload reminders and actions - Configurable module behavior, visible tabs, display options, and post-create navigation - Comprehensive ACL controls for system/user scopes, actions, manual edits, drop-ins, linger, reload, backup, and user filters - Safe Webmin user support through a scoped safe ACL preset - Virtualmin integration for granting domain owners access to their own systemd user units - Tests for unit generation, safety checks, ACL behavior, user-unit handling, backup coverage, and Perl::Critic compatibility A companion Virtualmin PR adds template integration so domain owners can be granted scoped access to their own systemd user units when this module is installed.
35 lines
1.0 KiB
Perl
Executable File
35 lines
1.0 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
# Reload a user's systemd manager after user unit-file changes.
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
require './systemd-lib.pl'; ## no critic
|
|
|
|
our (%access, %in, %text);
|
|
|
|
ReadParse();
|
|
error_setup($text{'reload_user_err'});
|
|
|
|
my $user = clean_unit_value($in{'user'});
|
|
my $uinfo = $user ? get_user_details($user) : undef;
|
|
$uinfo || error($text{'systemd_euser'});
|
|
systemd_can_reload_user(\%access, $uinfo->{'user'}) ||
|
|
systemd_acl_error('pmanual_user');
|
|
|
|
ui_print_unbuffered_header(undef, $text{'reload_user_title'}, "");
|
|
|
|
print text('reload_user_doing',
|
|
ui_tag('tt', html_escape($uinfo->{'user'}))), ui_br(), "\n";
|
|
my ($ok, $out) = reload_user_manager($uinfo->{'user'});
|
|
print ui_tag('pre', html_escape($out)) if ($out);
|
|
print($ok ? $text{'mass_ok'} : $text{'mass_failed'}, ui_p());
|
|
if ($ok) {
|
|
mark_user_daemon_reloaded($uinfo->{'user'});
|
|
webmin_log("reload", "systemd-user", $uinfo->{'user'},
|
|
{ 'user' => $uinfo->{'user'} });
|
|
}
|
|
|
|
ui_print_footer("index.cgi?scope=user&unituser=".urlize($uinfo->{'user'}),
|
|
$text{'index_return'});
|