hzxie / voj

A cross-platform online judge system based on Spring MVC framework and ActiveMQ.

Home Page:https://verwandlung.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KeyError: 'getpwuid(): uid not found: 1536' in Python 2

nicozhang opened this issue · comments

File "/usr/lib64/python2.7/posixpath.py", line 269, in expanduser
userhome = pwd.getpwuid(os.getuid()).pw_dir
KeyError: 'getpwuid(): uid not found: 1536'

查了下 C++代码,在启动子进程是,会设置 UID,但系统并没有该用户

void setupRunUser() {
while ( setgid(1536) != 0 ) {
std::cout << "[WARN] setgid(1536) failed." << std::endl;
sleep(1);
}
while ( setuid(1536) != 0 ) {
std::cout << "[WARN] setuid(1536) failed." << std::endl;
sleep(1);
}
while ( setresuid(1536, 1536, 1536) != 0 ) {
std::cout << "[WARN] setresuid(1536, 1536, 1536) failed." << std::endl;
sleep(1);
}
}

手动添加用户可以解决:
useradd -u 1536 -M compile

这么设计是为了获取用户空间的内存数据么? 文档里也没写,必须创建该用户。
Python2 不行,Python3 可以。

The non-existing user 1536 is used to prevent the submitter from doing any system calls.

What's your submitted code?
BTW, the Python Software Foundation declared Python 2 End of Life (EOL) on January 1, 2020, and ended support. Please use Python 3 instead.