Verifying the server user to work with sudo (#1254)

* checking that the username is root

Changing the mechanism for checking that the username is root

* wheel group check (#1198)

Checking if the user is included in the wheel group

* Checking requirements in script (#1210)

* Checking requirements in script

Checking requirements for sudo users in script

* Adding error handling

Adding error handling in the server controller for:
Sudo package is not pre-installed for sudo users.
Server user or associated group is not listed in the sudoers file.
Server user password required

* adding error codes

* added extended error descriptions

* checking sudo permission for root

Сhecking sudo permission for root.
Сhecking and redefining the system language.

* Username if whoami returns an error

Сommand to use home directory name if whoami returns error or is missing.

* Correcting text error

Correction of the text of the extended description of the package manager error

* Updating translations

* Optimization check_user_in_sudo.sh

* exceptions for missing uname

* output only for groups sudo or wheel
This commit is contained in:
lunardunno 2024-12-01 13:51:03 +04:00 committed by GitHub
parent 85fa1ad8b1
commit 076b076cd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 48 additions and 38 deletions

View file

@ -1,2 +1,4 @@
CUR_USER=$(whoami);\
groups $CUR_USER
CUR_USER=$(whoami 2> /dev/null || echo ~ | sed 's/.*\///');\
echo $LANG | grep -qE "en_US.UTF-8|^C.UTF-8" || export LC_ALL=C;\
if [ "$CUR_USER" = "root" ]; then command -v sudo > /dev/null 2>&1 && sudo -nu $CUR_USER sudo -n uname > /dev/null;\
else groups $CUR_USER | grep -E "\<sudo\>|\<wheel\>" && sudo -nu $CUR_USER sudo -n uname > /dev/null; fi

View file

@ -1,4 +1,4 @@
CUR_USER=$(whoami);\
CUR_USER=$(whoami 2> /dev/null || echo ~ | sed 's/.*\///');\
sudo mkdir -p $DOCKERFILE_FOLDER;\
sudo chown $CUR_USER $DOCKERFILE_FOLDER;\
if ! sudo docker network ls | grep -q amnezia-dns-net; then sudo docker network create \