我正试图从无头的VirtualBox客户上运行一个web服务器。VirtualBox需要绑定到端口80,但唯一的方法是以根用户身份运行VirtualBox。为了解决这个问题,我尝试使用setcap,但是VirtualBox进程是SUID,这意味着它删除了所有的用户特权,包括setcap设置。
客人不能搭桥,必须使用NAT。不幸的是,用iptables重新路由流量或以root方式运行VirtualBox也不是一个选项,但如果没有其他选项,我可能不得不解决。
编辑:我的kern.log也证实了这一点:
warning: /usr/lib/virtualbox/VBoxHeadless' has both setuid-root and effective capabilities. Therefore not raising all capabilities.编辑:功能手册页也涉及到以下内容:
If the effective user ID is changed from 0 to nonzero, then all capabilities are cleared from the effective set.
有什么想法吗?
发布于 2013-01-09 09:05:50
我已经找到了问题的根源。SUID根程序实际上可以绑定到特权端口,但是VirtualBox在它运行后不久就特别地降低了SUID特权,这使得在不进行认真修改的情况下不可能给它适当的权限。SUID实际上与setcap兼容,如功能手册页所概述的那样。从源重新编译VirtualBox是唯一的选择。
编辑:在生成export VBOX_HARD_CAP_NET_BIND_SERVICE=1之前设置VirtualBox启用此功能。
编辑:通过从SVN编译一个强化的VirtualBox构建,我终于让它完全工作了:
# Prerequisites:
# - Satisfy all dependencies listed in the VirtualBox build instructions
# - You may need to install additional packages:
# texlive-latex-extra
# yasm
export VBOX_HARD_CAP_NET_BIND_SERVICE=1
cd ~
# Download VirtualBox source code from SVN
svn co http://www.virtualbox.org/svn/vbox/trunk vbox
cd vbox
# Configure build. I encountered Java errors so I disabled Java support
./configure --disable-java
source ./env.sh
kmk all
# Build kernel module. The below path may vary!
cd ~/vbox/out/linux.amd64/release/bin/src
make
sudo make install
# Build hardened executable
cd ~/vbox/src/VBox
kmk packing
# Install VirtualBox
cd ~/vbox/out/linux.amd64/release/bin
sudo ./VirtualBox-4.2.51_OSE-r44262.run install上面的一些步骤可能需要创建符号链接。请按照Linux构建指令查询详细信息。
https://serverfault.com/questions/463206
复制相似问题