diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index bbdfe1b73..2824679f3 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -1657,6 +1657,20 @@ add_peer(int peer, bool is_remote_control_peer) { return ans; } +static bool +getpeerid(int fd, uid_t *euid, gid_t *egid) { +#ifdef __linux__ + struct ucred cr; + socklen_t sz = sizeof(cr); + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &sz) != 0) return false; + *euid = cr.uid; *egid = cr.gid; +#else + if (getpeereid(fd, euid, egid) != 0) return false; +#endif + return true; +} + + static bool accept_peer(int listen_fd, bool shutting_down, bool is_remote_control_peer) { int peer = accept(listen_fd, NULL, NULL); diff --git a/kitty/data-types.c b/kitty/data-types.c index d61f2c3aa..65bf57ce3 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -360,29 +360,6 @@ locale_is_valid(PyObject *self UNUSED, PyObject *args) { Py_RETURN_TRUE; } -bool -getpeerid(int fd, uid_t *euid, gid_t *egid) { -#ifdef __linux__ - struct ucred cr; - socklen_t sz = sizeof(cr); - if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &sz) != 0) return false; - *euid = cr.uid; *egid = cr.gid; -#else - if (getpeereid(fd, euid, egid) != 0) return false; -#endif - return true; -} - -static PyObject* -py_getpeereid(PyObject *self UNUSED, PyObject *args) { - int fd; - if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; - uid_t euid = 0; gid_t egid = 0; - if (!getpeerid(fd, &euid, &egid)) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } - int u = euid, g = egid; - return Py_BuildValue("ii", u, g); -} - #include "docs_ref_map_generated.h" static PyObject* @@ -575,7 +552,6 @@ static PyMethodDef module_methods[] = { {"wcwidth", (PyCFunction)wcwidth_wrap, METH_O, ""}, {"expand_ansi_c_escapes", (PyCFunction)expand_ansi_c_escapes, METH_O, ""}, {"get_docs_ref_map", (PyCFunction)get_docs_ref_map, METH_NOARGS, ""}, - {"getpeereid", (PyCFunction)py_getpeereid, METH_VARARGS, ""}, {"wcswidth", (PyCFunction)wcswidth_std, METH_O, ""}, {"unicode_database_version", (PyCFunction)unicode_database_version, METH_NOARGS, ""}, {"open_tty", open_tty, METH_VARARGS, ""}, diff --git a/kitty/data-types.h b/kitty/data-types.h index 825a23841..a2db1f318 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -423,7 +423,6 @@ void play_canberra_sound(const char *which_sound, const char *event_id, bool is_ SPRITE_MAP_HANDLE alloc_sprite_map(unsigned int, unsigned int); SPRITE_MAP_HANDLE free_sprite_map(SPRITE_MAP_HANDLE); const char* get_hyperlink_for_id(const HYPERLINK_POOL_HANDLE, hyperlink_id_type id, bool only_url); -bool getpeerid(int fd, uid_t *euid, gid_t *egid); #define memset_array(array, val, count) if ((count) > 0) { \ (array)[0] = (val); \ diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index dedbfc5dd..bfd5c7e19 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1590,10 +1590,6 @@ def remove_signal_handlers() -> None: pass -def getpeereid(fd: int) -> Tuple[int, int]: - pass - - X25519: int SHA1_HASH: int SHA224_HASH: int