From c271506e9c162f5b9cac3d4e4e39d7a06a2d2ca6 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Tue, 30 Jan 2024 19:01:01 +0300
Subject: [PATCH] feat: grant 'public' access to .proc_* with `pub` visibility

---
 src/lib.rs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index a2b75c51a9..16aaa5cbc1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -237,12 +237,16 @@ fn init_handlers() {
     let lua = ::tarantool::lua_state();
     for proc in ::tarantool::proc::all_procs().iter() {
         lua.exec_with(
-            "box.schema.func.create('.' .. ...,
-                { language = 'C', if_not_exists = true }
-            );",
-            proc.name(),
+            "local name, is_public = ...
+            local proc_name = '.' .. name
+            box.schema.func.create(proc_name, {language = 'C', if_not_exists = true})
+            if is_public then
+                box.schema.role.grant('public', 'execute', 'function', proc_name, {if_not_exists = true})
+            end
+            ",
+            (proc.name(), proc.is_public()),
         )
-        .expect("box.schema.func.create should never fail");
+        .expect("this shouldn't fail");
     }
 
     lua.exec(
-- 
GitLab