2020-11-01 14:35:11 +00:00
|
|
|
From a1454e8edb7a1a87093808dc7db540232147df3d Mon Sep 17 00:00:00 2001
|
2020-01-26 13:56:41 +00:00
|
|
|
From: Gabriel Ebner <gebner@gebner.org>
|
|
|
|
Date: Sun, 6 Dec 2015 14:26:36 +0100
|
2020-04-30 00:03:18 +01:00
|
|
|
Subject: [PATCH 07/18] hostnamed, localed, timedated: disable methods that
|
2020-01-26 13:56:41 +00:00
|
|
|
change system settings.
|
|
|
|
|
|
|
|
---
|
2020-07-31 17:02:33 +01:00
|
|
|
src/hostname/hostnamed.c | 6 ++++++
|
2020-01-26 13:56:41 +00:00
|
|
|
src/locale/localed.c | 9 +++++++++
|
|
|
|
src/timedate/timedated.c | 10 ++++++++++
|
2020-07-31 17:02:33 +01:00
|
|
|
3 files changed, 25 insertions(+)
|
2020-01-26 13:56:41 +00:00
|
|
|
|
|
|
|
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
|
2020-11-01 14:35:11 +00:00
|
|
|
index a1794bdab1..77134731e1 100644
|
2020-01-26 13:56:41 +00:00
|
|
|
--- a/src/hostname/hostnamed.c
|
|
|
|
+++ b/src/hostname/hostnamed.c
|
2020-11-01 14:35:11 +00:00
|
|
|
@@ -643,6 +643,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
name = empty_to_null(name);
|
|
|
|
|
2020-07-31 17:02:33 +01:00
|
|
|
context_read_etc_hostname(c);
|
2020-11-01 14:35:11 +00:00
|
|
|
@@ -702,6 +705,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
name = empty_to_null(name);
|
|
|
|
|
2020-07-31 17:02:33 +01:00
|
|
|
context_read_machine_info(c);
|
2020-01-26 13:56:41 +00:00
|
|
|
diff --git a/src/locale/localed.c b/src/locale/localed.c
|
2020-11-01 14:35:11 +00:00
|
|
|
index 736dacdee9..53e0ee935e 100644
|
2020-01-26 13:56:41 +00:00
|
|
|
--- a/src/locale/localed.c
|
|
|
|
+++ b/src/locale/localed.c
|
2020-07-31 17:02:33 +01:00
|
|
|
@@ -317,6 +317,9 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
/* If single locale without variable name is provided, then we assume it is LANG=. */
|
2020-07-31 17:02:33 +01:00
|
|
|
if (strv_length(l) == 1 && !strchr(l[0], '=')) {
|
|
|
|
if (!locale_is_valid(l[0]))
|
|
|
|
@@ -432,6 +435,9 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
keymap = empty_to_null(keymap);
|
|
|
|
keymap_toggle = empty_to_null(keymap_toggle);
|
|
|
|
|
2020-07-31 17:02:33 +01:00
|
|
|
@@ -606,6 +612,9 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
layout = empty_to_null(layout);
|
|
|
|
model = empty_to_null(model);
|
|
|
|
variant = empty_to_null(variant);
|
|
|
|
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
|
2020-11-01 14:35:11 +00:00
|
|
|
index 8bfcfd5cdc..a0ee03f134 100644
|
2020-01-26 13:56:41 +00:00
|
|
|
--- a/src/timedate/timedated.c
|
|
|
|
+++ b/src/timedate/timedated.c
|
2020-07-31 17:02:33 +01:00
|
|
|
@@ -646,6 +646,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ if (getenv("NIXOS_STATIC_TIMEZONE"))
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing timezone via systemd is not supported when it is set in NixOS configuration.");
|
|
|
|
+
|
|
|
|
if (!timezone_is_valid(z, LOG_DEBUG))
|
|
|
|
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid or not installed time zone '%s'", z);
|
|
|
|
|
2020-07-31 17:02:33 +01:00
|
|
|
@@ -725,6 +729,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
if (lrtc == c->local_rtc)
|
|
|
|
return sd_bus_reply_method_return(m, NULL);
|
|
|
|
|
2020-11-01 14:35:11 +00:00
|
|
|
@@ -905,6 +912,9 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error
|
2020-01-26 13:56:41 +00:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED,
|
|
|
|
+ "Changing system settings via systemd is not supported on NixOS.");
|
|
|
|
+
|
|
|
|
r = context_update_ntp_status(c, bus, m);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
--
|
2020-11-01 14:35:11 +00:00
|
|
|
2.29.2
|
2020-01-26 13:56:41 +00:00
|
|
|
|