Skip to content

Commit 0da17a0

Browse files
committed
Clarify info in the box.session module:
- Update description in `box.session.su()`, `box.session.user()`, and `box.session.euid()` - Add `box.session.effective_user()` page Fixes #5062
1 parent 41a65d6 commit 0da17a0

File tree

6 files changed

+59
-29
lines changed

6 files changed

+59
-29
lines changed

doc/reference/reference_lua/box_session.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Below is a list of all ``box.session`` functions and members.
3939
* - :doc:`./box_session/user`
4040
- Get the current user's name
4141

42+
* - :doc:`./box_session/effective_user`
43+
- Get the current effective user's name
44+
4245
* - :doc:`./box_session/type`
4346
- Get the connection type or cause of action
4447

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _box_session-effective_user:
2+
3+
box.session.effective_user()
4+
============================
5+
6+
.. module:: box.session
7+
8+
.. function:: effective_user()
9+
10+
:return: the name of the :ref:`current user <authentication-users>`
11+
12+
:rtype: string

doc/reference/reference_lua/box_session/euid.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ box.session.euid()
99

1010
.. function:: euid()
1111

12-
:return: the effective user ID of the :ref:`current user <authentication-users>`.
12+
:return: the :ref:`effective user <box_session-effective_user>` ID of the :ref:`current user <authentication-users>`.
1313

1414
This is the same as :doc:`/reference/reference_lua/box_session/uid`, except
1515
in two cases:
Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
1-
21
.. _box_session-su:
32

4-
================================================================================
53
box.session.su()
6-
================================================================================
4+
================
75

8-
.. module:: box.session
6+
.. module:: box.session
97

10-
.. function:: su(user-name [, function-to-execute])
8+
.. function:: su(user-name [, function-to-execute])
119

1210
Change Tarantool's :ref:`current user <authentication-users>` --
1311
this is analogous to the Unix command ``su``.
1412

15-
Or, if function-to-execute is specified,
13+
Or, if the `function-to-execute` option is specified,
1614
change Tarantool's :ref:`current user <authentication-users>`
1715
temporarily while executing the function --
1816
this is analogous to the Unix command ``sudo``.
1917

2018
:param string user-name: name of a target user
2119
:param function-to-execute: name of a function, or definition of a function.
2220
Additional parameters may be passed to
23-
``box.session.su``, they will be interpreted
24-
as parameters of function-to-execute.
21+
``box.session.su()``, they will be interpreted
22+
as parameters of `function-to-execute`.
23+
24+
**Examples:**
25+
26+
Change Tarantool's current user:
27+
28+
.. code-block:: tarantoolsession
29+
30+
app:instance001> box.session.su('guest')
31+
---
32+
...
33+
34+
Change Tarantool's current user temporarily:
2535

26-
**Example:**
36+
.. code-block:: tarantoolsession
2737
28-
.. code-block:: tarantoolsession
38+
app:instance001> function get_current_user() return box.session.user() end
39+
---
40+
...
2941
30-
tarantool> function f(a) return box.session.user() .. a end
42+
app:instance001> box.session.su('guest', get_current_user)
3143
---
44+
- guest
3245
...
3346
34-
tarantool> box.session.su('guest', f, '-xxx')
47+
app:instance001> box.session.su('guest', get_current_user, '-xxx')
3548
---
3649
- guest-xxx
3750
...
3851
39-
tarantool> box.session.su('guest',function(...) return ... end,1,2)
52+
app:instance001> box.session.su('guest', function(...) return box.session.user() end)
4053
---
41-
- 1
42-
- 2
54+
- guest
4355
...

doc/reference/reference_lua/box_session/user.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
21
.. _box_session-user:
32

4-
================================================================================
53
box.session.user()
6-
================================================================================
4+
==================
5+
6+
.. module:: box.session
77

8-
.. module:: box.session
8+
.. function:: user()
99

10-
.. function:: user()
10+
Return the name of the :ref:`current Tarantool user <authentication-users>`.
11+
If the current user is changed temporarily using the :ref:`box.session.su() <box_session-su>` method,
12+
`box.session.user()` ignores this change.
13+
In this case, `box.session.user()` shows the original current user.
1114

1215
:return: the name of the :ref:`current user <authentication-users>`
1316

locale/ru/LC_MESSAGES/reference/reference_lua/box_session/su.po

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ msgstr ""
1010
" аналогично Unix-команде ``su``."
1111

1212
msgid ""
13-
"Or, if function-to-execute is specified, change Tarantool's :ref:`current "
13+
"Or, if the `function-to-execute` option is specified, change Tarantool's :ref:`current "
1414
"user <authentication-users>` temporarily while executing the function -- "
1515
"this is analogous to the Unix command ``sudo``."
1616
msgstr ""
17-
"Или, если указана выполняемая функция (function-to-execute), временное "
17+
"Или, если указана выполняемая функция (`function-to-execute), временное "
1818
"изменение :ref:`текущего пользователя <authentication-users>` Tarantool во"
1919
" время выполнения функции – аналогично Unix-команде ``sudo``."
2020

@@ -26,15 +26,15 @@ msgstr "целевое имя пользователя"
2626

2727
msgid ""
2828
"name of a function, or definition of a function. Additional parameters may "
29-
"be passed to ``box.session.su``, they will be interpreted as parameters of "
30-
"function-to-execute."
29+
"be passed to ``box.session.su()``, they will be interpreted as parameters of "
30+
"`function-to-execute`."
3131
msgstr ""
32-
"имя функции или определение функции. Дополнительные параметры могут "
33-
"передаваться в ``box.session.su``, они будут интерпретироваться как "
32+
"имя функции или определение функции. Дополнительные параметры, переданные "
33+
"в ``box.session.su``, интерпретируются как "
3434
"параметры выполняемой функции."
3535

36-
msgid "**Example:**"
37-
msgstr "**Пример:**"
36+
msgid "**Examples:**"
37+
msgstr "**Примеры:**"
3838

3939
msgid ""
4040
"tarantool> function f(a) return box.session.user() .. a end\n"

0 commit comments

Comments
 (0)