【发布时间】:2017-11-21 22:00:17
【问题描述】:
作为 jupyterhub 用户,我正在尝试以 mgrs 组中的用户身份运行命令。
$ cat /etc/group
mgrs:x:1011:cody,admin
$ cat /etc/sudoers
jupyterhub ALL=(%mgrs) NOPASSWD:/boot/tp/python3/bin/sudospawner
$ whoami
jupyterhub
$ sudo -u cody /boot/tp/python3/bin/sudospawner
Password:
此 sudoers 行的示例来自 https://github.com/jupyterhub/jupyterhub/wiki/Using-sudo-to-run-JupyterHub-without-root-privileges
【问题讨论】:
-
你确定这有效吗?看起来
cody和admin属于mgrs组。这在 sudoers 世界中可能是合法的,但如果您尝试运行的命令只能由mgrs的成员执行并且不属于jupyterhub,那么我将开始寻找。 -
我将可执行文件的权限设置为777进行测试。
-
这消除了这个问题。我猜你有理由不想在文件上为组@987654329@ 使用
setgid,所以它总是以mgrs运行? -
我想以特定用户的身份运行命令。在这种情况下为 jupyterhub 以便用户可以读取彼此的文件。我希望 jupyterhub 用户能够以 mgrs 组中的任何用户身份运行 sudospawner。对不起,如果我误解了你。
-
在这种情况下,您应该能够设置文件所有权
sudo chown jupyterhub:mgrs /boot/tp/python3/bin/sudospawner,将UID设置为jupyterhub,将GID设置为mgrs。然后制作文件setuid,例如chmod 4750 /boot/tp/python3/bin/sudospawner这样mgrs的所有成员都可以运行该文件,它将以用户jupyterhub的身份运行。
标签: linux