Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ file_filter = po/<lang>.po
source_file = po/en_US.po
source_lang = en_US
type = PO

[o:linuxdeepin:p:linyaps:r:304ad8396f170f4f174265e91d850f4e]
file_filter = misc/share/polkit-1/translations/policy_<lang>.ts
source_file = misc/share/polkit-1/translations/policy.ts
source_lang = en_US
type = QT
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.11.4)

project(
linglong
VERSION 1.13.0
VERSION 1.13.1
DESCRIPTION "a container based application package manager for Linux desktop"
HOMEPAGE_URL "https://github.com/OpenAtom-Linyaps/linyaps"
LANGUAGES CXX C)
Expand Down
18 changes: 18 additions & 0 deletions apps/ll-cli/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
#include <sys/file.h>

#include <QDBusMetaType>
#include <QDBusObjectPath>

Check warning on line 27 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusObjectPath> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QJsonDocument>

Check warning on line 28 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QJsonDocument> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QJsonObject>

Check warning on line 29 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QJsonObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>

Check warning on line 30 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QProcess> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtGlobal>

Check warning on line 31 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtGlobal> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <algorithm>

Check warning on line 33 in apps/ll-cli/src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <algorithm> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <functional>
#include <map>
#include <memory>
Expand Down Expand Up @@ -685,6 +686,23 @@
}

const bool peerMode = noDBusFlag->count() > 0;
if (peerMode) {
if (getuid() != 0) {
LogE("--no-dbus should only be used by root user.");
return -1;
}

// Start ll-package-manager --no-dbus first to initialize the repository
QProcess::startDetached("sudo",
{ "--user",
LINGLONG_USERNAME,
"--preserve-env=QT_FORCE_STDERR_LOGGING",
"--preserve-env=QDBUS_DEBUG",
LINGLONG_LIBEXEC_DIR "/ll-package-manager",
"--no-dbus" });
using namespace std::chrono_literals;
std::this_thread::sleep_for(1s);
Comment on lines +696 to +704

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Unhandled Process Startup Failure & Flaky Sleep

  1. Unhandled Failure: QProcess::startDetached returns a bool indicating whether the process was successfully started. If it fails (e.g., if sudo is missing, permissions are incorrect, or the path is invalid), the failure is silently ignored, and the program will sleep for 1 second before failing with a generic/confusing error when trying to load the repository.
  2. Flaky Sleep: Using a hardcoded std::this_thread::sleep_for(1s) to wait for the daemon to initialize is a known anti-pattern. On slow or heavily loaded systems, 1 second might not be enough, leading to intermittent/flaky failures. On fast systems, it introduces an unnecessary 1-second delay to every CLI invocation.

Recommendation:

  • Check the return value of QProcess::startDetached and handle failure.
  • Consider implementing a polling loop with a small sleep interval (e.g., 50ms) and a timeout (e.g., up to 2 seconds) that checks for the creation of the socket file /tmp/linglong-package-manager.socket or the initialization of the repository instead of a hardcoded sleep.
        if (!QProcess::startDetached("sudo",
                                     { "--user",
                                       LINGLONG_USERNAME,
                                       "--preserve-env=QT_FORCE_STDERR_LOGGING",
                                       "--preserve-env=QDBUS_DEBUG",
                                       LINGLONG_LIBEXEC_DIR "/ll-package-manager",
                                       "--no-dbus" })) {
            LogE("failed to start ll-package-manager");
            return -1;
        }
        using namespace std::chrono_literals;
        std::this_thread::sleep_for(1s);

}
auto repo = linglong::repo::OSTreeRepo::loadFromPath(LINGLONG_ROOT);
if (!repo.has_value()) {
LogE("failed to load repo: {}", repo.error());
Expand Down
13 changes: 0 additions & 13 deletions libs/linglong/src/linglong/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,21 +464,8 @@ utils::error::Result<api::dbus::v1::PackageManager *> Cli::getPkgMan()
}

