This commit is contained in:
parent
78f9939afc
commit
c97f1fc87c
@ -255,6 +255,24 @@ namespace dlackware::timedate
|
|||||||
|
|
||||||
void set_ntp(bool use_ntp, bool)
|
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 rc_mode = std::filesystem::perms::owner_read | std::filesystem::perms::owner_write
|
||||||
| std::filesystem::perms::group_read | std::filesystem::perms::others_read;
|
| std::filesystem::perms::group_read | std::filesystem::perms::others_read;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user