]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_protofile: fix permission octet when suid/guid is set
authorLuca Di Maio <luca.dimaio1@gmail.com>
Wed, 16 Apr 2025 21:20:04 +0000 (23:20 +0200)
committerAndrey Albershteyn <aalbersh@kernel.org>
Wed, 28 May 2025 10:12:16 +0000 (12:12 +0200)
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 <luca.dimaio1@gmail.com>
Co-authored-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
[aalbersh: 68 chars limit and removed patch review revisions]

mkfs/xfs_protofile.py.in

index 040454da1da4df06f8bf20aeed0023c4b308a637..40d06ddb44aa300b6801ec451ffe915e288969f6 100644 (file)
@@ -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)