Updated at July 17, 2026 02:08 PM
box.session.su()
Change Tarantool's current user – this is
analogous to the Unix command su.
Or, if the function-to-execute option is specified, change
Tarantool's current user temporarily while executing the function –
this is analogous to the Unix command sudo. If the user is changed
temporarily:
- box.session.user() ignores this change.
- box.session.effective_user() shows this change.
Parameters:
-
user-name(string) — name of a target user -
function-to-execute— a function object. Additional parameters may be passed tobox.session.su(), they will be interpreted as parameters offunction-to-execute.
Example 1
Change Tarantool's current user to guest:
app:instance001> box.session.su('guest')---...
Example 2
Change Tarantool's current user to temporary_user temporarily:
app:instance001> function get_current_user() return box.session.user() end---...app:instance001> function get_effective_user() return box.session.effective_user() end---...app:instance001> get_current_user()---- admin...app:instance001> box.session.su('temporary_user', get_current_user)---- admin...app:instance001> box.session.su('temporary_user', get_effective_user)---- temporary_user...app:instance001> box.session.su('temporary_user', get_effective_user, '-xxx')---- temporary_user-xxx...app:instance001> box.session.su('temporary_user', function(...) return box.session.user() end)---- admin...