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
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.3
VERSION 1.13.4
DESCRIPTION "a container based application package manager for Linux desktop"
HOMEPAGE_URL "https://github.com/OpenAtom-Linyaps/linyaps"
LANGUAGES CXX C)
Expand Down
14 changes: 12 additions & 2 deletions libs/linglong/src/linglong/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,8 +1787,18 @@ int Cli::content(const ContentOptions &options)
LogE("failed to check symlink {}: {}", file.c_str(), ec.message());
}

// Dont't mapping the file under /home
if (auto tmp = target.string(); tmp.rfind("/home/", 0) == 0) {
auto *homePath = ::getenv("HOME");
if (homePath == nullptr || homePath[0] == '\0') {
LogE("failed to get HOME env");
return target;
}

// Don't map files under the user's home directory
auto homeStr = std::string(homePath);
if (homeStr.back() != '/') {
homeStr.push_back('/');
}
if (auto tmp = target.string(); tmp.rfind(homeStr, 0) == 0) {
return target;
}
Comment on lines +1790 to 1803

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.

high

If the HOME environment variable is not set or is empty, returning target early from Cli::mappingFile will completely bypass the file mapping logic (which maps files to /run/host/rootfs/...). This means that in environments where HOME is not defined (such as some systemd services, cron jobs, or restricted sandboxes), absolute paths will not be mapped at all, breaking core functionality.

Instead of returning target early when HOME is unavailable, we should simply skip the home directory check and proceed with the file mapping.

    auto *homePath = ::getenv("HOME");
    if (homePath != nullptr && homePath[0] != '\0') {
        // Don't map files under the user's home directory
        auto homeStr = std::string(homePath);
        if (homeStr.back() != '/') {
            homeStr.push_back('/');
        }
        if (auto tmp = target.string(); tmp.rfind(homeStr, 0) == 0) {
            return target;
        }
    }


Expand Down
Loading