about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/accountsservice/Disable-methods-that-change-files-in-etc.patch
blob: 23e1de95fdffdb5f8ecef236f00d2b11ed6c2b37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From 6f172007452b39bfda5062fc29ea5382671ac16e Mon Sep 17 00:00:00 2001
From: Alexander Ried <ried@mytum.de>
Date: Thu, 26 May 2016 19:54:21 +0200
Subject: [PATCH] Disable methods that change files in /etc

Only if environment variable NIXOS_USERS_PURE is set.
---
 src/daemon.c | 10 ++++++++++
 src/user.c   | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/src/daemon.c b/src/daemon.c
index 861430f..aefaf2d 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -1378,6 +1378,11 @@ daemon_create_user (AccountsAccounts      *accounts,
                     const gchar           *real_name,
                     gint                   account_type)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         Daemon *daemon = (Daemon *) accounts;
         CreateUserData *data;
 
@@ -1581,6 +1586,11 @@ daemon_delete_user (AccountsAccounts      *accounts,
                     gint64                 uid,
                     gboolean               remove_files)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         Daemon *daemon = (Daemon *) accounts;
         DeleteUserData *data;
 
diff --git a/src/user.c b/src/user.c
index 28170db..df947a1 100644
--- a/src/user.c
+++ b/src/user.c
@@ -1216,6 +1216,11 @@ user_set_real_name (AccountsUser          *auser,
                     GDBusMethodInvocation *context,
                     const gchar           *real_name)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
         int uid;
         const gchar *action_id;
@@ -1293,6 +1298,11 @@ user_set_user_name (AccountsUser          *auser,
                     GDBusMethodInvocation *context,
                     const gchar           *user_name)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
 
         daemon_local_check_auth (user->daemon,
@@ -1945,6 +1955,11 @@ user_set_home_directory (AccountsUser          *auser,
                          GDBusMethodInvocation *context,
                          const gchar           *home_dir)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
 
         daemon_local_check_auth (user->daemon,
@@ -2000,6 +2015,11 @@ user_set_shell (AccountsUser          *auser,
                 GDBusMethodInvocation *context,
                 const gchar           *shell)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
 
         daemon_local_check_auth (user->daemon,
@@ -2249,6 +2269,11 @@ user_set_locked (AccountsUser          *auser,
                  GDBusMethodInvocation *context,
                  gboolean               locked)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
 
         daemon_local_check_auth (user->daemon,
@@ -2457,6 +2482,11 @@ user_set_password_mode (AccountsUser          *auser,
                         GDBusMethodInvocation *context,
                         gint                   mode)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
         const gchar *action_id;
         gint uid;
@@ -2550,6 +2580,11 @@ user_set_password (AccountsUser          *auser,
                    const gchar           *password,
                    const gchar           *hint)
 {
+        if (getenv("NIXOS_USERS_PURE")) {
+                throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
+                return;
+        }
+
         User *user = (User *) auser;
         gchar **data;
         const gchar *action_id;