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 e62e124..87459b2 100644
16 @@ -931,6 +931,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 @@ -1138,6 +1143,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 0fb1a17..dbdebaf 100644
44 @@ -904,6 +904,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 @@ -981,6 +986,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;
66 daemon_local_check_auth (user->daemon,
68 @@ -1263,6 +1273,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;
78 daemon_local_check_auth (user->daemon,
80 @@ -1322,6 +1337,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;
90 daemon_local_check_auth (user->daemon,
92 @@ -1602,6 +1622,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;
102 daemon_local_check_auth (user->daemon,
104 @@ -1814,6 +1839,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 @@ -1905,6 +1935,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;