core: change uv_get_password uid/gid to unsigned (#3476)
Added in https://github.com/libuv/libuv/pull/742, these values are typically defined as unsigned (since Linux 2.4). Only -1 is special, representing an invalid id (e.g. see setreuid).
This commit is contained in:
parent
c2a345fa67
commit
f3e0bffcb1
@ -1133,8 +1133,8 @@ struct uv_interface_address_s {
|
||||
|
||||
struct uv_passwd_s {
|
||||
char* username;
|
||||
long uid;
|
||||
long gid;
|
||||
unsigned long uid;
|
||||
unsigned long gid;
|
||||
char* shell;
|
||||
char* homedir;
|
||||
};
|
||||
|
||||
@ -22,6 +22,10 @@
|
||||
#include "uv.h"
|
||||
#include "task.h"
|
||||
#include <string.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
TEST_IMPL(get_passwd) {
|
||||
/* TODO(gengjiawen): Fix test on QEMU. */
|
||||
@ -64,11 +68,15 @@ TEST_IMPL(get_passwd) {
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
ASSERT(pwd.uid == -1);
|
||||
ASSERT(pwd.gid == -1);
|
||||
ASSERT_EQ(pwd.uid, (unsigned)-1);
|
||||
ASSERT_EQ(pwd.gid, (unsigned)-1);
|
||||
#else
|
||||
ASSERT(pwd.uid >= 0);
|
||||
ASSERT(pwd.gid >= 0);
|
||||
ASSERT_NE(pwd.uid, (unsigned)-1);
|
||||
ASSERT_NE(pwd.gid, (unsigned)-1);
|
||||
ASSERT_EQ(pwd.uid, geteuid());
|
||||
if (pwd.uid != 0 && pwd.gid != getgid())
|
||||
/* This will be likely true, as only root could have changed it. */
|
||||
ASSERT_EQ(pwd.gid, getegid());
|
||||
#endif
|
||||
|
||||
/* Test uv_os_free_passwd() */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user