Merge branch 'dev' into support_podman

This commit is contained in:
lunardunno 2025-03-15 03:40:39 +04:00 committed by GitHub
commit 8a3183f101
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 66 additions and 51 deletions

View file

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25.0 FATAL_ERROR)
set(PROJECT AmneziaVPN) set(PROJECT AmneziaVPN)
project(${PROJECT} VERSION 4.8.4.4 project(${PROJECT} VERSION 4.8.4.3
DESCRIPTION "AmneziaVPN" DESCRIPTION "AmneziaVPN"
HOMEPAGE_URL "https://amnezia.org/" HOMEPAGE_URL "https://amnezia.org/"
) )
@ -11,7 +11,7 @@ string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
set(RELEASE_DATE "${CURRENT_DATE}") set(RELEASE_DATE "${CURRENT_DATE}")
set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH}) set(APP_MAJOR_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
set(APP_ANDROID_VERSION_CODE 2081) set(APP_ANDROID_VERSION_CODE 2080)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(MZ_PLATFORM_NAME "linux") set(MZ_PLATFORM_NAME "linux")

View file

@ -31,10 +31,6 @@ add_definitions(-DDEV_AGW_PUBLIC_KEY="$ENV{DEV_AGW_PUBLIC_KEY}")
add_definitions(-DDEV_AGW_ENDPOINT="$ENV{DEV_AGW_ENDPOINT}") add_definitions(-DDEV_AGW_ENDPOINT="$ENV{DEV_AGW_ENDPOINT}")
add_definitions(-DDEV_S3_ENDPOINT="$ENV{DEV_S3_ENDPOINT}") add_definitions(-DDEV_S3_ENDPOINT="$ENV{DEV_S3_ENDPOINT}")
if(IOS)
set(PACKAGES ${PACKAGES} Multimedia)
endif()
if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
set(PACKAGES ${PACKAGES} Widgets) set(PACKAGES ${PACKAGES} Widgets)
endif() endif()
@ -48,10 +44,6 @@ set(LIBS ${LIBS}
Qt6::Core5Compat Qt6::Concurrent Qt6::Core5Compat Qt6::Concurrent
) )
if(IOS)
set(LIBS ${LIBS} Qt6::Multimedia)
endif()
if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID)) if(WIN32 OR (APPLE AND NOT IOS) OR (LINUX AND NOT ANDROID))
set(LIBS ${LIBS} Qt6::Widgets) set(LIBS ${LIBS} Qt6::Widgets)
endif() endif()

View file

