Support s6-rc for service control
All checks were successful
Build / build (push) Successful in 16s

This commit is contained in:
Eugen Wissner 2024-07-05 19:46:32 +02:00
parent 78f9939afc
commit c97f1fc87c
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0

View File

@ -255,6 +255,24 @@ namespace dlackware::timedate
void set_ntp(bool use_ntp, bool)
{
try
{
std::string service_state = use_ntp ? "-u" : "-d";
const auto command_flags = Glib::SpawnFlags::SPAWN_SEARCH_PATH
| Glib::SpawnFlags::SPAWN_STDERR_TO_DEV_NULL | Glib::SpawnFlags::SPAWN_STDERR_TO_DEV_NULL;
int wait_status{-1};
Glib::spawn_sync("", std::vector<std::string>{ "s6-rc", service_state, "change", "ntpd" },
command_flags, {}, nullptr, nullptr, &wait_status);
if (wait_status == 0 || wait_status == 0x300) // Unknown service name in the arguments.
{
return;
}
}
catch (const Glib::SpawnError& spawn_error)
{
}
std::filesystem::perms rc_mode = std::filesystem::perms::owner_read | std::filesystem::perms::owner_write
| std::filesystem::perms::group_read | std::filesystem::perms::others_read;