From: Rishabh Dave Date: Tue, 12 Aug 2025 16:41:23 +0000 (+0530) Subject: cephfs.pyx: handle when UID/GID passed to chown() is -1 X-Git-Tag: testing/wip-vshankar-testing-20250821.112602-debug~5^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=325ae1163eb30b64957ced1eae04e2c24428ccfa;p=ceph-ci.git cephfs.pyx: handle when UID/GID passed to chown() is -1 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 --- diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index fb81732bea9..4410015a015 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -1293,8 +1293,10 @@ cdef class LibCephFS(object): 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) @@ -1332,8 +1334,10 @@ cdef class LibCephFS(object): 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: