Coder Social home page Coder Social logo

patchelf breaks hardlinks about patchelf HOT 6 CLOSED

nixos avatar nixos commented on June 15, 2024
patchelf breaks hardlinks

from patchelf.

Comments (6)

darealshinji avatar darealshinji commented on June 15, 2024

patchelf writes the changes in a new temporary file and replaces the original with the new one, that's why this happens.
https://github.com/NixOS/patchelf/blob/master/src/patchelf.cc#L378

from patchelf.

sjackman avatar sjackman commented on June 15, 2024

Breaking hardlinks is rather unexpected behaviour. Can writeFile be changed to write directly to the file, rather than through a temp file?

from patchelf.

darealshinji avatar darealshinji commented on June 15, 2024

I found the solution! This is what "static void writeFile()" should look like:

static void writeFile(string fileName, mode_t fileMode)
{
    int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY, 0700);
    if (fd == -1)
        error("open");

    if (write(fd, contents, fileSize) != fileSize)
        error("write");

    if (close(fd) != 0)
        error("close");
}

darealshinji@bed9cea

from patchelf.

sjackman avatar sjackman commented on June 15, 2024

Excellent! Thanks. I'll test it soon. Without O_CREAT you can remove , 0700 as it has no effect.

from patchelf.

sjackman avatar sjackman commented on June 15, 2024

@edolstra Can you please merge this patch from @darealshinji to fix this issue? Thanks!
darealshinji@bed9cea

from patchelf.

sjackman avatar sjackman commented on June 15, 2024

Great. Thanks. Will there be a new stable release that includes this fix?

from patchelf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.