From: Luca Di Maio Date: Wed, 16 Apr 2025 21:20:04 +0000 (+0200) Subject: xfs_protofile: fix permission octet when suid/guid is set X-Git-Tag: v6.15.0~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b66b1ab513f90ed7ddd59b167788e1567146dfa;p=thirdparty%2Fxfsprogs-dev.git xfs_protofile: fix permission octet when suid/guid is set When encountering suid or sgid files, we already set the `u` or `g` property in the prototype file. Given that proto.c only supports three numbers for permissions, we need to remove the redundant information from the permission, else it was incorrectly parsed. Co-authored-by: Luca Di Maio Co-authored-by: "Darrick J. Wong" Reviewed-by: "Darrick J. Wong" Signed-off-by: Luca Di Maio [aalbersh: 68 chars limit and removed patch review revisions] --- diff --git a/mkfs/xfs_protofile.py.in b/mkfs/xfs_protofile.py.in index 040454da..40d06ddb 100644 --- a/mkfs/xfs_protofile.py.in +++ b/mkfs/xfs_protofile.py.in @@ -44,7 +44,9 @@ def stat_to_str(statbuf): else: sgid = '-' - perms = stat.S_IMODE(statbuf.st_mode) + # We already register suid in the proto string, no need + # to also represent it into the octet + perms = stat.S_IMODE(statbuf.st_mode) & 0o777 return '%s%s%s%03o %d %d' % (type, suid, sgid, perms, statbuf.st_uid, \ statbuf.st_gid)