Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / accountsservice / Disable-methods-that-change-files-in-etc.patch
blob23e1de95fdffdb5f8ecef236f00d2b11ed6c2b37
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.
7 ---
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
14 --- a/src/daemon.c
15 +++ b/src/daemon.c
16 @@ -1378,6 +1378,11 @@ daemon_create_user (AccountsAccounts *accounts,
17 const gchar *real_name,
18 gint account_type)
20 + if (getenv("NIXOS_USERS_PURE")) {
21 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
22 + return;
23 + }
25 Daemon *daemon = (Daemon *) accounts;
26 CreateUserData *data;
28 @@ -1581,6 +1586,11 @@ daemon_delete_user (AccountsAccounts *accounts,
29 gint64 uid,
30 gboolean remove_files)
32 + if (getenv("NIXOS_USERS_PURE")) {
33 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
34 + return;
35 + }
37 Daemon *daemon = (Daemon *) accounts;
38 DeleteUserData *data;
40 diff --git a/src/user.c b/src/user.c
41 index 28170db..df947a1 100644
42 --- a/src/user.c
43 +++ b/src/user.c
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");
50 + return;
51 + }
53 User *user = (User *) auser;
54 int uid;
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");
62 + return;
63 + }
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");
74 + return;
75 + }
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,
82 const gchar *shell)
84 + if (getenv("NIXOS_USERS_PURE")) {
85 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
86 + return;
87 + }
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,
94 gboolean locked)
96 + if (getenv("NIXOS_USERS_PURE")) {
97 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
98 + return;
99 + }
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,
106 gint mode)
108 + if (getenv("NIXOS_USERS_PURE")) {
109 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
110 + return;
113 User *user = (User *) auser;
114 const gchar *action_id;
115 gint uid;
116 @@ -2550,6 +2580,11 @@ user_set_password (AccountsUser *auser,
117 const gchar *password,
118 const gchar *hint)
120 + if (getenv("NIXOS_USERS_PURE")) {
121 + throw_error (context, ERROR_NOT_SUPPORTED, "Modifying users not supported without users.mutableUsers");
122 + return;
125 User *user = (User *) auser;
126 gchar **data;
127 const gchar *action_id;