-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
Description
出题人在打包 docker image 时把 data/
目录用 COPY 加入了 image 中,并且设置目录拥有者为 judger,目录的权限是 766。
在 online_judge.py
中预期使用 os.makedir()
来设置 data
目录的权限为 700,但是 os.makedir()
不改变已存在的目录的权限,见 python 3.11 文档 os.makedirs。所以 runner 用户可以读取 data
中的内容。
而 static.out
是其他用户可读的。所以有下面的非预期解。
#include <stdio.h>
#include <stdlib.h>
// static_data_path
char *sdata_input_path = "./data/static.in";
char *sdata_output_path = "./data/static.out";
const int LEN = 2048;
int main() {
char *lines[2];
size_t ns[2];
FILE *fp = fopen(sdata_output_path, "r");
if (fp == NULL) {
printf("failed to read static output");
exit(1);
}
// read and show the 2 prime numbers.
getline(&lines[0], &ns[0], fp);
printf("%s", lines[0]);
getline(&lines[1], &ns[0], fp);
printf("%s", lines[1]);
free(lines[0]);
free(lines[1]);
fclose(fp);
return 0;
}