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纯净版
相关文章
- 微软Win10 21H2/22H2 6月累计更新补丁KB5060533发布!
- 微软Win11 22H2/23H2发布6月累积更新补丁KB5060999!
- 微软 Win11 24H2 推送 6 月累积更新补丁 KB5060842 !
- 重装系统,电脑只有一个C盘怎么创建分区
- 如何使用U盘重装Windows10系统-U盘重装Win10最简单的方法
- 如何使用U盘重装Windows11系统-U盘重装Win11最简单的方法
- 如何使用U盘重装Windows7系统-U盘重装Win7最简单的方法
- 微软Win10 22H2 5月更新补丁KB5058481发布!
- 微软 Win11 24H2 发布 5 月可选更新补丁KB5058499!
- Win7系统屏幕键盘的打开方法
系统下载排行榜71011xp
番茄花园 Win7 64位 快速稳定版
2【纯净之家】Windows7 64位 最新纯净版
3【老机专用】Windows7 32位 精简旗舰版
4【纯净之家】Windows7 SP1 64位 全补丁旗舰版
5JUJUMAO Win7 64位 最新纯净版
6【纯净之家】Windows7 32位 最新纯净版
7【纯净之家】Windows7 SP1 64位 办公旗舰版
8【雨林木风】Windows7 64位 装机旗舰版
9【电脑公司】Windows7 64位 免费旗舰版
10【国庆献礼】JUJUMAO Win7 SP1 64位旗舰克隆纯净版
【纯净之家】Windows10 22H2 64位 专业工作站版
2【纯净之家】Windows10 22H2 64位 游戏优化版
3【纯净之家】Windows10 企业版 LTSC 2021
4【纯净之家】Windows10企业版LTSC2021 纯净版
5【深度技术】Windows10 64位 专业精简版
6联想Lenovo Windows10 22H2 64位专业版
7JUJUMAO Win8.1 Up3 X64 极速精简版v2019.11
8【纯净之家】Windows10 22H2 64位 专业精简版
9【雨林木风】Windows10 64位 专业精简版
10【纯净之家】Windows10 22H2 64位 专业办公版
【纯净之家】Windows11 23H2 64位 游戏优化版
2【纯净之家】Windows11 23H2 64位 专业工作站版
3【纯净之家】Windows11 23H2 64位 纯净专业版
4风林火山Windows11下载中文版
5【纯净之家】Windows11 23H2 64位 最新企业版
6【纯净之家】Windows11 23H2 64位 中文家庭版
7JUJUMAO Win11 24H2 64位 专业版镜像
8深度精简 Win11 ESD 全新优化纯净版V2024
9【纯净之家】Windows11 23H2 64位专业精简版
10【纯净之家】Windows11 23H2 64位 纯净家庭版
深度技术 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
热门教程
装机必备 更多+
重装工具