@ -709,7 +709,7 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
QString transportProto = containerConfig.value(config_key::transport_proto).toString(defaultTransportProto); QString transportProto = containerConfig.value(config_key::transport_proto).toString(defaultTransportProto);
// TODO reimplement with netstat // TODO reimplement with netstat
QString script = QString("which lsof > /dev/null 2>&1 || true && sudo lsof -i -P -n 2>/dev/null | grep -E ':%1 ").arg(port); QString script = QString("which lsof &>/dev/null || true && sudo lsof -i -P -n 2>/dev/null | grep -E ':%1 ").arg(port);
for (auto &port : fixedPorts) { for (auto &port : fixedPorts) {
script = script.append("|:%1").arg(port); script = script.append("|:%1").arg(port);
} }
@ -757,10 +757,6 @@ ErrorCode ServerController::isServerPortBusy(const ServerCredentials &credential
ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, DockerContainer container) ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, DockerContainer container)
{ {
if (credentials.userName == "root") {
return ErrorCode::NoError;
}
QString stdOut; QString stdOut;
auto cbReadStdOut = [&](const QString &data, libssh::Client &) { auto cbReadStdOut = [&](const QString &data, libssh::Client &) {
stdOut += data + "\n"; stdOut += data + "\n";
@ -774,8 +770,16 @@ ErrorCode ServerController::isUserInSudo(const ServerCredentials &credentials, D
const QString scriptData = amnezia::scriptData(SharedScriptType::check_user_in_sudo); const QString scriptData = amnezia::scriptData(SharedScriptType::check_user_in_sudo);
ErrorCode error = runScript(credentials, replaceVars(scriptData, genVarsForScript(credentials)), cbReadStdOut, cbReadStdErr); ErrorCode error = runScript(credentials, replaceVars(scriptData, genVarsForScript(credentials)), cbReadStdOut, cbReadStdErr);
if (!stdOut.contains("sudo") && !stdOut.contains("wheel")) if (credentials.userName != "root" && stdOut.contains("sudo:") && !stdOut.contains("uname:") && stdOut.contains("not found"))
return ErrorCode::SudoPackageIsNotPreinstalled;
if (credentials.userName != "root" && !stdOut.contains("sudo") && !stdOut.contains("wheel"))
return ErrorCode::ServerUserNotInSudo; return ErrorCode::ServerUserNotInSudo;
if (stdOut.contains("can't cd to") || stdOut.contains("Permission denied") || stdOut.contains("No such file or directory"))
return ErrorCode::ServerUserDirectoryNotAccessible;
if (stdOut.contains("sudoers") || stdOut.contains("is not allowed to run sudo on"))
return ErrorCode::ServerUserNotAllowedInSudoers;
if (stdOut.contains("password is required"))
return ErrorCode::ServerUserPasswordRequired;
return error; return error;
} }

View file

@ -54,6 +54,10 @@ namespace amnezia
ServerCancelInstallation = 204, ServerCancelInstallation = 204,
ServerUserNotInSudo = 205, ServerUserNotInSudo = 205,
ServerPacketManagerError = 206, ServerPacketManagerError = 206,
SudoPackageIsNotPreinstalled = 207,
ServerUserDirectoryNotAccessible = 208,
ServerUserNotAllowedInSudoers = 209,
ServerUserPasswordRequired = 210,
// Ssh connection errors // Ssh connection errors
SshRequestDeniedError = 300, SshRequestDeniedError = 300,

View file

@ -20,8 +20,12 @@ QString errorString(ErrorCode code) {
case(ErrorCode::ServerContainerMissingError): errorMessage = QObject::tr("Server error: Docker container missing"); break; case(ErrorCode::ServerContainerMissingError): errorMessage = QObject::tr("Server error: Docker container missing"); break;
case(ErrorCode::ServerDockerFailedError): errorMessage = QObject::tr("Server error: Docker failed"); break; case(ErrorCode::ServerDockerFailedError): errorMessage = QObject::tr("Server error: Docker failed"); break;
case(ErrorCode::ServerCancelInstallation): errorMessage = QObject::tr("Installation canceled by user"); break; case(ErrorCode::ServerCancelInstallation): errorMessage = QObject::tr("Installation canceled by user"); break;
case(ErrorCode::ServerUserNotInSudo): errorMessage = QObject::tr("The user does not have permission to use sudo"); break; case(ErrorCode::ServerUserNotInSudo): errorMessage = QObject::tr("The user is not a member of the sudo group"); break;
case(ErrorCode::ServerPacketManagerError): errorMessage = QObject::tr("Server error: Packet manager error"); break; case(ErrorCode::ServerPacketManagerError): errorMessage = QObject::tr("Server error: Package manager error"); break;
case(ErrorCode::SudoPackageIsNotPreinstalled): errorMessage = QObject::tr("The sudo package is not pre-installed"); break;
case(ErrorCode::ServerUserDirectoryNotAccessible): errorMessage = QObject::tr("The server user's home directory is not accessible"); break;
case(ErrorCode::ServerUserNotAllowedInSudoers): errorMessage = QObject::tr("Action not allowed in sudoers"); break;
case(ErrorCode::ServerUserPasswordRequired): errorMessage = QObject::tr("The user's password is required"); break;
// Libssh errors // Libssh errors
case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break; case(ErrorCode::SshRequestDeniedError): errorMessage = QObject::tr("SSH request was denied"); break;

View file

@ -1,2 +1,13 @@
CUR_USER=$(whoami);\ if which apt-get > /dev/null 2>&1; then pm=$(which apt-get); opt="--version";\
groups $CUR_USER elif which dnf > /dev/null 2>&1; then pm=$(which dnf); opt="--version";\
elif which yum > /dev/null 2>&1; then pm=$(which yum); opt="--version";\
elif which pacman > /dev/null 2>&1; then pm=$(which pacman); opt="--version";\
else pm="uname"; opt="-a";\
fi;\
CUR_USER=$(whoami 2>/dev/null || echo ~ | sed 's/.*\///');\
echo $LANG | grep -qE '^(en_US.UTF-8|C.UTF-8|C)$' || export LC_ALL=C;\
sudo -K;\
cd ~;\
if [ "$CUR_USER" = "root" ] || ( groups "$CUR_USER" | grep -E '\<(sudo|wheel)\>' ); then \
sudo -nu $CUR_USER $pm $opt > /dev/null; sudo -n $pm $opt > /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 mkdir -p $DOCKERFILE_FOLDER;\
sudo chown $CUR_USER $DOCKERFILE_FOLDER;\ sudo chown $CUR_USER $DOCKERFILE_FOLDER;\
if ! sudo docker network ls | grep -q amnezia-dns-net; then sudo docker network create \ if ! sudo docker network ls | grep -q amnezia-dns-net; then sudo docker network create \

View file

@ -3334,8 +3334,8 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>ليس لدي المستخدم الصلحيات لأستخدام sudo</translation> <translation>المستخدم ليس عضوًا في مجموعة sudo</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>
@ -3399,7 +3399,7 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation>خطأ في الخادم: خطأ في مدير الحزم</translation> <translation>خطأ في الخادم: خطأ في مدير الحزم</translation>
</message> </message>
<message> <message>

View file

@ -3468,8 +3468,8 @@ It&apos;s okay as long as it&apos;s from someone you trust.</source>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>The user does not have permission to use sudo</translation> <translation>کاربر عضو گروه sudo نیست</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>
@ -3590,8 +3590,8 @@ It&apos;s okay as long as it&apos;s from someone you trust.</source>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation>Server error: Packet manager error</translation> <translation>خطای سرور: خطای مدیر بسته</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="34"/> <location filename="../core/errorstrings.cpp" line="34"/>

View file

@ -3434,13 +3434,13 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation> sudo ि </translation> <translation> sudo </translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation> ि: ि</translation> <translation> ि: ि</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>

View file

@ -3330,8 +3330,8 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation> sudo ကက</translation> <translation> sudo </translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>
@ -3395,8 +3395,8 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation> မှု: Packet Manager </translation> <translation> - Package manager </translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="34"/> <location filename="../core/errorstrings.cpp" line="34"/>

View file

@ -4038,13 +4038,13 @@ and will not be shared or disclosed to the Amnezia or any third parties</source>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>У пользователя нет прав на использование sudo</translation> <translation>Пользователь не входит в группу sudo</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="24"/> <location filename="../core/errorstrings.cpp" line="24"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation>Ошибка сервера: ошибка менеджера пакетов</translation> <translation>Ошибка сервера: Ошибка менеджера пакетов</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="27"/> <location filename="../core/errorstrings.cpp" line="27"/>

View file

@ -3700,13 +3700,13 @@ and will not be shared or disclosed to the Amnezia or any third parties</source>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>The user does not have permission to use sudo</translation> <translation>Користувач не входить до групи sudo</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation type="unfinished"></translation> <translation>Помилка сервера: Помилка менеджера пакетів</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>

View file

@ -3433,8 +3433,8 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>صارف کو sudo استعمال کرنے کی اجازت نہیں ہے</translation> <translation>صارف sudo گروپ کا رکن نہیں ہے</translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>
@ -3498,7 +3498,7 @@ Already installed containers were found on the server. All installed containers
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation>سرور خطا: پیکیج منیجر خطا</translation> <translation>سرور خطا: پیکیج منیجر خطا</translation>
</message> </message>
<message> <message>

View file

@ -3675,13 +3675,13 @@ and will not be shared or disclosed to the Amnezia or any third parties</source>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="22"/> <location filename="../core/errorstrings.cpp" line="22"/>
<source>The user does not have permission to use sudo</source> <source>The user is not a member of the sudo group</source>
<translation>root权限</translation> <translation> sudo </translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="23"/> <location filename="../core/errorstrings.cpp" line="23"/>
<source>Server error: Packet manager error</source> <source>Server error: Package manager error</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../core/errorstrings.cpp" line="26"/> <location filename="../core/errorstrings.cpp" line="26"/>