- 论坛徽章:
- 0
|
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/security.h>
- #include <linux/fs.h>
- #include <linux/file.h>
- MODULE_LICENSE("GPL");
- static int td_inode_setxattr(struct dentry *dentry, char *name,
- void *value, size_t size, int flags)
- {
- printk(KERN_INFO "This is the vit_inode_setxattr\n");
- return 0;
- }
- static int td_inode_getxattr(struct dentry *dentry, char *name)
- {
- printk(KERN_INFO "This is the vit_inode_getxattr\n");
- return 0;
- }
- static struct security_operations td_security_ops = {
- .inode_setxattr = td_inode_setxattr,
- .inode_getxattr = td_inode_getxattr,
- };
- static int __init td_init(void)
- {
- if (register_security(&td_security_ops) != 0) {
- printk(KERN_INFO
- "Failure registering module with the kernel\n");
- } else
- printk(KERN_INFO "Success registering module with the kernel\n");
-
- return 0;
- }
- static void __exit td_exit(void)
- {
- if (unregister_security(&td_security_ops) != 0) {
- printk(KERN_INFO
- "Failure unregistering module with the kernel\n");
- } else
- printk(KERN_INFO "Success unregistering module withe the kernel\n");
- }
- module_init(td_init);
- module_exit(td_exit);
复制代码 写了一个简单的lsm 模块,通过register_security 注册一个struct security_operations 但总是提示注册失败 |
|