Backport main branch improvements (#658)

* Add sys_ prefix to unwrapped system calls
* This change also implements getlogin() and getlogin_r().
* Add getgroups and setgroups (#619)
* Fix getgroups / setgroups tests across platforms. See #619
* Change accept type to struct sockaddr * (#630)
* vista: use old strace path
This commit is contained in:
Gavin Hayes 2022-10-10 23:44:29 -04:00 committed by GitHub
parent 4381b3d925
commit f4ff1729d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
831 changed files with 1381 additions and 1822 deletions

View file

@ -325,6 +325,10 @@ static dontinline int LuaUnixGetid(lua_State *L, int f(void)) {
return ReturnInteger(L, f());
}
static dontinline int LuaUnixGetUnsignedid(lua_State *L, unsigned f(void)) {
return ReturnInteger(L, f());
}
// unix.getpid()
// └─→ pid:int
static int LuaUnixGetpid(lua_State *L) {
@ -340,25 +344,25 @@ static int LuaUnixGetppid(lua_State *L) {
// unix.getuid()
// └─→ uid:int
static int LuaUnixGetuid(lua_State *L) {
return LuaUnixGetid(L, getuid);
return LuaUnixGetUnsignedid(L, getuid);
}
// unix.getgid()
// └─→ gid:int
static int LuaUnixGetgid(lua_State *L) {
return LuaUnixGetid(L, getgid);
return LuaUnixGetUnsignedid(L, getgid);
}
// unix.geteuid()
// └─→ uid:int
static int LuaUnixGeteuid(lua_State *L) {
return LuaUnixGetid(L, geteuid);
return LuaUnixGetUnsignedid(L, geteuid);
}
// unix.getegid()
// └─→ gid:int
static int LuaUnixGetegid(lua_State *L) {
return LuaUnixGetid(L, getegid);
return LuaUnixGetUnsignedid(L, getegid);
}
// unix.umask(newmask:int)

View file

@ -43,7 +43,6 @@ void setgrent(void);
struct group *fgetgrent(struct FILE *);
int putgrent(const struct group *, struct FILE *);
int getgrouplist(const char *, gid_t, gid_t *, int *);
int setgroups(size_t, const int32_t *);
int initgroups(const char *, int32_t);
COSMOPOLITAN_C_END_

View file

@ -206,6 +206,8 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_fds_to_keep)
}
}
int sys_getdents(unsigned, void *, unsigned, long *);
/* Close all open file descriptors in the range from start_fd and higher
* Do not close any in the sorted py_fds_to_keep list.
*
@ -228,7 +230,7 @@ _close_open_fds_safe(int start_fd, PyObject* py_fds_to_keep)
struct dirent *entry;
int fd, dir, bytes, offset;
if ((dir = _Py_open_noraise(FD_DIR, O_RDONLY|O_DIRECTORY)) != -1) {
while ((bytes = getdents(dir, buffer, sizeof(buffer), 0)) > 0) {
while ((bytes = sys_getdents(dir, buffer, sizeof(buffer), 0)) > 0) {
for (offset = 0; offset < bytes; offset += entry->d_reclen) {
entry = (struct dirent *)(buffer + offset);
if ((fd = _pos_int_from_ascii(entry->d_name)) < 0)

View file

@ -229,9 +229,9 @@
/* Define to 1 if you have the 'lockf' function and the F_LOCK macro. */
/* #undef HAVE_LOCKF */
#define HAVE_DEVICE_MACROS 1
#define HAVE_MAKEDEV 1
#define HAVE_MKDIRAT 1
/* #define HAVE_DEVICE_MACROS 1 */
#define HAVE_MAKEDEV 1
#define HAVE_MKDIRAT 1
#define HAVE_MBRTOWC 1
#define HAVE_MEMMOVE 1
@ -241,6 +241,11 @@
/* #undef HAVE_SEM_OPEN */
/* #undef HAVE_SEM_TIMEDWAIT */
/* #undef HAVE_SEM_UNLINK */
/* #define HAVE_MKNOD 1 */
/* #define HAVE_MKNODAT 1 */
/* #define HAVE_MKFIFO 1 */
/* #define HAVE_MKFIFOAT 1 */
/* #define HAVE_SETHOSTNAME 1 */
#define HAVE_DIRENT_H 1
#define HAVE_GETPPID 1
@ -248,10 +253,6 @@
#define HAVE_LINKAT 1
#define HAVE_LSTAT 1
#define HAVE_LUTIMES 1
#define HAVE_MKFIFO 1
#define HAVE_MKFIFOAT 1
#define HAVE_MKNOD 1
#define HAVE_MKNODAT 1
#define HAVE_MKTIME 1
#define HAVE_MMAP 1
#define HAVE_NICE 1
@ -275,7 +276,6 @@
#define HAVE_SETEGID 1
#define HAVE_SETEUID 1
#define HAVE_SETGID 1
#define HAVE_SETHOSTNAME 1
#define HAVE_SETITIMER 1
#define HAVE_SETLOCALE 1
#define HAVE_SETPGID 1