mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 15:13:46 +00:00
119 lines
4.6 KiB
Diff
119 lines
4.6 KiB
Diff
|
From cec1430f72edfedb951fe34e87765ef422ea9843 Mon Sep 17 00:00:00 2001
|
||
|
From: Gabriel Ebner <gebner@gebner.org>
|
||
|
Date: Sun, 6 Dec 2015 14:26:36 +0100
|
||
|
Subject: [PATCH 10/27] hostnamed, localed, timedated: disable methods that
|
||
|
change system settings.
|
||
|
|
||
|
---
|
||
|
src/hostname/hostnamed.c | 9 +++++++++
|
||
|
src/locale/localed.c | 9 +++++++++
|
||
|
src/timedate/timedated.c | 10 ++++++++++
|
||
|
3 files changed, 28 insertions(+)
|
||
|
|
||
|
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
|
||
|
index 9e4f4fb59e..141b8acc08 100644
|
||
|
--- a/src/hostname/hostnamed.c
|
||
|
+++ b/src/hostname/hostnamed.c
|
||
|
@@ -423,6 +423,9 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
|
||
|
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 (isempty(name))
|
||
|
name = c->data[PROP_STATIC_HOSTNAME];
|
||
|
|
||
|
@@ -479,6 +482,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
|
||
|
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);
|
||
|
|
||
|
if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME]))
|
||
|
@@ -536,6 +542,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
|
||
|
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);
|
||
|
|
||
|
if (streq_ptr(name, c->data[prop]))
|
||
|
diff --git a/src/locale/localed.c b/src/locale/localed.c
|
||
|
index 8d0eec96a5..0b1c1d664e 100644
|
||
|
--- a/src/locale/localed.c
|
||
|
+++ b/src/locale/localed.c
|
||
|
@@ -276,6 +276,9 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
|
||
|
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=. */
|
||
|
if (strv_length(l) == 1 && !strchr(*l, '=')) {
|
||
|
if (!locale_is_valid(*l))
|
||
|
@@ -411,6 +414,9 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro
|
||
|
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);
|
||
|
|
||
|
@@ -587,6 +593,9 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err
|
||
|
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
|
||
|
index 6c94b23de4..fa20d22cde 100644
|
||
|
--- a/src/timedate/timedated.c
|
||
|
+++ b/src/timedate/timedated.c
|
||
|
@@ -653,6 +653,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
|
||
|
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);
|
||
|
|
||
|
@@ -732,6 +736,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error
|
||
|
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);
|
||
|
|
||
|
@@ -924,6 +931,9 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error
|
||
|
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;
|
||
|
--
|
||
|
2.24.1
|
||
|
|