Problem while compiling a module for LSM

From: Hemal (hemal.rathod@private)
Date: Thu Oct 28 2004 - 02:09:04 PDT


Dear All,

I just installed the linux 2.6.9 kernel on Red Hat Enterprise Linux
with 2.4.21 on it. It compiled nicely. While configuring the 2.6.9
kernel, I dint select any of the security modules listed there since I
wanted to register my module with LSM. My example module looks like
this:

/* CBox lsm interface */
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/security.h>

MODULE_LICENSE("GPL");


static int cbox_inode_alloc_security(struct inode *inode)
{
	printk(KERN_WARNING "Yahoo");
        return 0;
}
 
static void cbox_inode_free_security(struct inode *inode)
 {
	 printk(KERN_WARNING "Deleted...\n");

}

static int cbox_inode_mkdir_security(struct inode *inode, struct dentry
*dentry, int mask)
{
       printk(KERN_WARNING "Dir Created... \n");
       return 0;
}

static struct security_operations cbox_security_operations = {


         .inode_alloc_security =         cbox_inode_alloc_security,
         .inode_free_security =          cbox_inode_free_security,
	 .inode_mkdir = 		 cbox_inode_mkdir_security,
  
};


int cbox_lsm_init (void)
{

if (!(register_security(&cbox_security_operations)))
               printk(KERN_WARNING "register LSM done\n");
	return 0;


}

void cbox_lsm_exit (void)
{
	if (!(unregister_security(&cbox_security_operations)))
               printk(KERN_WARNING "unregister LSM done\n");

       return 0;
}

module_init(cbox_lsm_init);
module_exit(cbox_lsm_exit);

***************************************************************************************************

My Makefile is:


ifneq ($(KERNELRELEASE),)
obj-m:= exam1.o

else
KDIR:= /lib/modules/$(shell uname -r)/build
PWD:= $(shell pwd)

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
endif

***************************************************************************************************

when I type make, i get the following error:

[root@localhost root]# make
make -C /lib/modules/2.6.9/build SUBDIRS=/root modules
make[1]: Entering directory `/root/linux-2.6.9'
  CC [M]  /root/exam1.o
/root/exam1.c:30: variable `cbox_security_operations' has initializer
but incomplete type
/root/exam1.c:33: unknown field `inode_alloc_security' specified in initializer
/root/exam1.c:33: warning: excess elements in struct initializer
/root/exam1.c:33: warning: (near initialization for `cbox_security_operations')
/root/exam1.c:34: unknown field `inode_free_security' specified in initializer
/root/exam1.c:34: warning: excess elements in struct initializer
/root/exam1.c:34: warning: (near initialization for `cbox_security_operations')
/root/exam1.c:35: unknown field `inode_mkdir' specified in initializer
/root/exam1.c:35: warning: excess elements in struct initializer
/root/exam1.c:35: warning: (near initialization for `cbox_security_operations')
/root/exam1.c: In function `cbox_lsm_init':
/root/exam1.c:43: warning: implicit declaration of function `register_security'
/root/exam1.c: In function `cbox_lsm_exit':
/root/exam1.c:52: warning: implicit declaration of function
`unregister_security'
/root/exam1.c:55: warning: `return' with a value, in function returning void
/root/exam1.c: At top level:
/root/exam1.c:30: storage size of `cbox_security_operations' isn't known
make[2]: *** [/root/exam1.o] Error 1
make[1]: *** [_module_/root] Error 2
make[1]: Leaving directory `/root/linux-2.6.9'
make: *** [default] Error 2
[root@localhost root]#


Can anyone please help me sort the problem. Your help will be very
much appreciated. Thanks.



-- 
Cheers
Hemal



This archive was generated by hypermail 2.1.3 : Thu Oct 28 2004 - 02:09:30 PDT