免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1394 | 回复: 0
打印 上一主题 下一主题

[内核模块] register_security 失败 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-05-16 11:36 |只看该作者 |倒序浏览
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/init.h>
  4. #include <linux/security.h>
  5. #include <linux/fs.h>
  6. #include <linux/file.h>

  7. MODULE_LICENSE("GPL");

  8. static int td_inode_setxattr(struct dentry *dentry, char *name,
  9.                         void *value, size_t size, int flags)
  10. {
  11.         printk(KERN_INFO "This is the vit_inode_setxattr\n");
  12.         return 0;
  13. }

  14. static int td_inode_getxattr(struct dentry *dentry, char *name)
  15. {
  16.         printk(KERN_INFO "This is the vit_inode_getxattr\n");
  17.         return 0;
  18. }

  19. static struct security_operations td_security_ops = {
  20.         .inode_setxattr =         td_inode_setxattr,
  21.         .inode_getxattr =        td_inode_getxattr,
  22. };

  23. static int __init td_init(void)
  24. {
  25.         if (register_security(&td_security_ops) != 0) {
  26.                 printk(KERN_INFO
  27.                         "Failure registering module with the kernel\n");
  28.         } else
  29.                 printk(KERN_INFO "Success registering module with the kernel\n");
  30.        

  31.         return 0;
  32. }

  33. static void __exit td_exit(void)
  34. {
  35.         if (unregister_security(&td_security_ops) != 0) {
  36.                 printk(KERN_INFO
  37.                         "Failure unregistering module with the kernel\n");
  38.         } else
  39.                 printk(KERN_INFO "Success unregistering module withe the kernel\n");
  40. }

  41. module_init(td_init);
  42. module_exit(td_exit);
复制代码
写了一个简单的lsm 模块,通过register_security 注册一个struct security_operations 但总是提示注册失败
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP