免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: 剑心通明
打印 上一主题 下一主题

专题讨论之handbook版-第3章(讨论版) [复制链接]

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
51 [报告]
发表于 2005-10-17 11:44 |只看该作者

专题讨论之handbook版-第3章(讨论版)

设置了t以后root用户还是可以任意删除的吧?我说哪,我在用root实验,怎么不管用哪

论坛徽章:
0
52 [报告]
发表于 2005-10-17 12:08 |只看该作者

专题讨论之handbook版-第3章(讨论版)

[quote]原帖由 "剑心通明"]关于chmod,除了大家都比较清楚的rwx以为,谁给说说其他的标志位,t、s等如何使用的[/quote 发表:


这个关于权限和标志位的问题,网中人写过一篇文章比较清楚的,你可以到linux看看。

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
53 [报告]
发表于 2005-10-17 12:20 |只看该作者

专题讨论之handbook版-第3章(讨论版)

原帖由 "access-list" 发表:


这个关于权限和标志位的问题,网中人写过一篇文章比较清楚的,你可以到linux看看。
我看的好像就是那篇文章,正在实验中

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
54 [报告]
发表于 2005-10-17 12:37 |只看该作者

专题讨论之handbook版-第3章(讨论版)

做个实验吧:
以temp用户登录,
$pwd
/tmp
$mkdir temp
$ll
drwxr-xr-x  2 temp  wheel       512 Oct 17 11:56 temp/
$cd temp
$touch temp1
$touch temp2
$ll
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
这个时候,temp目录的权限是755,因为文件属组没有写权限,因此只有temp用户才能在temp目录下建文件,其它用户只能读、访问temp目录,无法建文件的,当然root用户除外,我刚开始是用root作实验的,我说哪怎么设置半天都不管用哪
换test用户登录实验
$touch test1
touch:test1ermission denied
用root是可以的:
desktop# touch root1
desktop# ll
total 0
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
好了,现在给temp目录写权限。
换temp用户
$ll
drwxr-xr-x  2 temp  wheel       512 Oct 17 11:56 temp/
$chmod g+w temp
$ll
drwxrwxr-x  2 temp  wheel       512 Oct 17 12:04 temp
当然root用户也可以改temp的权限了,试试
desktop# chmod g-w temp
desktop# ll
drwxr-xr-x  2 temp  wheel       512 Oct 17 12:04 temp
hehe,root就是牛啊
再改回来继续实验吧:
desktop# chmod g+w temp
desktop# ll
drwxrwxr-x  2 temp  wheel       512 Oct 17 12:04 temp
现在temp目录属组可以写了,换test用户应该就可以新建文件了,试试吧:
$touch test1
$touch test2
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
再来试试删除另外用户的文件吧:
$rm test1
override rw-r--r-- temp/wheel for temp1?
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
不可以的,因为temp1的权限是644,只有temp用户才能删除,现在把temp1的权限修改一下试试:
换temp用户登录
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
$chmod g+w temp1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-rw-r--  1 temp  wheel  0 Oct 17 11:57 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
再换回test用户来删除试试:
$rm temp1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
ok了,已经删除掉了。
现在该试sticky bit了,换到temp用户下
$ll
drwxr-xr-x  2 temp  wheel       512 Oct 17 11:56 temp/
$chmod g+t temp
$ll
drwxrwxr-t  2 temp  wheel       512 Oct 17 12:16 temp
$cd temp
$touch temp1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-r--r--  1 temp  wheel  0 Oct 17 12:25 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
然后给temp1属组写权限,按照上面的实验,如果没有设置sticky bit的话,test用户应该是可以删除的,我们试试吧
$chmod g+w temp1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-rw-r--  1 temp  wheel  0 Oct 17 12:25 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
好了,换test用户吧:
$rm temp1
rm:temp1:Operation not permitted
同样的,让test用户也改个权限
$chmod g+w test1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-rw-r--  1 temp  wheel  0 Oct 17 12:25 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-rw-r--  1 test  wheel  0 Oct 17 12:10 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
看看temp用户行不行?
$rm test1
居然可以?!
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-rw-r--  1 temp  wheel  0 Oct 17 12:25 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
怎么搞的?难道因为temp目录是temp用户建的,他就可以删除了?我再换个新用户去。
用test用户重新建test1文件,并给属组写权限:
$touch test1
$chmod g+w test1
$ll
-rw-r--r--  1 root  wheel  0 Oct 17 12:04 root1
-rw-rw-r--  1 temp  wheel  0 Oct 17 12:25 temp1
-rw-r--r--  1 temp  wheel  0 Oct 17 11:57 temp2
-rw-rw-r--  1 test  wheel  0 Oct 17 12:33 test1
-rw-r--r--  1 test  wheel  0 Oct 17 12:10 test2
现在换新建的aaa用户来删除试试:
$rm test1
rm:test1:Operation not permitted
还真的是这样啊,我猜的没错。

论坛徽章:
0
55 [报告]
发表于 2005-10-17 13:39 |只看该作者

专题讨论之handbook版-第3章(讨论版)

[quote]原帖由 "剑心通明"]铱吹暮孟窬褪悄瞧?恼拢??谑笛橹?[/quote 发表:


那个链接我找了很久也找不到了,贴出来给我看看,thx

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
56 [报告]
发表于 2005-10-17 18:37 |只看该作者

专题讨论之handbook版-第3章(讨论版)

原帖由 "剑心通明" 发表:
正在看chmod的相关文章,有几个问题不大明白,望各位指点:
1:目录的大小计算。所谓的目录入口占用空间是如何计算的?
2:那个sticky bit位如果文件设置了是什么意思?看有的帖子说是为了共享文件,不大理解
3:sui..........


1.不懂
2.如果设置了目录的粘滞位,那么只有文件和目录的所有者可以删除该目录下的文件。 (一般使用于类似于/tmp这样有基本写权限的目录) .也就是说多个用户可以共享一个目录,但是该目录下的文件只有此文件的属主才可以删除。

3.suid怎么写都是setuid吧。

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
57 [报告]
发表于 2005-10-17 19:05 |只看该作者

专题讨论之handbook版-第3章(讨论版)

加了sticky bit以后,非root用户,确实是只能删除自己的文件,即使该文件所属的组对它有写权限也不行,但是建这个目录的用户却可以删除,为什么?

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
58 [报告]
发表于 2005-10-17 19:10 |只看该作者

专题讨论之handbook版-第3章(讨论版)

原帖由 "FinalBSD" 发表:


1.不懂
2.如果设置了目录的粘滞位,那么只有文件和目录的所有者可以删除该目录下的文件。 (一般使用于类似于/tmp这样有基本写权限的目录) .也就是说多个用户可以共享一个目录,但是该目录下的文件只有此..........

如果设置了目录的粘滞位,那么只有文件和目录的所有者可以删除该目录下的文件。

明白了,呵呵

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
59 [报告]
发表于 2005-10-17 19:15 |只看该作者

专题讨论之handbook版-第3章(讨论版)

http://www.douzhe.com/article/data/7/300.html
好像这里有一部分,我也不知道都是哪的了,到处复制的,嘿嘿

论坛徽章:
2
丑牛
日期:2013-09-29 09:47:222015七夕节徽章
日期:2015-08-21 11:06:17
60 [报告]
发表于 2005-10-17 19:16 |只看该作者

专题讨论之handbook版-第3章(讨论版)

setuid的部分今天跑去测试视频会议的东东了,明天继续看吧,累死了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP