5 thoughts on “Speed traps with chmod”

  1. Thanks for inter­est­ing reading.

    You have small typo:
    “When you spec­ify g+w, it means to remove the write access for the group…” 

    It should be “g‑w”

  2. The exam­ples are just exam­ples. I did not intend to give the same exam­ples for absolute and rel­a­tive nota­tion (which is impos­si­ble with­out show­ing a file/directory with spe­cif­ic access rights). g+w adds group write access no mat­ter what oth­er set­tings are there, where­as the absolute exam­ples do not keep the remain­ing access rights. Please do not com­pare them.

  3. Cur­rent chmod com­mand imple­men­ta­tions have already read the stat struc­ture before set­ting the new per­mis­sions (checked on FreeB­SD and Solaris source), so there is real­ly no ben­e­fit for absolute mode over sym­bol­ic mode.

    Even absolute mode is not 100% absolute. For non-regular files the inter­pre­ta­tion is imple­men­ta­tion depen­dent. Quot­ing Solaris man page for chmod(1):
    For direc­to­ries, the set­gid bit can­not be set (or cleared)
    in absolute mode; it must be set (or cleared) in symbolic
    mode using g+s (or g‑s).

    Also the inode should already be in the inode cache. Even find needs the stat struc­ture (-type f).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.