-
Notifications
You must be signed in to change notification settings - Fork 13
/
uuGroupPolicyChecks.r
651 lines (601 loc) · 22 KB
/
uuGroupPolicyChecks.r
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# \file
# \brief Group operation policy check rules.
# \author Chris Smeele
# \author Ton Smeele
# \author Lazlo Westerhof
# \copyright Copyright (c) 2015 - 2021, Utrecht University. All rights reserved
# \license GPLv3, see LICENSE
# For every Group Management action (GroupAdd, GroupUserChangeRole, etc.) there
# is a corresponding function in this file that will tell you if someone (the
# *actor) is allowed to perform that action with the supplied parameters.
#
# The result is returned in the output parameters *allowed and *reason. For
# calling rules to be able to receive these output parameters, it is imperative
# that the rules in this file DO NOT FAIL.
#
# Context: The rules in this file are called by:
# - Group Manager implementations of Sudo policies (see uuGroupPolicies.r)
# - Group Manager actions, to figure out the reason for denying a Sudo action.
# Utility functions {{{
# \brief Check if a user name is valid.
#
# User names must:
#
# - contain zero or one '@' signs, but not at the beginning or the end of the name
# - contain only lowercase letters and dots if no '@' sign is present
# - contain only lowercase letters, numbers, hyphens, underscores and dots if an '@' sign is present
# - may contain a zone name after a '#' sign
#
# \param[in] name
#
uuUserNameIsValid(*name)
= *name like regex ``([a-z.]+|[a-z0-9_.-]+@[a-z0-9_.-]+)(#[a-zA-Z0-9_-]+)?``;
# \brief Check if a group name is valid for creation by a priv-group-add member.
#
# Group names must:
#
# - be prefixed with 'research-' or 'deposit-'
# - contain only lowercase characters, numbers and hyphens
# - not start or end with a hyphen
#
# NB: Update the category name check below if you change the second half of this pattern.
#
# NB: Datamanager is missing in this list. uuGroupNameIsDatamanager is for the specific datamanager case.
#
# \param[in] name
#
uuGroupNameIsValid(*name)
= *name like regex ``(research|deposit)-([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])``;
uuGroupNameIsDatamanager(*name)
= *name like regex ``(datamanager)-([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])``;
# \brief Check if a category name is valid.
#
# This must be exactly the same as the part of the group name check after the group prefix.
#
# \param[in] name
#
uuGroupCategoryNameIsValid(*name)
= *name like regex ``([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])``;
# \brief Check if a subcategory name is valid.
#
# Subcategory names must:
#
# - contain only letters, numbers, spaces, commas, periods, underscores and hyphens
#
# \param[in] name
#
uuGroupSubcategoryNameIsValid(*name)
= *name like regex ``[a-zA-Z0-9 ,.()_-]+``;
# \brief Check if co_identifier is valid.
#
# CO Identifier must:
#
# - contain only letters, numbers, and hyphens
#
# \param[in] name
# \param[out] valid
#
uuGroupCOIdentifierIsValid(*name, *valid) {
if (*name like regex ``[0-9a-f]{8}\-[0-9a-f]{4}\-4[0-9a-f]{3}\-[89ab][0-9a-f]{3}\-[0-9a-f]{12}`` || *name == '') {
*valid = true;
}
else {
*valid = false;
}
}
# \brief Check if a data classification is valid in combination with a group name.
#
# The valid set of classifications depends on the group prefix.
#
# \param[in] groupName
# \param[in] dataClassification
# \param[out] valid
#
uuGroupDataClassificationIsValid(*groupName, *dataClassification, *valid) {
uuChop(*groupName, *prefix, *base, "-", true);
if (*prefix == "research" || *prefix == "intake") {
uuListContains(list("critical", "sensitive", "basic", "public", "unspecified"), *dataClassification, *valid);
} else {
*valid = (*dataClassification == "");
}
}
# \brief Check if a schema-id is valid.
#
# \param[in] schema_id
# \param[out] valid
#
uuGroupSchemaIdIsValid(*schema_id, *valid) {
# Check validity of schema_id
*schema_coll = "/$rodsZoneClient/yoda/schemas/" ++ *schema_id;
*coll = "";
foreach(*row in SELECT COLL_NAME WHERE COLL_NAME = *schema_coll) {
*coll = *row.COLL_NAME;
succeed;
}
if (*coll != "") {
*valid = true;
} else {
*valid = false;
}
}
# \brief Check if indicated expiration date is valid
#
# \param[in] expiration_date
# \param[out] valid
#
uuGroupExpirationDateIsValid(*expiration_date, *valid) {
*result = "";
rule_group_expiration_date_validate(*expiration_date, *result);
*valid = bool(*result);
}
# \brief Check if actor is a group manager in a group in the category
#
# \param[in] actor
# \param[in] category
# \param[out] isGroupManager
#
uuGroupIsGroupManagerInCategory(*actor, *category, *isGroupManager) {
*isGroupManager = false;
uuUserGetGroups(*actor, false, *groups);
foreach (*actorGroup in *groups) {
uuGroupGetCategory(*actorGroup, *agCategory, *agSubcategory);
if (*agCategory == *category) {
uuGroupUserIsManager(*actorGroup, *actor, *isGroupManager);
if (*isGroupManager) {
break;
}
}
}
}
# }}}
# \brief Group Policy: Can the user create a new group?
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName the new group name
# \param[in] category
# \param[in] subcategory
# \param[in] schema_id
# \param[in] expiration_date
# \param[in] description
# \param[in] dataClassification
# \param[in] co_identifier
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupAdd(*actor, *groupName, *category, *subcategory, *expiration_date, *schema_id, *description, *dataClassification, *co_identifier, *allowed, *reason) {
# Rodsadmin exception.
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupUserExists("priv-group-add", *actor, false, *hasPrivGroupAdd);
uuGroupUserExists("priv-category-add", *actor, false, *hasPrivCatAdd);
if (*hasPrivGroupAdd || *actorUserType == "rodsadmin") {
if (uuGroupNameIsValid(*groupName)) {
uuUserNameIsAvailable(*groupName, *nameAvailable, *existingType);
if (*nameAvailable) {
uuGroupDataClassificationIsValid(*groupName, *dataClassification, *dataclasValid);
if (*dataclasValid) {
uuChop(*groupName, *prefix, *base, "-", true);
# For research groups: Make sure their ro and
# vault groups do not exist yet.
*roName = "read-*base";
uuGroupExists(*roName, *roExists);
*vaultName = "vault-*base";
uuGroupExists(*vaultName, *vaultExists);
# Extra check for situations that a vault path is already present
uuGroupVaultPathExists(*vaultName, *vaultPathExists);
if (*roExists || *vaultExists || *vaultPathExists) {
*reason = "This group name is not available.";
} else {
uuGroupSchemaIdIsValid(*schema_id, *schemaIdValid);
if (*schemaIdValid) {
# Check expiration date
uuGroupExpirationDateIsValid(*expiration_date, *expirationDateValid);
if (*expirationDateValid) {
# Last check.
uuGroupCOIdentifierIsValid(*co_identifier, *coIdentifierValid);
if(*coIdentifierValid) {
uuGroupPolicyCanUseCategory(*actor, *category, *allowed, *reason);
}
else{
*reason = "Invalid SRAM CO Identifier when adding group: '*co_identifier'";
}
} else {
*reason = "Invalid expiration date when adding group: '*expiration_date'";
}
} else {
# schema not valid -> report error
*reason = "Invalid schema-id used when adding group: '*schema_id'";
}
}
} else {
*reason = "The chosen data classification is invalid for this type of group.";
}
} else {
if (*existingType == "rodsuser") {
*existingType = "user";
} else if (*existingType == "rodsgroup") {
*existingType = "group";
}
*reason = "The name '*groupName' is already in use by another *existingType.";
}
} else if (uuGroupNameIsDatamanager(*groupName)) {
if ((*hasPrivGroupAdd && *hasPrivCatAdd) || *actorUserType == "rodsadmin") {
# Special case for a datamanager group.
uuUserNameIsAvailable(*groupName, *nameAvailable, *existingType);
if (*nameAvailable) {
# The category for which the datamanager group is paired with must already exist
# And actor must be a group manager in at least one group
# in the category for them to be allowed to create a datamanager group
*isManagerInCategory = false;
uuGroupIsGroupManagerInCategory(*actor, *category, *isManagerInCategory)
if (*isManagerInCategory) {
*allowed = 1
}
else {
*reason = "You must be a manager of a group in category '*category' to create a datamanager- group"
}
} else {
if (*existingType == "rodsuser") {
*existingType = "user";
} else if (*existingType == "rodsgroup") {
*existingType = "group";
}
*reason = "The name '*groupName' is already in use by another *existingType.";
}
} else {
*reason = "You must have priv-group-add and priv-cat-add to add a datamanger group"
}
} else {
*reason = "Group names must start with one of 'research-', 'deposit-', or 'datamanager-' and may only contain lowercase letters (a-z) and hyphens (-).";
}
} else {
*reason = "You cannot create groups because you are not a member of the priv-group-add group.";
}
}
# \brief Group Policy: Can the user create a group with / modify a group to use a certain category?
#
# This is a utility function for other check functions, there is no
# corresponding group action for this rule.
#
# \param[in] actor the user whose privileges are checked
# \param[in] categoryName the category name
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanUseCategory(*actor, *categoryName, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupCategoryExists(*categoryName, *categoryExists);
if (*categoryExists) {
*isManagerInCategory = false;
uuUserGetGroups(*actor, false, *groups);
foreach (*actorGroup in *groups) {
uuGroupGetCategory(*actorGroup, *agCategory, *agSubcategory);
if (*agCategory == *categoryName) {
uuGroupUserIsManager(*actorGroup, *actor, *isManagerInCategory);
if (*isManagerInCategory) {
break;
}
}
}
if (*isManagerInCategory || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "You cannot use this group category because you are not a group manager in the *categoryName category.";
}
} else {
uuGroupUserExists("priv-category-add", *actor, false, *hasPriv);
if (*hasPriv || *actorUserType == "rodsadmin") {
if (uuGroupCategoryNameIsValid(*categoryName)) {
*allowed = 1;
} else {
*reason = "Category names may only contain lowercase letters (a-z), numbers, and hyphens (-), and may not start or end with a hyphen.";
}
} else {
*reason = "You cannot use this group category because you are not a member of the priv-category-add group.";
}
}
}
# \brief Group Policy: Can the user set a certain group attribute to a certain value?
#
# Available attributes are: category, subcategory and description.
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName the group name
# \param[in] attribute the group attribute to set (one of 'category', 'subcategory', 'description', 'data_classification', 'schema_id', 'expiration_date')
# \param[in] value the new value
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupModify(*actor, *groupName, *attribute, *value, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupUserIsManager(*groupName, *actor, *isManager);
if (*isManager || *actorUserType == "rodsadmin") {
if (*attribute == "category") {
if (*groupName like "datamanager-*" && *groupName != "datamanager-*value") {
*reason = "The category of a datamanager group cannot be changed.";
} else {
uuGroupPolicyCanUseCategory(*actor, *value, *allowed, *reason);
}
} else if (*attribute == "subcategory") {
if (uuGroupSubcategoryNameIsValid(*value)) {
*allowed = 1;
} else {
*reason = "Subcategory names may only contain letters (a-z), numbers, spaces, commas, periods, parentheses, hyphens (-) and underscores (_).";
}
} else if (*attribute == "description") {
*allowed = 1;
} else if (*attribute == "data_classification") {
uuGroupDataClassificationIsValid(*groupName, *value, *dataClassValid);
if (*dataClassValid) {
*allowed = 1;
} else {
*reason = "The chosen data classification is invalid for this type of group.";
}
} else if (*attribute == "schema_id") {
uuGroupSchemaIdIsValid(*value, *schemaIdValid);
if (*schemaIdValid) {
*allowed = 1;
} else {
*reason = "The chosen schema id is invalid for this group.";
}
} else if (*attribute == "expiration_date") {
uuGroupExpirationDateIsValid(*value, *expirationDateValid);
if (*expirationDateValid) {
*allowed = 1;
} else {
*reason = "The chosen expiration date is invalid.";
}
} else if (*attribute == "co_identifier") {
uuGroupCOIdentifierIsValid(*value, *coIdentifierValid);
if(*coIdentifierValid) {
*allowed = 1;
}
else{
*reason = "The CO Identifier is invalid";
}
} else {
*reason = "Invalid group attribute name.";
}
} else {
*reason = "You are not a manager of group *groupName.";
}
}
# \brief Group Policy: Can the user remove a group?
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName the group name
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupRemove(*actor, *groupName, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupUserIsManager(*groupName, *actor, *isManager);
# Only a rodsadmin or a privileged group manager in
# that category can remove a datamanager-group.
# v These groups are user-removable v
if (*groupName like regex "(grp|intake|research|deposit|vault)-.*" ) {
if (*isManager || *actorUserType == "rodsadmin") {
*homeCollection = "/$rodsZoneClient/home/*groupName";
*homeCollectionIsEmpty = true;
foreach (*row in SELECT DATA_NAME WHERE COLL_NAME = '*homeCollection') {
*homeCollectionIsEmpty = false; break;
}
foreach (*row in SELECT COLL_ID WHERE COLL_PARENT_NAME LIKE '*homeCollection') {
*homeCollectionIsEmpty = false; break;
}
if (*homeCollectionIsEmpty) {
if (*groupName like regex "(research)-.*") {
# Research groups can only be removed when no vault packages exist
uuChop(*groupName, *prefix, *base, "-", true);
*vaultName = "vault-*base";
*zoneName = $rodsZoneClient;
*vaultIsEmpty = true;
# Check whether vault still holds data
msiMakeGenQuery("COLL_NAME", "COLL_NAME like '/*zoneName/home/*vaultName/%'", *genQIn);
msiExecGenQuery(*genQIn, *genQOut);
foreach(*genQOut){
*vaultIsEmpty = false;
break;
}
if (*vaultIsEmpty) {
*allowed = 1;
} else {
*reason = "There are still datapackages in the vault for group: *groupName. Please remove these first before removing this group.";
}
} else {
*allowed = 1;
}
} else {
*reason = "The group's directory is not empty. Please remove all of its files and subdirectories before removing this group.";
}
} else {
*reason = "You are not a manager of group *groupName.";
}
} else if (*groupName like regex "(datamanager)-.*") {
# Confirm actor is a manager of at least one group in the category
# and has the privileges
uuGroupGetCategory(*groupName, *category, *agSubcategory);
uuGroupIsGroupManagerInCategory(*actor, *category, *isManagerInCategory)
if (*isManagerInCategory) {
uuGroupUserExists("priv-group-add", *actor, false, *hasPrivGroupAdd);
uuGroupUserExists("priv-category-add", *actor, false, *hasPrivCatAdd);
if (*hasPrivGroupAdd && *hasPrivCatAdd) {
*allowed = 1
}
else {
*reason = "You must have group and category add privileges to delete this datamanager- group";
}
}
else {
*reason = "You must be a manager of a group in category '*category' to delete this datamanager- group"
}
} else {
*reason = "'*groupName' is not a regular group. You can only remove groups that have one of the following prefixes: grp, intake, research, vault.";
}
}
# \brief Group Policy: Can the user add a new user to a certain group?
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName the group name
# \param[in] newMember the user to add to the group
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupUserAdd(*actor, *groupName, *newMember, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupGetMemberCount(*groupName, *members);
if (int(*members) == 0 && *newMember == *actor) {
# Special case for empty groups.
# This is run if a group has just been created. We then allow
# the group creator (already set in the 'manager' field by the
# postproc of GroupAdd) to add himself to the group.
*isCreator = false;
foreach (
*manager in
SELECT META_USER_ATTR_VALUE
WHERE USER_GROUP_NAME = '*groupName'
AND META_USER_ATTR_NAME = 'manager'
AND META_USER_ATTR_VALUE = '*newMember'
) {
*isCreator = true;
}
if (*isCreator || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "You are not a manager of group '*groupName'.";
}
} else {
uuGroupUserIsManager(*groupName, *actor, *isManager);
if (*isManager || *actorUserType == "rodsadmin") {
uuGroupUserExists(*groupName, *newMember, false, *isAlreadyAMember);
if (*isAlreadyAMember) {
*reason = "User '*newMember' is already a member of group '*groupName'.";
} else {
if (uuUserNameIsValid(*newMember)) {
*allowed = 1;
} else {
*reason = "The new member's name is invalid.";
}
}
} else {
*reason = "You are not a manager of group *groupName.";
}
}
}
# \brief Group Policy: Can the user remove a user from a certain group?
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName the group name
# \param[in] member the user to remove from the group
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupUserRemove(*actor, *groupName, *member, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupUserIsManager(*groupName, *actor, *isManager);
if (*isManager || *actorUserType == "rodsadmin") {
if (*member == *actor) {
# This also ensures that groups always have at least one manager.
*reason = "You cannot remove yourself from group *groupName.";
} else {
*allowed = 1;
}
} else {
*reason = "You are not a manager of group *groupName.";
}
}
# \brief Group Policy: Can the user change a group member's role?
#
# \param[in] actor the user whose privileges are checked
# \param[in] groupName
# \param[in] member the target group member
# \param[in] newRole the member's new role
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuGroupPolicyCanGroupUserChangeRole(*actor, *groupName, *member, *newRole, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
uuGroupUserExists(*groupName, *member, true, *exists);
if (*exists) {
if ( (*newRole == "normal" || *newRole == "manager")
|| (*newRole == "reader" && *groupName like regex "(intake|research|deposit)-.*")) {
uuGroupUserIsManager(*groupName, *actor, *isManager);
if (*isManager || *actorUserType == "rodsadmin") {
if (*member == *actor) {
*reason = "You cannot change your own role in group *groupName.";
} else {
*allowed = 1;
}
} else {
*reason = "You are not a manager of group *groupName.";
}
} else {
*reason = "'*newRole' is not a valid member role for group *groupName.";
}
} else {
*reason = "'*member' is not a member of group *groupName.";
}
}
# \brief User Policy: Can the user set a certain user attribute to a certain value?
#
# \param[in] actor the user whose privileges are checked
# \param[in] userName the user name
# \param[in] attribute the user attribute to set
# \param[out] allowed whether the action is allowed
# \param[out] reason the reason why the action was disallowed, set if allowed is false
#
uuUserPolicyCanUserModify(*actor, *userName, *attribute, *allowed, *reason) {
uuGetUserType(*actor, *actorUserType);
*allowed = 0;
*reason = "";
# User setting: mail notifications
if (*attribute == "org_settings_mail_notifications") {
if (*actor == *userName || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "Cannot modify settings of other user.";
}
# User setting: Number of items
} else if (*attribute == "org_settings_number_of_items") {
if (*actor == *userName || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "Cannot modify settings of other user.";
}
# User setting: Initial list to be presented in group manager: Tree or flat list
} else if (*attribute == "org_settings_group_manager_view") {
if (*actor == *userName || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "Cannot modify settings of other user.";
}
# User setting: Color mode
} else if (*attribute == "org_settings_color_mode") {
if (*actor == *userName || *actorUserType == "rodsadmin") {
*allowed = 1;
} else {
*reason = "Cannot modify settings of other user.";
}
# User SRAM invitation
} else if (*attribute == "org_sram_invited") {
*allowed = 1;
# User notifications
} else if (trimr(*attribute, "_") == "org_notification") {
*allowed = 1;
} else {
*reason = "Invalid user attribute name.";
}
}