if (this->peerMode) {
if (getuid() != 0) {
return LINGLONG_ERR("--no-dbus should only be used by root user.");
}

LogW("some subcommands will failed in --no-dbus mode.");
const auto pkgManAddress = QString("unix:path=/tmp/linglong-package-manager.socket");
QProcess::startDetached("sudo",
{ "--user",
LINGLONG_USERNAME,
"--preserve-env=QT_FORCE_STDERR_LOGGING",
"--preserve-env=QDBUS_DEBUG",
LINGLONG_LIBEXEC_DIR "/ll-package-manager",
"--no-dbus" });
using namespace std::chrono_literals;
std::this_thread::sleep_for(1s);

const auto &pkgManConn =
QDBusConnection::connectToPeer(pkgManAddress, "ll-package-manager");
Comment on lines 466 to 471

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Architectural Issue: Daemon Startup Logic Moved to Application Entry Point

The logic to start ll-package-manager in peerMode was moved from the library (libs/linglong/src/linglong/cli/cli.cpp) to the application's entry point (apps/ll-cli/src/main.cpp).

Since libs/linglong is a shared library, other executables or components using Cli::getPkgMan() in peerMode will no longer automatically start the ll-package-manager daemon, leading to connection failures.

Recommendation:
Keep the daemon startup logic inside the library (e.g., as a helper function in Cli or PackageManager initialization) so that any consumer of the library can safely use peerMode without manual setup in their respective main.cpp.

Expand Down
4 changes: 4 additions & 0 deletions libs/linglong/src/linglong/runtime/run_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,10 @@ utils::error::Result<void> RunContext::resolveTimeZone()
std::error_code ec;
auto localtimeStatus = std::filesystem::symlink_status(localtimePath, ec);
if (ec) {
if (ec == std::errc::no_such_file_or_directory) {
contextCfg.timezone = "UTC";
return LINGLONG_OK;
}
return LINGLONG_ERR(fmt::format("failed to get status of {}", localtimePath), ec);
}

Expand Down
58 changes: 54 additions & 4 deletions misc/share/polkit-1/translations/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,63 @@
<context>
<name>policy</name>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!message" line="0" />
<source>Authentication is required to perform this action</source>
<location filename="org.deepin.linglong.PackageManager1.install!message" line="0" />
<source>Authentication is required to install packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!description" line="0" />
<source>Check Authentication</source>
<location filename="org.deepin.linglong.PackageManager1.install!description" line="0" />
<source>Install packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!message" line="0" />
<source>Authentication is required to update packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!description" line="0" />
<source>Update packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!message" line="0" />
<source>Authentication is required to uninstall packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!description" line="0" />
<source>Uninstall packages</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!message" line="0" />
<source>Authentication is required to install packages from local files</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!description" line="0" />
<source>Install packages from local files</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!message" line="0" />
<source>Authentication is required to prune package cache</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!description" line="0" />
<source>Prune package cache</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!message" line="0" />
<source>Authentication is required to modify package manager configuration</source>
<translation type="unfinished" />
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!description" line="0" />
<source>Modify package manager configuration</source>
<translation type="unfinished" />
</message>
</context>
Expand Down
62 changes: 56 additions & 6 deletions misc/share/polkit-1/translations/policy_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,64 @@
<context>
<name>policy</name>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!message" line="0" />
<source>Authentication is required to perform this action</source>
<translation>Authentication is required to perform this action</translation>
<location filename="org.deepin.linglong.PackageManager1.install!message" line="0" />
<source>Authentication is required to install packages</source>
<translation>Authentication is required to install packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!description" line="0" />
<source>Check Authentication</source>
<translation>Check Authentication</translation>
<location filename="org.deepin.linglong.PackageManager1.install!description" line="0" />
<source>Install packages</source>
<translation>Install packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!message" line="0" />
<source>Authentication is required to update packages</source>
<translation>Authentication is required to update packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!description" line="0" />
<source>Update packages</source>
<translation>Update packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!message" line="0" />
<source>Authentication is required to uninstall packages</source>
<translation>Authentication is required to uninstall packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!description" line="0" />
<source>Uninstall packages</source>
<translation>Uninstall packages</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!message" line="0" />
<source>Authentication is required to install packages from local files</source>
<translation>Authentication is required to install packages from local files</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!description" line="0" />
<source>Install packages from local files</source>
<translation>Install packages from local files</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!message" line="0" />
<source>Authentication is required to prune package cache</source>
<translation>Authentication is required to prune package cache</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!description" line="0" />
<source>Prune package cache</source>
<translation>Prune package cache</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!message" line="0" />
<source>Authentication is required to modify package manager configuration</source>
<translation>Authentication is required to modify package manager configuration</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!description" line="0" />
<source>Modify package manager configuration</source>
<translation>Modify package manager configuration</translation>
</message>
</context>
</TS>
62 changes: 56 additions & 6 deletions misc/share/polkit-1/translations/policy_pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,64 @@
<context>
<name>policy</name>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!message" line="0"/>
<source>Authentication is required to perform this action</source>
<translation>A autenticação é necessária para executar esta ação</translation>
<location filename="org.deepin.linglong.PackageManager1.install!message" line="0"/>
<source>Authentication is required to install packages</source>
<translation>É necessário autenticar-se para instalar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!description" line="0"/>
<source>Check Authentication</source>
<translation>Verificar autenticação</translation>
<location filename="org.deepin.linglong.PackageManager1.install!description" line="0"/>
<source>Install packages</source>
<translation>Instalar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!message" line="0"/>
<source>Authentication is required to update packages</source>
<translation>É necessário autenticar-se para atualizar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!description" line="0"/>
<source>Update packages</source>
<translation>Atualizar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!message" line="0"/>
<source>Authentication is required to uninstall packages</source>
<translation>É necessário autenticar-se para desinstalar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!description" line="0"/>
<source>Uninstall packages</source>
<translation>Desinstalar pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!message" line="0"/>
<source>Authentication is required to install packages from local files</source>
<translation>É necessário autenticar-se para instalar pacotes a partir de arquivos locais</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!description" line="0"/>
<source>Install packages from local files</source>
<translation>Instalar pacotes a partir de arquivos locais</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!message" line="0"/>
<source>Authentication is required to prune package cache</source>
<translation>É necessário autenticar-se para limpar o cache de pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!description" line="0"/>
<source>Prune package cache</source>
<translation>Limpar cache de pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!message" line="0"/>
<source>Authentication is required to modify package manager configuration</source>
<translation>É necessário autenticar-se para modificar a configuração do gerenciador de pacotes</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!description" line="0"/>
<source>Modify package manager configuration</source>
<translation>Alterar configuração do gerenciador de pacotes</translation>
</message>
</context>
</TS>
62 changes: 56 additions & 6 deletions misc/share/polkit-1/translations/policy_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,64 @@
<context>
<name>policy</name>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!message" line="0"/>
<source>Authentication is required to perform this action</source>
<translation>当前操作需要密码认证</translation>
<location filename="org.deepin.linglong.PackageManager1.install!message" line="0"/>
<source>Authentication is required to install packages</source>
<translation>安装软件包需要认证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.checkAuthentication!description" line="0"/>
<source>Check Authentication</source>
<translation>检查认证</translation>
<location filename="org.deepin.linglong.PackageManager1.install!description" line="0"/>
<source>Install packages</source>
<translation>安装软件包</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!message" line="0"/>
<source>Authentication is required to update packages</source>
<translation>更新软件包需要认证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.update!description" line="0"/>
<source>Update packages</source>
<translation>更新软件包</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!message" line="0"/>
<source>Authentication is required to uninstall packages</source>
<translation>卸载软件包需要认证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.uninstall!description" line="0"/>
<source>Uninstall packages</source>
<translation>卸载软件包</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!message" line="0"/>
<source>Authentication is required to install packages from local files</source>
<translation>从本地文件安装软件包需要进行身份验证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.install-from-file!description" line="0"/>
<source>Install packages from local files</source>
<translation>从本地文件安装软件包</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!message" line="0"/>
<source>Authentication is required to prune package cache</source>
<translation>清理软件包缓存需要认证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.prune!description" line="0"/>
<source>Prune package cache</source>
<translation>清理软件包缓存</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!message" line="0"/>
<source>Authentication is required to modify package manager configuration</source>
<translation>修改软件包管理器配置需要认证</translation>
</message>
<message>
<location filename="org.deepin.linglong.PackageManager1.set-configuration!description" line="0"/>
<source>Modify package manager configuration</source>
<translation>修改软件包管理器配置</translation>
</message>
</context>
</TS>
Loading
Loading