selinux对文件的控制
来源:互联网 发布:php面试编程题 编辑:程序博客网 时间:2024/09/21 08:15
[root@localhost ~]# ls -Z /var/ftp/pub 显示上下文
[root@localhost ~]# ps auxZ | grep vsftpd 显示文件上下文
[root@localhost ~]# chcon -t public_content_t /var/ftp/pub/westos ##更改文件上下文
在设置之前需要纯净的环境,所以先要删除之前配置的文件,重新安装ftp服务
[root@localhost ~]# rm -fr /etc/vsftpd/ ##删除之前配置的文件,准备重新安装ftp服务[root@localhost ~]# yum reinstall vsftpd.x86_64 ##重新安装ftp服务Loaded plugins: langpacksrhel_dvd | 4.1 kB 00:00:00 Package vsftpd-3.0.2-9.el7.x86_64 already installed and latest versionNothing to do[root@localhost ~]# yum reinstall vsftpd.x86_64 Loaded plugins: langpacksResolving Dependencies--> Running transaction check---> Package vsftpd.x86_64 0:3.0.2-9.el7 will be reinstalled--> Finished Dependency ResolutionDependencies Resolved================================================================================= Package Arch Version Repository Size=================================================================================Reinstalling: vsftpd x86_64 3.0.2-9.el7 rhel_dvd 166 kTransaction Summary=================================================================================Reinstall 1 PackageTotal download size: 166 kInstalled size: 343 kIs this ok [y/d/N]: yDownloading packages:vsftpd-3.0.2-9.el7.x86_64.rpm | 166 kB 00:00:00 Running transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : vsftpd-3.0.2-9.el7.x86_64 1/1 Verifying : vsftpd-3.0.2-9.el7.x86_64 1/1 Installed: vsftpd.x86_64 0:3.0.2-9.el7 Complete![root@localhost ~]# systemctl restart vsftpd.service 开启ftp服务[root@localhost ~]# vim /etc/sysconfig/selinux 将selinux改为enforcing 7 SELINUX=enforcing 再reboot[root@localhost ~]# setenforce 1 ##直接更改setenforce 0为disabled 1为enforcing[root@localhost ~]# getenforce ##显示selinuxEnforcing
接下来进行selinux对文件的控制,修改其文件上下文
root@localhost ~]# touch /mnt/westos ##在mnt目录下新建立一个文件[root@localhost ~]# mv /mnt/westos /var/ftp/pub/ ##移动 /mnt/westos 到/var/ftp/pub/mv: overwrite ‘/var/ftp/pub/westos’? y 另一边检测:[kiosk@foundation20 Desktop]$ lftp 172.25.254.220 lftp 172.25.254.220:~> cd /pubcd ok, cwd=/pub lftp 172.25.254.220:/pub> ls-rw-r--r-- 1 14 50 3633280 Apr 23 04:52 big-rw-r--r-- 1 14 50 2400784 Apr 23 03:56 bigfile-rw------- 1 14 50 0 Apr 23 02:58 file-rw-r--r-- 1 14 50 0 Apr 23 03:27 file1-rw-r--r-- 1 14 50 0 Apr 23 04:50 newfile-rw-r--r-- 1 14 50 2146 Apr 23 03:55 passwddrwx------ 2 14 50 6 Apr 23 03:11 testlftp 172.25.254.220:/pub> exit开始更改文件上下文[root@localhost ~]# ls -Z /var/ftp/pub 显示上下文-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 big-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 bigfile-rw-------. ftp ftp system_u:object_r:public_content_t:s0 file-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 file1-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 newfile-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 passwddrwx------. ftp ftp system_u:object_r:public_content_t:s0 test-rw-r--r--. root root unconfined_u:object_r:mnt_t:s0 westos[root@localhost ~]# ps auxZ | grep vsftpd 显示文件上下文system_u:system_r:ftpd_t:s0-s0:c0.c1023 root 2451 0.0 0.0 52756 688 ? Ss 05:10 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.confsystem_u:system_r:ftpd_t:s0-s0:c0.c1023 nobody 2557 0.0 0.0 54852 1416 ? Ss 05:17 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.confsystem_u:system_r:ftpd_t:s0-s0:c0.c1023 ftp 2559 0.0 0.0 56960 1444 ? S 05:17 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.confunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 2577 0.0 0.0 112640 940 pts/0 S+ 05:18 0:00 grep --color=auto vsftpd[root@localhost ~]# chcon -t public_content_t /var/ftp/pub/westos ##更改文件上下文[root@localhost ~]# ps auxZ | grep vsftpd 显示文件上下文system_u:system_r:ftpd_t:s0-s0:c0.c1023 root 2451 0.0 0.0 52756 688 ? Ss 05:10 0:00 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.confunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 2627 0.0 0.0 112640 936 pts/0 S+ 05:22 0:00 grep --color=auto vsftpd[root@localhost ~]# ls -Z /var/ftp/pub/-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 big-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 bigfile-rw-------. ftp ftp system_u:object_r:public_content_t:s0 file-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 file1-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 newfile-rw-r--r--. ftp ftp system_u:object_r:public_content_t:s0 passwddrwx------. ftp ftp system_u:object_r:public_content_t:s0 test-rw-r--r--. root root unconfined_u:object_r:public_content_t:s0 westos在另一边检测lftp 172.25.254.220[kiosk@foundation20 Desktop]$ lftp 172.25.254.220 lftp 172.25.254.220:~> cd /pubcd ok, cwd=/pub lftp 172.25.254.220:/pub> ls-rw-r--r-- 1 14 50 3633280 Apr 23 04:52 big-rw-r--r-- 1 14 50 2400784 Apr 23 03:56 bigfile-rw------- 1 14 50 0 Apr 23 02:58 file-rw-r--r-- 1 14 50 0 Apr 23 03:27 file1-rw-r--r-- 1 14 50 0 Apr 23 04:50 newfile-rw-r--r-- 1 14 50 2146 Apr 23 03:55 passwddrwx------ 2 14 50 6 Apr 23 03:11 test-rw-r--r-- 1 0 0 0 Apr 23 09:10 westos
0 0
- selinux对文件的控制
- selinux对文件的控制
- selinux对文件的控制
- selinux对文件的控制
- selinux对文件的控制
- selinux对文件的控制
- selinux对文件的控制
- Linux学习第十单元-selinux对文件的控制
- RH134-第二十一节-selinux对文件的控制
- selinux对mysql控制
- Linux运维笔记-文档总结- selinux对文件的控制
- SELinux对网站目录权限控制的不当的问题
- SElinux的强制访问控制
- [顶]解决SELinux对网站目录权限控制的不当的问题 20
- seandroid对selinux的改进
- 控制对文件的访问
- 控制对文件的访问
- 对文件的访问控制
- android 状态栏只显示电量时间
- ubuntu下tensorflow的环境搭建
- Docker 组件如何协作?- 每天5分钟玩转容器技术(8)
- 网络习题汇总
- Servlet -------总结二
- selinux对文件的控制
- 某水题
- Quant finance blogs
- 基于 Jest + Enzyme 的 React 单元测试
- 0427
- 多图FTP上传
- 用matlab处理蚂蚁迷宫问题
- Android高仿京东淘宝商品列表布局切换效果
- TFLearn Tutorials | TensorFlow入门