Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 105 lines 4.4 kB view raw
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 2From: Gabriel Ebner <gebner@gebner.org> 3Date: Sun, 6 Dec 2015 14:26:36 +0100 4Subject: [PATCH] hostnamed, localed, timedated: disable methods that change 5 system settings. 6 7--- 8 src/hostname/hostnamed.c | 6 ++++++ 9 src/locale/localed.c | 9 +++++++++ 10 src/timedate/timedated.c | 10 ++++++++++ 11 3 files changed, 25 insertions(+) 12 13diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c 14index ba50b59f92..9827487453 100644 15--- a/src/hostname/hostnamed.c 16+++ b/src/hostname/hostnamed.c 17@@ -1115,6 +1115,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_ 18 if (r < 0) 19 return r; 20 21+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 22+ "Changing system settings via systemd is not supported on NixOS."); 23+ 24 name = empty_to_null(name); 25 26 context_read_etc_hostname(c); 27@@ -1177,6 +1180,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess 28 if (r < 0) 29 return r; 30 31+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 32+ "Changing system settings via systemd is not supported on NixOS."); 33+ 34 name = empty_to_null(name); 35 36 context_read_machine_info(c); 37diff --git a/src/locale/localed.c b/src/locale/localed.c 38index 062744519d..95bde4b1c3 100644 39--- a/src/locale/localed.c 40+++ b/src/locale/localed.c 41@@ -226,6 +226,9 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er 42 43 use_localegen = locale_gen_check_available(); 44 45+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 46+ "Changing system settings via systemd is not supported on NixOS."); 47+ 48 /* If single locale without variable name is provided, then we assume it is LANG=. */ 49 if (strv_length(l) == 1 && !strchr(l[0], '=')) { 50 if (!locale_is_valid(l[0])) 51@@ -343,6 +346,9 @@ static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_erro 52 if (r < 0) 53 return bus_log_parse_error(r); 54 55+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 56+ "Changing system settings via systemd is not supported on NixOS."); 57+ 58 vc_context_empty_to_null(&in); 59 60 r = vc_context_verify_and_warn(&in, LOG_ERR, error); 61@@ -460,6 +466,9 @@ static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_err 62 if (r < 0) 63 return bus_log_parse_error(r); 64 65+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 66+ "Changing system settings via systemd is not supported on NixOS."); 67+ 68 x11_context_empty_to_null(&in); 69 70 r = x11_context_verify_and_warn(&in, LOG_ERR, error); 71diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c 72index c79bb864df..cbd30214b7 100644 73--- a/src/timedate/timedated.c 74+++ b/src/timedate/timedated.c 75@@ -676,6 +676,10 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error * 76 if (r < 0) 77 return r; 78 79+ if (getenv("NIXOS_STATIC_TIMEZONE")) 80+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 81+ "Changing timezone via systemd is not supported when it is set in NixOS configuration."); 82+ 83 if (!timezone_is_valid(z, LOG_DEBUG)) 84 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid or not installed time zone '%s'", z); 85 86@@ -754,6 +758,9 @@ static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error 87 if (r < 0) 88 return r; 89 90+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 91+ "Changing system settings via systemd is not supported on NixOS."); 92+ 93 if (lrtc == c->local_rtc && !fix_system) 94 return sd_bus_reply_method_return(m, NULL); 95 96@@ -948,6 +955,9 @@ static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error 97 if (r < 0) 98 return r; 99 100+ return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, 101+ "Changing system settings via systemd is not supported on NixOS."); 102+ 103 r = context_update_ntp_status(c, bus, m); 104 if (r < 0) 105 return r;