相关疑难解决方法(0)

允许任何用户在特定网络命名空间中运行程序的安全方式

我有一个连接到我的服务器的蜂窝调制解调器,我想用它作为固定电话断线时获取通知电子邮件的一种方式。

为了很好地分离正常的网络访问和这种特殊的蜂窝调制解调器访问,我创建了一个网络命名空间并在那里创建了网络设备作为唯一的设备。要让程序使用蜂窝调制解调器,我只需使用ip netns exec.

问题是我想允许任何用户在命名空间中运行他们想要的任何程序,但netns exec需要 root。我的解决方案如下:

/usr/local/sbin/_oob_shim:

#!/bin/sh
cmd_line="$@"
/bin/ip netns exec oob \
    /usr/bin/sudo -u "#$SUDO_UID" -g "#$SUDO_GID" /bin/sh -c "$cmd_line"
Run Code Online (Sandbox Code Playgroud)

/etc/sudoers:

ALL ALL=NOPASSWD: /usr/local/sbin/_oob_shim
Run Code Online (Sandbox Code Playgroud)

我认为在尚未成为 root 或知道 root 密码的情况下运行 shim 的唯一方法是通过 sudo,我可以相信 sudo 将 $SUDO_UID 和 $SUDO_GID 设置为正确的值。

我是否让自己面临重大风险?或者,我应该说我错过了任何明显的警告吗?

networking sudo network-namespaces

9
推荐指数
1
解决办法
2093
查看次数

在不同的网络中使用网络管理器

In continuation of my last question about using netns as a relugar user, I'm now looking for a way to open VPN tunnels as a regular user.

So I naturally thought about network-manager. Any user can use it for any VPN.

I could just allow opening VPN tunnels by editing the sudoer file, but I really would rather not do that.

So I'm wondering how to use it in different network namespaces. According to this source, network-manager might …

users networkmanager vpn

6
推荐指数
1
解决办法
1335
查看次数