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中发现:http://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纯净版
相关文章
- 微软 Win11 Canary 预览版 27975 发布!附补丁文件下载
- 微软 Win11 23H2 RP 22631.6132 预览版发布!更新内容一览
- 微软 Win11 24H2 推送 9 月可选更新补丁 KB5065789!
- 微软Win11 Dev 26220.6760(KB5065793)发布!附补丁文件下载
- 微软 Win11 Beta 预览版 Build 26120.6760 发布!
- 微软推送 Win10 22H2 最后可选更新 KB5066198!
- 微软 Win11 Canary 预览版 27954 发布!附补丁文件下载
- 家庭版系统打开本地组策略编辑器的方法
- 纯净版系统汇总:专业版 / 工作站版 / 家庭版 / 企业版 / 旗舰版
- Win11 24H2微软账号无法登录解决方法
系统下载排行榜71011xp
番茄花园 Win7 64位 快速稳定版
2【纯净之家】Windows7 64位 全新纯净版
3【纯净之家】Windows7 SP1 64位 全补丁旗舰版
4JUJUMAO Win7 64位 最新纯净版
5【纯净之家】Windows7 32位 全新纯净版
6【纯净之家】Win7 64位 Office2007 办公旗舰版
7【雨林木风】Windows7 64位 装机旗舰版
8【电脑公司】Windows7 64位 免费旗舰版
9JUJUMAO Win7 64位旗舰纯净版
10【深度技术】Windows7 64位 官方旗舰版
【纯净之家】Windows10 22H2 64位 专业工作站版
2【纯净之家】Windows10 22H2 64位 游戏优化版
3【纯净之家】Windows10 企业版 LTSC 2021
4【纯净之家】Windows10企业版LTSC 2021 纯净版
5【深度技术】Windows10 64位 专业精简版
6联想Lenovo Windows10 22H2 64位专业版
7JUJUMAO Win10 X64 极速精简版
8【雨林木风】Windows10 64位 专业精简版
9深度技术 Win10 64位国庆特别版
10【纯净之家】Win10 64位 Office2007 专业办公版
【纯净之家】Windows11 23H2 64位 游戏优化版
2【纯净之家】Windows11 23H2 64位 专业工作站版
3【纯净之家】Windows11 23H2 64位 纯净专业版
4风林火山Windows11下载中文版(24H2)
5【纯净之家】Windows11 23H2 64位 企业版
6【纯净之家】Windows11 23H2 64位 中文家庭版
7JUJUMAO Win11 24H2 64位 专业版镜像
8【纯净之家】Windows11 23H2 64位专业精简版
9【纯净之家】Windows11 23H2 64位 纯净家庭版
10Windows11 23H2 64位 官方正式版 V22631.6060
深度技术 GHOST XP SP3 电脑专用版 V2017.03
2深度技术 GGHOST XP SP3 电脑专用版 V2017.02
3Win7系统下载 PCOS技术Ghost WinXP SP3 2017 夏季装机版
4番茄花园 GHOST XP SP3 极速体验版 V2017.03
5萝卜家园 GHOST XP SP3 万能装机版 V2017.03
6雨林木风 GHOST XP SP3 官方旗舰版 V2017.03
7电脑公司 GHOST XP SP3 经典旗舰版 V2017.03
8雨林木风GHOST XP SP3完美纯净版【V201710】已激活
9萝卜家园 GHOST XP SP3 完美装机版 V2016.10
10雨林木风 GHOST XP SP3 精英装机版 V2017.04
热门教程
装机必备 更多+
重装工具