小编Sve*_*ven的帖子

取消共享后的grantpt报告错误

我有一个小程序,试图在取消共享后创建一个伪终端.输出是:

uid before unshare:5000
uid after unshare:0
Grant pt Error: : Permission denied
Run Code Online (Sandbox Code Playgroud)

代码:

#define _GNU_SOURCE

#include <sys/mount.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sched.h>

void set_uid_map(pid_t pid, int inside_id, int outside_id, int length) {
    char path[256];
    sprintf(path, "/proc/%d/uid_map", getpid());
    FILE* uid_map = fopen(path, "w");
    fprintf(uid_map, "%d %d %d", inside_id, outside_id, length);
    fclose(uid_map);
}
void set_gid_map(pid_t pid, int inside_id, int outside_id, int length) {
    char path[256];
    sprintf(path, "/proc/%d/gid_map", getpid());
    FILE* gid_map = fopen(path, "w");
    fprintf(gid_map, …
Run Code Online (Sandbox Code Playgroud)

c linux linux-namespaces

10
推荐指数
1
解决办法
283
查看次数

标签 统计

c ×1

linux ×1

linux-namespaces ×1