yii 学习笔记六、后台模块效果设计
2014-04-07 20:26
465 查看
4.5 of Advanced Programming in the UNIX programming has a very clear explanation for file access permissions.
Here is an experiment to show the explanation.
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, const char *argv[]) { int fd; if ((fd = open("data", O_RDONLY)) < 0) { printf("open error\n"); return 1; } else { printf("open ok\n"); return 0; } }
$ gcc code.c
$ echo abc > data
$ ls -l
-rwxr-xr-x 1 jing jing 7174 2010-10-09 17:27 a.out
-rw-r--r-- 1 jing jing 302 2010-10-09 17:19 code.c
-rw-r--r-- 1 jing jing 4 2010-10-09 17:26 data
$ /a.out
open ok
$ chmod u-r data
$ /a.out
open error
$ id
uid=1000(jing) gid=1000(jing) groups=4(adm),20(dialout),24(cdrom),46(plugdev),104(lpadmin),115(admin),120(sambashare),121(vboxusers),125(kvm),126(libvirtd),1000(jing)
Here is the tricky part. If the effective user id is equal to the file owner id and it does not have the read permission, the permission is denied even the effective group id is equal to the file group id and does has the read permission.
$ sudo chown test data
$ ./a.out
open ok
$ sudo chown :kvm data
$ ./a.out
open ok
kvm is a supplementary group of the current user jing. So the file can be still opened after its group being set to kvm.
$ sudo chmod g-r data
$ ./a.out
open error
$ sudo chown :fax data
$ ./aout
open ok
$ sudo chmod o-r data
$ ./a.out
open error
相关文章推荐
- yii 学习笔记六、模块理解
- php学习笔记-后台模块
- Linux内核设计与实现 学习笔记(7)设备与模块
- [知了堂学习笔记]_EasyUi快速搭建一个权限管理的模块(1)--RBAC概述和数据库设计
- OpenCV学习笔记-用控制器设计模式实现功能模块间的通信
- 网上图书商城项目学习笔记-024后台模块介绍及管理员登录
- java设计模式学习笔记之模块方法模式
- maven 多模块工程设计架构设计---学习笔记
- OPENCV学习笔记3-2_用控制器设计模式实现功能模块间通信
- 『框架设计(第2版)CLR Via C#』学习笔记(001)——将源代码编译成托管模块
- 微软企业库4.1学习笔记(十八)缓存模块6 缓存的设计目的
- 关于后盾网yii框架的学习小结(5)--验证码的使用与规则的设置,为后台模块设置独立的布局
- cocos2d-x 3.0游戏实例学习笔记《卡牌塔防》第0步---知识点总结&效果预览&设计思路
- linux内核设计与实现学习笔记-模块
- 微软企业库4.1学习笔记(十八)缓存模块6 缓存的设计目的
- 微软企业库4.1学习笔记(十八)缓存模块6 缓存的设计目的
- 关于后盾网yii框架的学习小结(5)--验证码的使用与规则的设置,为后台模块设置独立的布局
- 微软企业库4.1学习笔记(十八)缓存模块6 缓存的设计目的
- 我脑残实验室Verilog学习笔记——在Xilinx ISE中运用符号设计顶层模块的方法
- 【JAVAWEB学习笔记】网上商城实战5:后台的功能模块