Skip to content

-printf %m and -ls drop setuid/setgid/sticky bits and the file type #890

Done

Description

@youdie006

Two places format permissions differently from GNU find 4.9.0:

-printf %m masks the mode with 0o777 and pads it to three digits:

mode GNU uutils
4755 4755 755
1777 (e.g. /tmp) 1777 777
044 44 044
000 0 000

So find / -perm -4000 -printf '%m %p\n' hides the setuid bit it was searching for.

-ls has its own permission formatter that only knows directories and regular files and ignores the setuid, setgid and sticky bits:

file GNU uutils
/tmp drwxrwxrwt drwxrwxrwx
4755 file -rwsr-xr-x -rwxr-xr-x
symlink lrwxrwxrwx ?rwxrwxrwx
/dev/null crw-rw-rw- ?rw-rw-rw-

-printf %M already uses uucore::fs::display_permissions and matches GNU, so -ls could reuse it. I have small fixes for both and will open them as separate PRs.

Activity

  1. sylvestre commented on Nov 27, 2026

    @sylvestre
    SponsorContributor

    Fixed by #891 (-printf %m) and #892 (-ls)

    Results with main 51ddbfe:

    $ mkdir d && touch d/f && chmod 4755 d/f && chmod 1777 d && ln -s f d/l
    $ find d -printf '%m %p\n'
    1777 d
    777 d/l
    4755 d/f
    $ find d -ls | awk '{print $3, $11}'
    drwxrwxrwt d
    lrwxrwxrwx d/l
    -rwsr-xr-x d/f
    

    Same as GNU find 4.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions