• pelya
    link
    fedilink
    138 days ago

    The ingenuity of this command is that /dev/nul does not exist, the correct path is /dev/null, however the command executes without error and creates a symlink to a non-existing path.
    The only thing missing is sudo.

      • Korthrun
        link
        fedilink
        3
        edit-2
        8 days ago

        My dumbass can only come up with three:

        1. You are already root (ok, fine)
        2. You have made /dev/ writable by non-privileged users
        3. Your non-privileged user already owns the symlink /dev/nul. Which “ok, fine”, but also the point of command would have to be to functionally do nothing other than print out the error ln: failed to create symbolic link '/dev/nul': File exists

        I would love to understand the use case behind #2. I am also curious to see even 7 more cases, let alone your figurative million.

        In regards to #3 even if the behaviour of ln was to replace a symlink if it already existed, it’ll probably have to unlink() the existing symlink, which I’m pretty sure is gonna get you a permission denied error on any /dev filesystem with sane permissions.

        • Korthrun
          link
          fedilink
          1
          edit-2
          8 days ago

          Follow up, tested and confirmed #3:

          [korthrun@host]$ ls -l /dev/korth
          .rw-r--r-- korthrun wheel 0 B Wed Jun 11 17:11:03 2025 /dev/korth
          [korthrun@host]$ rm /dev/korth
          rm: cannot remove '/dev/korth': Permission denied
          
        • @nibbler@discuss.tchncs.de
          link
          fedilink
          18 days ago

          ln could be +s

          the kernel could have been modified

          I’m sure there is some way if using capabilities

          you don’t need to be ‘root’, uid 0 is enough :)