Coder Social home page Coder Social logo

Comments (2)

imlk0 avatar imlk0 commented on July 29, 2024 1

Fixed in commit 6db9b17

from proot-rs.

imlk0 avatar imlk0 commented on July 29, 2024

Document the steps to solve this problem:

  • The expected behavior:

    image

    image

    image

    image

  • Causes of this issue:

    The reason is similar to the one of the previous issue.

    When translating a path, proot-rs needs to create a new path by iterating over the components in the path (with Path::components() ). However, the trailing slash is not shown in the results of Path::components(), with is a flaw in the implementation of the rust standard library.
    rust-lang/rust#29008 (comment)

  • According to POSIX

    A pathname that contains at least one non- character and that ends with one or more trailing characters shall not be resolved successfully unless the last pathname component before the trailing characters names an existing directory or a directory entry that is to be created for a directory immediately after the pathname is resolved. Interfaces using pathname resolution may specify additional constraints1 when a pathname that does not name an existing directory contains at least one non- character and contains one or more trailing characters.
    If a symbolic link is encountered during pathname resolution, the behavior shall depend on whether the pathname component is at the end of the pathname and on the function being performed. If all of the following are true, then pathname resolution is complete:
    - This is the last pathname component of the pathname.
    - The pathname has no trailing .
    - The function is required to act on the symbolic link itself, or certain arguments direct that the function act on the symbolic link itself.

  • Something maybe helpful: https://elixir.bootlin.com/linux/latest/source/fs/namei.c#L97

      ```rust
      /* [Feb-Apr 2000 AV] Complete rewrite. Rules for symlinks:
       *	inside the path - always follow.
       *	in the last component in creation/removal/renaming - never follow.
       *	if LOOKUP_FOLLOW passed - follow.
       *	if the pathname has trailing slashes - follow.
       *	otherwise - don't follow.
       * (applied in that order).
      */
      ```
    
  • Way to fix:

    • Extend PathBuf to add two functions:
      • fn with_trailing_slash(&self) -> bool;: Check if this path contains trailing slash.
      • try_add_trailing_slash(&mut self);: Add a trailing slash ("/") to PathBuf.
    • In path translation function translate_absolute_path():
      • Add a appropriate slash to the end of translated path, so that trailing slash will not be eaten by proot-rs.
    • In enter() function of each path related syscalls:
      • Add trailing slash as a consideration for whether to follow the last component

    image

from proot-rs.

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.