Remove unused code

This commit is contained in:
Kovid Goyal 2024-08-26 19:13:09 +05:30
parent 96f2861c2a
commit 9843b5c210
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 14 additions and 29 deletions

View file

@ -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);

View file

@ -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, ""},

View file

@ -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); \

View file

@ -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