When chown() in libcephfs call receives -1 as the value of UID/GID, it
is implicitly converted from signed integer to unsigned integeer but
CephFS cython instead of doing that errors out during complilation.
Therefore make this conversion explicitly to allow users to pass -1
(which they do to indicate that UID/GID value shouldn't be changed) and
also for sake of uniformity and consistency between between CephFS
cython and libcephfs interface.
Fixes: https://tracker.ceph.com/issues/72547
Introduced-by: 65328aca31f2f5038cb602148120b9427370ed4f
Signed-off-by: Rishabh Dave <ridave@redhat.com>
cdef:
char* _path = path
- uid_t _uid = uid
- gid_t _gid = gid
+ # Avoid "OverflowError: can't convert negative value to uid_t."
+ uid_t _uid = uid if uid >= 0 else -1
+ # Avoid "OverflowError: can't convert negative value to gid_t."
+ gid_t _gid = gid if gid >= 0 else -1
if follow_symlink:
with nogil:
ret = ceph_chown(self.cluster, _path, _uid, _gid)
cdef:
int _fd = fd
- uid_t _uid = uid
- gid_t _gid = gid
+ # Avoid "OverflowError: can't convert negative value to uid_t."
+ uid_t _uid = uid if uid >= 0 else -1
+ # Avoid "OverflowError: can't convert negative value to gid_t."
+ gid_t _gid = gid if gid >= 0 else -1
with nogil:
ret = ceph_fchown(self.cluster, _fd, _uid, _gid)
if ret < 0: