1 From 6f172007452b39bfda5062fc29ea5382671ac16e Mon Sep 17 00:00:00 2001
2 From: Alexander Ried <ried@mytum.de>
3 Date: Thu, 26 May 2016 19:54:21 +0200
4 Subject: [PATCH] Disable methods that change files in /etc
6 Only if environment variable NIXOS_USERS_PURE is set.
8 src/daemon.c | 10 ++++++++++
9 src/user.c | 35 +++++++++++++++++++++++++++++++++++
10 2 files changed, 45 insertions(+)
12 diff --git a/src/daemon.c b/src/daemon.c
13 index 861430f..aefaf2d 100644
16 @@ -1378,6 +1378,11 @@ daemon_create_user (AccountsAccounts *accounts,
17 const gchar *real_name,
20 + if (getenv("NIXOS_USERS_PURE")) {
21 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
25 Daemon *daemon = (Daemon *) accounts;
28 @@ -1581,6 +1586,11 @@ daemon_delete_user (AccountsAccounts *accounts,
30 gboolean remove_files)
32 + if (getenv("NIXOS_USERS_PURE")) {
33 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
37 Daemon *daemon = (Daemon *) accounts;
40 diff --git a/src/user.c b/src/user.c
41 index 28170db..df947a1 100644
44 @@ -1216,6 +1216,11 @@ user_set_real_name (AccountsUser *auser,
45 GDBusMethodInvocation *context,
46 const gchar *real_name)
48 + if (getenv("NIXOS_USERS_PURE")) {
49 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
53 User *user = (User *) auser;
55 const gchar *action_id;
56 @@ -1293,6 +1298,11 @@ user_set_user_name (AccountsUser *auser,
57 GDBusMethodInvocation *context,
58 const gchar *user_name)
60 + if (getenv("NIXOS_USERS_PURE")) {
61 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
65 User *user = (User *) auser;
67 daemon_local_check_auth (user->daemon,
68 @@ -1945,6 +1955,11 @@ user_set_home_directory (AccountsUser *auser,
69 GDBusMethodInvocation *context,
70 const gchar *home_dir)
72 + if (getenv("NIXOS_USERS_PURE")) {
73 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
77 User *user = (User *) auser;
79 daemon_local_check_auth (user->daemon,
80 @@ -2000,6 +2015,11 @@ user_set_shell (AccountsUser *auser,
81 GDBusMethodInvocation *context,
84 + if (getenv("NIXOS_USERS_PURE")) {
85 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
89 User *user = (User *) auser;
91 daemon_local_check_auth (user->daemon,
92 @@ -2249,6 +2269,11 @@ user_set_locked (AccountsUser *auser,
93 GDBusMethodInvocation *context,
96 + if (getenv("NIXOS_USERS_PURE")) {
97 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
101 User *user = (User *) auser;
103 daemon_local_check_auth (user->daemon,
104 @@ -2457,6 +2482,11 @@ user_set_password_mode (AccountsUser *auser,
105 GDBusMethodInvocation *context,
108 + if (getenv("NIXOS_USERS_PURE")) {
109 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
113 User *user = (User *) auser;
114 const gchar *action_id;
116 @@ -2550,6 +2580,11 @@ user_set_password (AccountsUser *auser,
117 const gchar *password,
120 + if (getenv("NIXOS_USERS_PURE")) {
121 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
125 User *user = (User *) auser;
127 const gchar *action_id;