_subprocess_run_as_user
Run simple commands as another user
This module provides a set of tools similar to subprocess.run, glob.glob or
os.path.exists, but extended so that they can be executed on behalf of
another user. Note that this requires appropriate sudo permissions.
_mkdir_as_user(*, folder, user)
¶
Create a folder as a different user
| PARAMETER | DESCRIPTION |
|---|---|
folder
|
Absolute path to the folder
TYPE:
|
user
|
User to be impersonated
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
if |
Source code in fractal_server/runner/executors/slurm_sudo/_subprocess_run_as_user.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
_run_command_as_user(*, cmd, user=None, check=False)
¶
Use sudo -u to impersonate another user and run a command
| PARAMETER | DESCRIPTION |
|---|---|
cmd
|
Command to be run
TYPE:
|
user
|
User to be impersonated
TYPE:
|
check
|
If
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
RuntimeError
|
if |
| RETURNS | DESCRIPTION |
|---|---|
res
|
The return value from
TYPE:
|
Source code in fractal_server/runner/executors/slurm_sudo/_subprocess_run_as_user.py
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 | |