linux 普通账户绑定1024以下端口
系统大全为您提供
一、昨天收到一个开放需求:
这个帐号是给开发人员使用的
乍看这个需求,貌似很简单,但其实里面涉及一些技术问题(在Linux上普通用户无法绑定1024以下的端口),
当时为了不耽误开放工作,给了一台测试机的root,现在回过头来解决改问题。
二、google得知,基本有两种解决方法:
1、常用的就是使用sudo给予普通用户一定的权限,不过这跟给root有什么区别,还得维护sudo。
2、debian系统下有一个小程序authbind,允许程序不使用root权限来绑定系统1024以下的特权端口,
在程序启动时必须调用authbind,authbind会调用一些环境变量,来允许你的程序绑定在特权端口。
Ubuntu 12.04安装authbind
apt-get install authbind
怎样使用authbind呢?通过配置文件区域来使用了,默认的配置文件区域在/etc/authbind目录下,里面有三个目录:byport、byaddr、byuid。
假如我们有个test账号,想运行一个程序绑定80端口
在byport目录下建立80文件:/etc/authbind/byport/80,设置test账户有80文件的使用权限,如果80文件可以被test访问,则绑定就是成功的,否则绑定就是失败的。
具体操作:
chmod 755 /etc/authbind/port/80
chown test.test /etc/authbind/port/80
在你要启动的命令前加上authbind --deep命令即可。
我们也可以直接在地址上绑定端口,在byaddr下建立ip:port文件,测试方法如上。
也可以在byuid目录下建立uid文件,只要你的test账号可以访问,否则绑定失败。
三、centos实现
由于authbind是基于debian的,所以在yum上找不到源,google也没有找到对应的rpm;
从github中发现:https://github.com/tootedom/authbind-centos-rpm
down下来,按照指示rpmbuild -v -bb --clean SPECS/authbind.spec出现两个问题:
1、路径错误
[root@stat authbind]# rpmbuild -v -bb --clean SPECS/authbind.spec
error: File /root/authbind/SOURCES/authbind_2.1.1.tar.gz: No such file or directory
2、没能生成build目录
[root@stat authbind]# rpmbuild -v -bb --clean SPECS/authbind.spec
Executing(%prep): /bin -e ar/tmp/rpm-tmp.6tbsn7
+ umask 022
+ cd /root/authbind/authbind/BUILD
ar/tmp/rpm-tmp.6tbsn7: line 26: cd: /root/authbind/authbind/BUILD: No such file or directory
error: Bad exit status from ar/tmp/rpm-tmp.6tbsn7 (%prep)
RPM build errors:
Bad exit status from ar/tmp/rpm-tmp.6tbsn7 (%prep)
对rpmbuild不熟,但发现SOURCES/authbind_2.1.1.tar.gz,解压后发现Makefile,直接安装成功!
[root@stat authbind-2.1.1]# make
cc -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/localb/authbindbauthbind.so.1"' -DHELPER='"/usr/localb/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o authbind.o authbind.c
cc -g authbind.o -o authbind
cc -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/localb/authbindbauthbind.so.1"' -DHELPER='"/usr/localb/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o helper.o helper.c
cc -g helper.o -o helper
cc -D_REENTRANT -g -O2 -Wall -Wwrite-strings -Wpointer-arith -Wimplicit -Wnested-externs -Wmissing-prototypes -Wstrict-prototypes -DMAJOR_VER='"1"' -DMINOR_VER='"0"' -DLIBAUTHBIND='"/usr/localb/authbindbauthbind.so.1"' -DHELPER='"/usr/localb/authbind/helper"' -DCONFIGDIR='"/etc/authbind"' -D_GNU_SOURCE -c -o libauthbind.o -fPIC libauthbind.c
ld -shared -soname libauthbind.so.1 -o libauthbind.so.1.0 libauthbind.o -ldl -lc
[root@stat authbind-2.1.1]#
[root@stat authbind-2.1.1]#
[root@stat authbind-2.1.1]# make install
install -o root -g root -m 755 -d /usr/localb/authbind /usr/local/man/man1 /usr/local/man/man8
install -o root -g root -m 755 -s authbind /usr/local/bin/.
install -o root -g root -m 644 libauthbind.so.1.0 /usr/localb/authbind/.
strip --strip-unneeded /usr/localb/authbindbauthbind.so.1.0
ln -sf libauthbind.so.1.0 /usr/localb/authbindbauthbind.so.1
install -o root -g root -m 755 -s helper /usr/localb/authbind/.
chmod u+s /usr/localb/authbind/helper
install -o root -g root -m 755 -d /etc/authbind
/etc/authbind/byport /etc/authbind/byaddr /etc/authbind/byuid
[root@stat authbind-2.1.1]# cd /etc/authbind/
[root@stat authbind]# ls
byaddr byport byuid
之后按照authbind --deep实现linux 普通账户绑定1024以下端口。
以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。
本文来自系统大全http://www.win7cn.com/如需转载请注明!推荐:win7纯净版
相关文章
- 系统之家装机大师 U 盘重装 Win10 系统详细教程
- 系统之家装机大师 U 盘重装 Win11 系统详细教程
- 系统之家装机大师 U 盘重装 Win7 系统详细教程
- 微软大幅上调 Windows OEM 授权费 7%-10%!
- WSL 现已支持 Azure‑Linux4.0,兼容 x86‑64 与 Arm64 硬件架构
- 火狐浏览器 2026 最大改版 Nova 上线,更柔和、更个性化
- Chrome Linux ARM64 正式上线,支持账号同步与 Widevine DRM
- Xbox 推送预览系统更新:新增智能下载优化速度
- Win11 三大预览通道同步更新:修复 0xc0000409 安装故障并优化大量 UI
- 微软重构 Windows 11 搜索体验:减少广告网页结果,优先本地内容
系统下载排行榜71011xp
【番茄花园】Win7 64位 快速稳定版
2【纯净之家】Windows7 32位 全新纯净版
3【雨林木风】Windows7 64位 装机旗舰版
4【纯净之家】Win7 64位 Office2007 办公旗舰版
5JUJUMAO Win7 64位旗舰纯净版
6【电脑公司】Windows7 64位 免费旗舰版
7【游戏专用】Windows7 64位 装机旗舰版
8【深度技术】Windows7 64位 官方旗舰版
9【番茄花园】Windows7 64位 旗舰装机版
10【纯净之家】Windows7 SP1 32位 全补丁旗舰版
【纯净之家】Windows10 22H2 64位 企业版
2【纯净之家】Windows10 32位 官方正式版
3【技术员】Windows10 64位 纯净版iso镜像
4【雨林木风】Windows10 64位稳定版系统
5JUJUMAO Win10 64位 纯净版镜像
6【技术员】Windows10 64位 系统纯净版
7【技术员】Windows10 64位 纯净装机版
8【番茄花园】Windows10 64位 专业版镜像
9【雨林木风】Windows10 64位 中文精简版
10【雨林木风】Windows10 64位 官方专业版
【纯净之家】Windows11 23H2 64位 纯净专业版
2【纯净之家】Windows11 23H2 64位 游戏优化版
3【纯净之家】Windows11 23H2 64位 企业版系统
4【纯净之家】Windows11 23H2 64位 中文家庭版
5风林火山Windows11下载中文版(24H2)
6JUJUMAO Win11 24H2 64位 精简版镜像
7JUJUMAO Win11 24H2 64位 专业版镜像
8【纯净之家】Windows11 23H2 64位 纯净家庭版
9电脑公司Win11 64位高级专业版系统 V2022
10电脑公司Win11 64位专业优化版 V2021.08
深度技术 GHOST XP SP3 电脑专用版 V2017.03
2深度技术 GGHOST XP SP3 电脑专用版 V2017.02
3萝卜家园 GHOST XP SP3 万能装机版 V2017.03
4番茄花园 GHOST XP SP3 极速体验版 V2017.03
5雨林木风 GHOST XP SP3 官方旗舰版 V2017.03
6萝卜家园 GHOST XP SP3 完美装机版 V2016.10
7Win7系统下载 PCOS技术Ghost WinXP SP3 2017 夏季装机版
8电脑公司 GHOST XP SP3 经典旗舰版 V2017.03
9雨林木风GHOST XP SP3完美纯净版【V201710】已激活
10雨林木风 GHOST XP SP3 精英装机版 V2017.04
热门教程
装机必备 更多+
重装工具