Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeef98a2 authored by Jiyong Park's avatar Jiyong Park Committed by Gerrit Code Review
Browse files

Merge "Make sure symlinks created by ueventd are correctly labeled" into main

parents 3fa729d1 ccce03d8
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -599,7 +599,22 @@ void DeviceHandler::HandleDevice(const std::string& action, const std::string& d
                PLOG(ERROR) << "Failed to create directory " << Dirname(link);
            }

            if (symlink(target.c_str(), link.c_str())) {
            // Create symlink and make sure it's correctly labeled
            std::string secontext;
            // Passing 0 for mode should work.
            if (SelabelLookupFileContext(link, 0, &secontext) && !secontext.empty()) {
                setfscreatecon(secontext.c_str());
            }

            int rc = symlink(target.c_str(), link.c_str());

            if (!secontext.empty()) {
                int save_errno = errno;
                setfscreatecon(nullptr);
                errno = save_errno;
            }

            if (rc < 0) {
                if (errno != EEXIST) {
                    PLOG(ERROR) << "Failed to symlink " << devpath << " to " << link;
                } else if (std::string link_path;