From: Cecilia Lau Date: Tue, 22 Apr 2025 22:12:28 +0000 (-0400) Subject: libcephfs / pybind: use uid_t and gid_t instead of int X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=65328aca31f2f5038cb602148120b9427370ed4f;p=ceph.git libcephfs / pybind: use uid_t and gid_t instead of int allows for setting uid/gid over 2^31-1 through libcephfs Fixes: https://tracker.ceph.com/issues/71015 Signed-off-by: Cecilia Lau --- diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index 0a08e89566cc..b75f279a0d9d 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -1148,7 +1148,7 @@ int ceph_chmodat(struct ceph_mount_info *cmount, int dirfd, const char *relpath, * @param gid the group id to set on the file/directory. * @returns 0 on success or negative error code on failure. */ -int ceph_chown(struct ceph_mount_info *cmount, const char *path, int uid, int gid); +int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid); /** * Change the ownership of a file from an open file descriptor. @@ -1159,7 +1159,7 @@ int ceph_chown(struct ceph_mount_info *cmount, const char *path, int uid, int gi * @param gid the group id to set on the file/directory. * @returns 0 on success or negative error code on failure. */ -int ceph_fchown(struct ceph_mount_info *cmount, int fd, int uid, int gid); +int ceph_fchown(struct ceph_mount_info *cmount, int fd, uid_t uid, gid_t gid); /** * Change the ownership of a file/directory, don't follow symlinks. @@ -1170,7 +1170,7 @@ int ceph_fchown(struct ceph_mount_info *cmount, int fd, int uid, int gid); * @param gid the group id to set on the file/directory. * @returns 0 on success or negative error code on failure. */ -int ceph_lchown(struct ceph_mount_info *cmount, const char *path, int uid, int gid); +int ceph_lchown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid); /** * Change the ownership of a file/directory releative to a file descriptor. diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 3c3cfe4d35af..767abb5c833a 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -1314,21 +1314,21 @@ extern "C" int ceph_chmodat(struct ceph_mount_info *cmount, int dirfd, const cha } extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path, - int uid, int gid) + uid_t uid, gid_t gid) { if (!cmount->is_mounted()) return -ENOTCONN; return cmount->get_client()->chown(path, uid, gid, cmount->default_perms); } extern "C" int ceph_fchown(struct ceph_mount_info *cmount, int fd, - int uid, int gid) + uid_t uid, gid_t gid) { if (!cmount->is_mounted()) return -ENOTCONN; return cmount->get_client()->fchown(fd, uid, gid, cmount->default_perms); } extern "C" int ceph_lchown(struct ceph_mount_info *cmount, const char *path, - int uid, int gid) + uid_t uid, gid_t gid) { if (!cmount->is_mounted()) return -ENOTCONN; diff --git a/src/pybind/cephfs/cephfs.pyx b/src/pybind/cephfs/cephfs.pyx index 9a4b5c778b36..fb81732bea98 100644 --- a/src/pybind/cephfs/cephfs.pyx +++ b/src/pybind/cephfs/cephfs.pyx @@ -1293,8 +1293,8 @@ cdef class LibCephFS(object): cdef: char* _path = path - int _uid = uid - int _gid = gid + uid_t _uid = uid + gid_t _gid = gid if follow_symlink: with nogil: ret = ceph_chown(self.cluster, _path, _uid, _gid) @@ -1332,8 +1332,8 @@ cdef class LibCephFS(object): cdef: int _fd = fd - int _uid = uid - int _gid = gid + uid_t _uid = uid + gid_t _gid = gid with nogil: ret = ceph_fchown(self.cluster, _fd, _uid, _gid) if ret < 0: diff --git a/src/pybind/cephfs/types.pxd b/src/pybind/cephfs/types.pxd index d20ea87dc9cf..cbe31cbf4ba8 100644 --- a/src/pybind/cephfs/types.pxd +++ b/src/pybind/cephfs/types.pxd @@ -12,6 +12,8 @@ cdef extern from "": cdef extern from "sys/types.h": ctypedef unsigned long mode_t ctypedef unsigned long dev_t + ctypedef unsigned int uid_t; + ctypedef unsigned int gid_t; cdef extern from "sys/time.h": cdef struct timeval: