【问题标题】:How can I allow the child process to create nested user namespace?如何允许子进程创建嵌套的用户命名空间?
【发布时间】:2020-01-18 13:32:35
【问题描述】:

我使用以下代码在新的用户命名空间中创建子进程:

pid_t child = syscall (SYS_clone, SIGCHLD | CLONE_NEWNS | CLONE_NEWUSER, NULL, NULL, NULL);

在父进程中,我写了uid_mapgid_map,并将当前的uid和pid映射到自己。

在子进程中我会调用execvp来启动一个新进程,该进程可能会调用unshare并带有CLONE_NEWUSER标志,在新的用户命名空间中是不允许的。

我的问题是,是否可以允许unshareexecvp启动的进程进行操作?

我按照 user_namespace 手册页中的示例使用 pipe 确保在调用 execvp 之前写入 uid_mapgid_map

【问题讨论】:

    标签: c linux kernel


    【解决方案1】:

    我猜你的映射不正确。来自man 2 unshare,看起来你正在打这个:

           EPERM  CLONE_NEWUSER was specified in flags, but either  the  effective
                  user  ID or the effective group ID of the caller does not have a
                  mapping in the parent namespace (see user_namespaces(7)).
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-30
      • 2019-08-30
      • 1970-01-01
      • 2015-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多