| SYSTEM INFORMATION | |
|---|---|
| OS type and version | Ubuntu 26.04.1 LTS |
| Webmin version | 2.660 |
| Virtualmin version | 8.1.0 GPL |
I work too much & missed my window to respond to my previous topic.
The previous topic is not solved so I’ve decided to make a request.
Some (actually many) custom commands must be run as root (else a permission error) but they are for other users that require certain functions.
These custom commands end up being for multiple users therefore the user name that invoked the command is necessary so that all users can apply something that only affects their specific user directory or database(s).
No matter what I do it seems that if the command has to be run as root then only the root user name is in a variable which is completely useless.
printenv only contains data for the root user because the command has to be run as root.
No variable or bash command seems to show the actual Virtualmin user that invoked the command.
Why not introduce a global array that has some user values that can be used this way?
Is it not possible for the parent window to pass this data somehow?
Please.. try my described scenario & perhaps you will see the frustration.
This is just a basic scenario that will show what variables/arrays are available.
Keep in mind that the website users on this system do not have sudo access nor any terminal access.
Create a custom command that runs a bash script and you can pass the user account at the end of the command.
Ensure the command is run as root and checkmark the user environment setting.
example command (try all known variables/array keys for the user account to see what is available - $REMOTE_USER is only an example that does not work!):
bash /usr/local/bin/virtualmin-example.sh “$REMOTE_USER”
Commands within your script have to be for the user account that executed the command but your OS will only allow root to invoke the commands else a permission error.
In this case it is only a test so we are only echoing the passed variable to see what we can work with.
The bash script for this example ( file: /usr/local/bin/virtualmin-example.sh )
printf ‘The first variable value passed as reference: %s’ “$1”;
This currently outputs nothing.
What I propose is to add the ability to access some parent user variables when the command has to run as root.
Multiple users will be using these commands but currently when a user is allowed to use custom commands they see them all.