From 080d5a02c5ab0ce7f010ead55263dc35d78b3b96 Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Mon, 2 Dec 2024 11:14:30 +0100 Subject: [PATCH] YDA-5992: rearrange admin scripts --- notifications.py | 4 ++-- .../admin-datarequest-temp-write-permission.sh | 0 tools/{ => admin}/admin-datarequestactions.sh | 0 tools/{ => admin}/admin-remove-orphan-vault-if-empty.sh | 0 .../admin-scheduled-copytovault.sh} | 0 tools/admin/admin-user-modify.sh | 8 ++++++++ tools/{ => admin}/admin-vault-archive.sh | 0 tools/{ => admin}/admin-vaultactions.sh | 0 tools/{ => admin}/admin-vaultingest.sh | 0 uuGroup.r | 5 +++++ 10 files changed, 15 insertions(+), 2 deletions(-) rename tools/{ => admin}/admin-datarequest-temp-write-permission.sh (100%) rename tools/{ => admin}/admin-datarequestactions.sh (100%) rename tools/{ => admin}/admin-remove-orphan-vault-if-empty.sh (100%) rename tools/{scheduled-copytovault.sh => admin/admin-scheduled-copytovault.sh} (100%) mode change 100755 => 100644 create mode 100644 tools/admin/admin-user-modify.sh rename tools/{ => admin}/admin-vault-archive.sh (100%) rename tools/{ => admin}/admin-vaultactions.sh (100%) rename tools/{ => admin}/admin-vaultingest.sh (100%) diff --git a/notifications.py b/notifications.py index ae45d3ee7..4dd5b9a53 100644 --- a/notifications.py +++ b/notifications.py @@ -3,7 +3,7 @@ __copyright__ = 'Copyright (c) 2021-2024, Utrecht University' __license__ = 'GPLv3, see LICENSE' - +import base64 import json import random import string @@ -53,7 +53,7 @@ def set(ctx, actor, receiver, target, message): identifier = generate_random_id(ctx) timestamp = int(time.time()) notification = {"identifier": identifier, "timestamp": timestamp, "actor": actor, "target": target, "message": message} - ctx.uuUserModify(receiver, "{}_{}".format(NOTIFICATION_KEY, identifier), json.dumps(notification), '', '') + ctx.uuAdminUserModify(receiver, "{}_{}".format(NOTIFICATION_KEY, identifier), str(base64.b64encode(bytes(json.dumps(notification), "utf-8")), "utf-8")) # Send mail notification if immediate notifications are on. receiver = user.from_str(ctx, receiver)[0] diff --git a/tools/admin-datarequest-temp-write-permission.sh b/tools/admin/admin-datarequest-temp-write-permission.sh similarity index 100% rename from tools/admin-datarequest-temp-write-permission.sh rename to tools/admin/admin-datarequest-temp-write-permission.sh diff --git a/tools/admin-datarequestactions.sh b/tools/admin/admin-datarequestactions.sh similarity index 100% rename from tools/admin-datarequestactions.sh rename to tools/admin/admin-datarequestactions.sh diff --git a/tools/admin-remove-orphan-vault-if-empty.sh b/tools/admin/admin-remove-orphan-vault-if-empty.sh similarity index 100% rename from tools/admin-remove-orphan-vault-if-empty.sh rename to tools/admin/admin-remove-orphan-vault-if-empty.sh diff --git a/tools/scheduled-copytovault.sh b/tools/admin/admin-scheduled-copytovault.sh old mode 100755 new mode 100644 similarity index 100% rename from tools/scheduled-copytovault.sh rename to tools/admin/admin-scheduled-copytovault.sh diff --git a/tools/admin/admin-user-modify.sh b/tools/admin/admin-user-modify.sh new file mode 100644 index 000000000..548d93488 --- /dev/null +++ b/tools/admin/admin-user-modify.sh @@ -0,0 +1,8 @@ +#!/bin/sh +user=$1 +shift +property=$1 +shift +value=`echo $* | base64 -di` +arg='uuUserModify("'$user'", "'$property'", '\'$value\'', *status, *message)' +/bin/irule -r irods_rule_engine_plugin-irods_rule_language-instance "$arg" null ruleExecOut diff --git a/tools/admin-vault-archive.sh b/tools/admin/admin-vault-archive.sh similarity index 100% rename from tools/admin-vault-archive.sh rename to tools/admin/admin-vault-archive.sh diff --git a/tools/admin-vaultactions.sh b/tools/admin/admin-vaultactions.sh similarity index 100% rename from tools/admin-vaultactions.sh rename to tools/admin/admin-vaultactions.sh diff --git a/tools/admin-vaultingest.sh b/tools/admin/admin-vaultingest.sh similarity index 100% rename from tools/admin-vaultingest.sh rename to tools/admin/admin-vaultingest.sh diff --git a/uuGroup.r b/uuGroup.r index b59e3881a..b5d988e7c 100644 --- a/uuGroup.r +++ b/uuGroup.r @@ -239,6 +239,11 @@ uuGroupRemoveOrphanVaultIfEmpty(*vaultName) { writeString("stdout", "*stdout"); } +# \brief Modify user as admin. +uuAdminUserModify(*userName, *property, *b64blob) { + msiExecCmd("admin-user-modify.sh", "*userName *property *b64blob", "", "", 0, *out); +} + # \brief List all groups the user belongs to. # # This function has special handling for 'read-*' groups: